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
Client is an application that detects the connection of an external USB storage device, mounts its primary partition with the ext4 file system in the /mnt directory, and checks the performance of the file system by performing test operations (creating, writing, reading, and deleting a file).FileVfs is an application that implements the server portion of the virtual file system, thereby providing the interface used for interaction with file systems and block devices.USB – driver for managing all types of USB devices.UsbMassStorage is a driver used to access data on external USB drives (USB flash drives and external hard drives).EntropyEntity – system program that implements random number generation.DCM – system program that lets you dynamically create IPC channels.When you build an example for the target hardware platform, platform-specific drivers are automatically included in the solution:
BSP is a hardware platform support package (Board Support Package). Provides cross-platform configuration of peripherals for the Radxa ROCK 3A.GPIO – GPIO support driver for the Radxa ROCK 3A.PinCtrl – low-level pin multiplexing (pinmux) configuration driver for the Radxa ROCK 3A.PCIE – PCIe bus driver for Raspberry Pi 4 B.Bcm2711MboxArmToVc – driver for working with the VideoCore (VC6) coprocessor via mailbox technology for Raspberry Pi 4 B.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