The API is defined in the header file sysroot-*-kos/include/kos/romfs.h from the KasperskyOS SDK.
The API is designed to work with ROMFS file systems, which includes the ROMFS image supplied as part of the KasperskyOS kernel image and the ROMFS image placed in memory by the bootloader (similar to initrd in Linux). The mechanism that implements the API does not use VFS.
The input data and output data of some API functions are associated with blobs because the romfs.h API implementation uses the blob_api.h API, which is designed to gain access to named blobs.
Information about API functions is provided in the table below.
Mounting a ROMFS image
To mount a ROMFS image, call the KosRomFsMount() or KosRomFsMountByHandle() function.
You must use the romFsName parameter of the KosRomFsMount() or KosRomFsMountByHandle() function to specify an arbitrary mount point name whose size must not exceed the value of the KOS_ROMFS_MAX_NAME constant (not counting the terminating zero). In one process, each mount point must have a unique name.
You must use the blobName parameter of the KosRomFsMount() function to specify the name of the blob containing the required ROMFS image: romfs.0 or romfs.1. In the first case, the ROMFS image will be mounted from the kernel image. In the second case, the ROMFS image that was placed in memory by the bootloader will be mounted.
In the blob parameter of the KosRomFsMountByHandle() function, you must specify the handle of the blob containing the required ROMFS image. This handle must be obtained by calling the KnBlobGet() function from the blob_api.h API. You must use the name parameter of the KnBlobGet() function to define the name of the blob containing the required ROMFS image: romfs.0 or romfs.1 (similar to the blobName parameter of the KosRomFsMount() function). After mounting, you can close the handle of the blob.
The KosRomFsMount() and KosRomFsMountByHandle() functions mount only in the calling process. The same ROMFS image can have several simultaneously existing mount points that were created by calls of the KosRomFsMount() or KosRomFsMountByHandle() function in one or more processes.
Opening a file
To open a file, you must call the KosRomFsOpen() function while specifying a string in the format <mount point name>/<file name> via the path parameter.
The same file can have several simultaneously existing identifiers that were obtained by calling the KosRomFsOpen() function in one or more processes. In this case, operations with the file via different identifiers are performed without mutual influence.
Reading data from a file
To read data from a file, use the KosRomFsRead() function. This function reads a file starting from the defined offset relative to the beginning of the file.
Receiving information about a file
To get the file size, call the KosRomFsGetFileSize() function.
To obtain information that includes the file size, the unique ID of the file in ROMFS, and the SID for the blob containing the ROMFS image, call the KosRomFsGetFileStat() function.
Closing a file
To close the file, call the KosRomFsClose() function.
Unmounting a ROMFS image
To unmount a ROMFS image, call the KosRomFsUnmount() function.
To unmount all ROMFS images, call the KosRomFsUnmountAll() function.
The KosRomFsUnmount() and KosRomFsUnmountAll() functions unmount only in the calling process.
A file that is open when the ROMFS image is unmounted remains available for operations until it is closed.
Information about API functions
Romfs.h functions
Function |
Information about the function |
|---|---|
|
Purpose Mounts a ROMFS image. Parameters
Returned values If successful, the function returns |
|
Purpose Mounts a ROMFS image. Parameters
Returned values If successful, the function returns |
|
Purpose Unmounts a ROMFS image. Parameters
Returned values If successful, the function returns |
|
Purpose Unmounts all ROMFS images. Parameters N/A Returned values If successful, the function returns |
|
Purpose Opens a file. Parameters
Returned values If successful, the function returns |
|
Purpose Closes a file. Parameters
Returned values If successful, the function returns |
|
Purpose Reads data from a file, starting from the defined offset. Parameters
Returned values If successful, the function returns |
|
Purpose Gets the size of a file. Parameters
Returned values If successful, the function returns |
|
Purpose Gets information about the file. Parameters
Returned values If successful, the function returns |