Wednesday, March 22, 2023

Linux Kernel Continued...

 

Linux also supports FUSE which is a user-space file-system framework. It consists of a kernel module (fuse.ko), a userspace library(libfuse.*) and a mount utility (fusermount). One of the most important features of FUSE is allowing secure non-privileged mounts. One example of this is the sshfs which is a secure network filesystem using the sftp protocol.

One of the common applications for FUSE filesystem is the use of a Watchdog to continuously monitor a folder to check for any new files or when an existing file is modified or deleted. As an example, if the size of the folder exceeds a limit, then it can be pruned. Watchdog is an open-source cross-platform python API library that can be used to monitor file systems. The Watchdog observer keeps monitoring the folder for any changes like file creation and when an event occurs, the event handler executes the event’s specified action.

Such usage is very common when there are a lot of files being uploaded to a file directory, let us say a hot folder and those files may never be used once they are processed. It helps to keep the file contents of the hot folder under a certain size limit for performance reasons. Therefore, another folder is created to roll over the contents from the hot folder. Let us call this folder the cold folder. It might so happen that processing might not have caught up with a file in the hot folder  and it is moved to the cold folder. The application then needs to check the hot folder first and then the cold folder and with the help of an attribute or a modification to the file name or the presence of an output file, detect if the file has been processed. The hot and cold folder are interchangeable for reading from and writing to the file. Since FUSE provides a bridge to the actual kernel interfaces, the library providing event handling interfaces can extend it to pass through the file operations without requiring the application to know whether the hot or cold folder is used. The only overrides to the operating system file system operations would be to resolve the appropriate folder.

No comments:

Post a Comment