mass_storage example

This example demonstrates use of the UsbMassStorage driver in KasperskyOS-based solutions to work with an external USB drive connected to the hardware platform's USB port.

Example directory in the SDK

The code of the example and build scripts are available at the following path:

/opt/KasperskyOS-Community-Edition-<platform>-<version>/examples/mass_storage

List of programs

When you build an example for the target hardware platform, platform-specific drivers are automatically included in the solution:

Initialization description

The solution initialization description file named init.yaml is generated during the solution build process based on the ./einit/src/init.yaml.in template. Macros in @INIT_*@‌ ‌format contained in the template are automatically expanded in the resulting init.yaml file. For more details, refer to init.yaml.in template.

Security policy description

The security policy description files for a KasperskyOS-based solution are located in the ./einit/src directory.

The security.psl file contains description of the solution security policy. The dynld.psl file contains a description of the security policy required for correct operation of dynamic linking in the solution, and is included in the top-level security.psl file via the use declaration.

Resources

The directory ./resources/xdl/mass_storage contains EDL descriptions for the Client and FileVfs programs.

Operating scenario

The Client program interacts with the FileVfs program, which acts as a VFS server through an IPC interface. FileVfs mounts the ext4 file system from an external USB drive to the /mnt directory. To test the mount functionality, the Client sequentially performs the following operations: creates a file named new_file, writes the test_message string to it, reads the contents, and deletes the file. The results of each operation are printed to the standard output stream.

Building and running the example

To prepare the USB drive for use in this example, run the following commands:

# In the following commands /dev/sde is the block device name of the connected USB drive

parted /dev/sde mklabel msdos

parted /dev/sde mkpart primary ext4 0% 100%

mkfs.ext4 -L flash /dev/sde1

See Building and running examples section.

Page top