KasperskyOS Community Edition 1.3

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 USB port of the Raspberry Pi 4 B.

Example directory in the SDK

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

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

List of programs

  • Client is an application that mounts file systems to specified directories on an external USB drive and performs basic file operations (create, write, read, and delete).
  • 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.
  • 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.
  • USB – driver for managing all types of USB devices.
  • PCIE is a PCIe bus driver.
  • 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 following template:

./einit/src/init.yaml.in

When building the example, the @INIT_Client_ENTITY_CONNECTIONS+@ macro in the init.yaml.in template in the init.yaml file is replaced by a list of IPC channels with all the system programs that are linked to the Client program. This list serves as a supplement to the manually defined IPC channels in the init.yaml.in template.

When building the example, the @INIT_FileVfs_ENTITY_CONNECTIONS@ macro in the init.yaml file is replaced by a list of IPC channels with all the system programs that are linked to the FileVfs program.

During the build, the @INIT_EXTERNAL_ENTITIES@ macro in the init.yaml.in template in the init.yaml file is replaced by a list of system programs that are linked to applications. This list contains the IPC channels of system programs, the run parameters of the main() function, and the values of environment variables.

For more details, refer to init.yaml.in template.

Security policy description

The security.psl file contains the solution security policy description and is generated based on the following template during the solution build process:

./einit/src/security.psl.in

During the solution build, the @INIT_EXTERNAL_ENTITIES@ macro in the security.psl.in template is replaced with a list of system programs that are included in the KasperskyOS SDK. For more details, refer to security.psl.in template.

Resources

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

Operating scenario

The Client program sends requests to the FileVfs program via IPC to mount file systems (ext2, ext3, ext4) to the specified directories and perform basic operations with files (create, write, read, and delete) to verify that the file systems are mounted correctly on an external USB drive. The results of operations are displayed in standard output.

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.