This example demonstrates how to mount file systems of a block device.
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/vfs_extfs
List of programs
Applications:
Client sends requests via IPC to the FileVfs program.FileVfs implements the server portion of the virtual file system, thereby providing the interface used for interaction with file systems and block devices.System programs and drivers:
DCM dynamically creates IPC channels.EntropyEntity implements random number generation.(Although this program is necessary in a solution that uses a standard configuration of a virtual file system, the program functionality is not used in this example.)SDCard is a physical storage device driver.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 and Raspberry Pi 4 B.Bcm2711MboxArmToVc – driver for working with the VideoCore (VC6) coprocessor via mailbox technology for Raspberry Pi 4 B.GPIO – GPIO support driver for the Radxa ROCK 3A.PinCtrl – low-level pin multiplexing (pinmux) configuration driver for the Radxa ROCK 3A.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. This file is a top-level file into which a portion of the solution security policy description in the form of the PSL file dynld.psl is included via the use declaration. (The declarations in the PSL file are annotated to explain the purpose of these declarations.) The dynld.psl file contains the part of the security policy that is used when dynamically linking the solution components.
Resources
The directory ./resources/xdl/vfs_extfs contains the Client.edl and FileVfs.edl files, which are the EDL descriptions for the example programs.
Operating scenario
The Client program interacts with the FileVfs program, which acts as a VFS server through an IPC interface. The FileVfs program mounts 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.
Building and running the example
The CMake system, which is included with KasperskyOS Community Edition, is used to build and run the example.
To run the example on a hardware platform, the SD card needs to have a bootable partition with the solution image as well as 3 additional partitions with the ext2, ext3 and ext4 file systems, respectively. To do so, you need to run the following commands:
# Image will contain a boot partition of 1 GB in fat32 and three partitions of 350 MB each in ext2, ext3 and ext4, respectively.
$ fs_image_name=sdcard.img
$ dd if=/dev/zero of=${fs_image_name} bs=1024k count=2048
$ sudo parted ${fs_image_name} mklabel msdos
$ loop_device=$(sudo losetup --find --show --partscan ${fs_image_name})
$ sudo parted ${loop_device} mkpart primary fat32 8192s 50%
$ sudo parted ${loop_device} mkpart extended 50% 100%
$ sudo parted ${loop_device} mkpart logical ext2 50% 67%
$ sudo parted ${loop_device} mkpart logical ext3 67% 84%
$ sudo parted ${loop_device} mkpart logical ext4 84% 100%
$ sudo parted ${loop_device} set 1 boot on
$ sudo mkfs.vfat ${loop_device}p1
$ sudo mkfs.ext2 ${loop_device}p5
$ sudo mkfs.ext3 ${loop_device}p6
$ sudo mkfs.ext4 -O ^64bit,^extent ${loop_device}p7
See Building and running examples section.
Page top