Filesystem in Userspace FUSE.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
International Journal of Computer Architecture and Mobility (ISSN 2319-9229) Volume 1-Issue 8, June 2013 Filesystem in Userspace (FUSE) Shashi Bahir, Rahul Bangar, Sujit Shetty, Saurabh Shinde, Vandana Jagtap Department of Computer Engineering, MIT Pune Pune University, India [email protected] [email protected] [email protected] [email protected] [email protected] Abstract- Developing kernel file systems for UNIX is a is a steep learning curve for doing kernel development due to challenging task, due to a variety of reasons. This approach the lack of facilities that are available to application requires the programmer to understand and deal with programmers complicated kernel code and data structures, making new code prone to bugs caused by programming errors. The kernel code User space filesystems have seen a strong resurgence. lacks memory protection, requires careful use of synchronization FUSE is a framework that allows file systems to be developed primitives, can be written only in C, and that too without being in userspace while offering ease of use and flexibility. linked against the standard C library. Debugging kernel code is also tedious, and errors can require rebooting the system. This document is meant to highlight the features of This document gives an idea about FUSE (loadable “Kernel loadable fuse”. The main idea is to make a kernel module), which allows non privileged users to develop completely new filesystem which interacts with the kernel but own file system in userspace. it is actually mounted in the userspace. With the help of the fuse application we would combine two different filesystem Keywords—VFS (Virtual File System), UNIX, kernel, userspace, and create a virtual file system. E.g. Windows (NTFS) filesystems Filesystem and Red Hat Linux Enterprise (EXT4) Filesystem this will make the user memory space big and a fast I. INTRODUCTION processing. When both the filesystems are mounted the virtual Developing in-kernel file systems for UNIX is a filesystem (VFS) created is to have a combination of these challenging task, due to a variety of reasons. This approach filesystem. This will make the user memory space big and a requires the programmer to understand and deal with fast processing. When the user want to access the internet the complicated kernel code and data structures, making new code Trivial Data Filesystem (TDFS) is going to interact with the prone to bugs caused by programming errors. Moreover, there Network FileSystem (NFS) Available Online at: www.ijcam.com International Journal of Computer Architecture and Mobility (ISSN 2319-9229) Volume 1-Issue 8, June 2013 mainstream operating systems. FUSE requires a programmer to deal only with a simple application programming interface (API) consisting of familiar file system operations. A variety of programming language bindings are available for FUSE, which, coupled with its simplicity, makes file system development accessible to a large number of programmers. FUSE file systems can also be mounted by nonprivileged users, which motivate novel uses for file systems. For instance, WikipediaFS allows a user to view and edit Wikipedia articles as if they were local files. Fig. 1 System Architecture The kernel code lacks memory protection, requires careful II. WORKING OF FUSE use of synchronization primitives, can be written only in C, and that too without being linked against the standard C library. Debugging kernel code is also tedious, and errors can require rebooting the system. Even a fully functional in-kernel file system has several disadvantages. Porting a file system written for a particular flavor of Unix to a different one can require significant changes in the design and implementation of the file system, even though the use of similar file system interfaces (such as Fig. 2 A flow-chart diagram illustrating how FUSE works the VFS layer) on several Unix-like systems makes the task somewhat easier. Besides, an in-kernel file system can be There is something of delineation between what is called mounted only with super user privileges. This can be a “kernel-space” and “user-space”. Kernel-space is roughly hindrance for file system development and usage on centrally indicated by anything that is happening within the kernel code administered machines, such as those in universities and or the “space” of the kernel code and resources, typically as a corporations. privileged user. On the other hand “user-space” indicates anything that is happening outside of the kernel where any In contrast to kernel development, programming in user user can create and run an application and use system space mitigates, or completely eliminates, several of the resources. abovementioned issues. The illustration corresponds to the “hello world” file FUSE is a widely used framework available for UNIX like system on the FUSE website. At a high level the “hello world” operating system, which allows non privileged users to file system is compiled to create a binary called “hello”. This develop file systems in user space. It has been merged into the binary is executed in the upper right hand corner of the Linux kernel, while ports are also available for several illustration with a file system mount point of /tmp/fuse. Then Available Online at: www.ijcam.com International Journal of Computer Architecture and Mobility (ISSN 2319-9229) Volume 1-Issue 8, June 2013 the user executes ls -l command against the mount point (ls -l during a maintenance period. But since it’s a file system is till /tmp/fuse). This command goes through glibc to the VFS. The recommend that you run it on a test system first before putting VFS then goes to the FUSE module since the mount point it into production. corresponds to a FUSE based file system. The FUSE kernel A third advantage is that if the file system crashes for module then goes through glibc and libfuse (libfuse is the some reason, it doesn’t necessarily take down the entire OS. If FUSE library in user space) and contacts the actual file system the kernel files system crashes, there is a distinct possibility binary (“hello”). The file system binary returns the results that the kernel could also throw an exception and crash. The back down the stack to the FUSE kernel model, back through kernel and file system developers have taken great pains to the VFS, and finally back to the ls -l command. prevent this from happening but the fact that the file system resides in kernel space increases the possibility of a problem causing a kernel panic compared to a user-space application III. ADVANTAGES OF FUSE that typically crashes without causing a kernel panic. If a user- The first advantage is that they don’t reside in the kernel, space file system crashes, you can just kill any associated naturally, so it’s fairly easy to distribute your code. That is, processes (I love “kill -9″ – just be sure you’re killing the the code does not have to go through the extremely rigorous correct process) and then remount the file system. Of course, and sometimes aggravating process of testing, review, there is the possibility of data corruption in this case, but justification, stylistic code changes, test, review, justification, hopefully the user-space file system designers have etc. Hopefully the developer(s) of the user-space file system mechanisms to limit this. have paid attention to security, maintainability, interactions with other user applications, etc., so that the code is reasonably safe for testing. Being in user-space also means IV. ILLUSTRATION that the file system code can be tested sooner since a bug Traditional operating system design makes a division usually just crashes the application and doesn’t cause a kernel between the “kernel” of the system, which is responsible for panic. Developers don’t have to wait for something complete interfacing with hardware devices, provides networking, file and tested before releasing to a wider test audience and can system and other low-level services and “user space” where get some very immediate feedback as to the usefulness of the user applications execute. Typically the kernel is file system. “monolithic,” meaning that all its services share a single The second advantage is that if there is an enhancement or memory address space and execute at elevated hardware a bug fix, you can quickly update the file system (no waiting privilege level, and strictly divided from user space, in which for a couple of kernel revisions). The file system is in user- each application has its own address space. space so you can update as you would any other user-space application using the package tools for your distribution (e.g. File systems are traditionally implemented in kernel space yum or apt-get). Of course, it is likely you will have to to take advantage of low overhead of accessing internal kernel unmount the file system, upgrade, and then remount the file services such as storage device drivers (typically this is to system, but this is a fairly common process that most avoid a context switch between user space and kernel space) administrators have mastered, typically performing upgrades and to make themselves transparently accessible to any and all Available Online at: www.ijcam.com International Journal of Computer Architecture and Mobility (ISSN 2319-9229) Volume 1-Issue 8, June 2013 user space processes. REFERENCES [1] Network Distributed File System in User FUSE project aims to provide the means by which file Space Ivan Voras, Mario Žagar Faculty of systems can be written in user space and exposed via the Electrical Engineering & Computing, University kernel to rest of the operating system in a transparent way (i.e. of Zagreb,Unska3,10000 Zagreb, Croatia not distinguishable from other file systems).