Title: Introduction to FUSE File system in USEr space
1Introduction to FUSE(File system in USEr space)
2Agenda
- Brief to VFS (Virtual File System)
- FUSE (File system in USEr space)
- Hello world file system programming tutorial
- Demo a simple fuse file system example
3Brief to VFS (Virtual File System) (1/3)
cp /mnt/ext2/data /mnt/FAT32/data
User AP
User space
Kernel space
FAT32
Kernel
mount as /mnt/FAT32
User AP should know about every IO functions of
each file systems to feed the need completing
every IO operations. A common interface for user
AP to call IO functions is necessary.
Ext2/3
mount as /mnt/ext2
4Brief to VFS (Virtual File System) (2/3)
cp /mnt/ext2/data /mnt/FAT32/data
User AP
User space
Kernel space
Kernel
VFS
Providing a common interface for every IO
functions.
5Brief to VFS (Virtual File System) (3/3)
- Issues developers shall address
- Hard work for kernel-programming (as drivers)
User AP
User space
Kernel space
Kernel
Kernel
VFS
VFS
Special-purpose File System
6FUSE (File system in USEr space) (1/4)
- The role FUSE plays
- Programming a file system in user-space
User AP
User-level program
User space
Kernel space
FAT32
Kernel
VFS
Ext2/3
FUSE
7FUSE (File system in USEr space) (2/4)
- How user-level file system works
cat /mnt/user_level_fs/data
4
User AP
User-level program
User space
Kernel space
FAT32
Kernel
VFS
1.Call open( ) read( )
2.Bypass the IO call to FUSE module
Ext2/3
3.Diver the IO call to upper level
5
4.User-level program open( ) read( ) are
invoked
FUSE
5.Return the result to user AP
mount as /mnt/user_level_fs
8FUSE (File system in USEr space) (3/4)
- FUSE-based file system FTPFS
- Scenario list the files on the remote FTP server
User command ls /mnt/ftpfs
FTPFSuser-levelprogram
User AP
User space
Kernel space
Kernel
Bypass to user-level program
VFS
9FUSE (File system in USEr space) (4/4)
- How to install FUSE package
- How to build and execute FUSE program
tar zxvf fuse-2.7.3.tar.gz cd fuse-2.7.3
./configure make make install
gcc fuse_example.c o fuse_example
-D_FILE_OFFSET_BITS64 lfuse ./fuse_example
/mnt/mount_point
10Hello world file system programming tutorial
(1/)
- Main function and function pointers
static struct fuse_operations hello_oper
.getattr hello_getattr, .readdir
hello_readdir, .open hello_open, .read
hello_read, int main(int argc, char
argv) return fuse_main(argc, argv,
hello_oper, NULL)
IO operations left for developers to implement
11Hello world file system programming tutorial
(2/)
cd /mnt/mount_point
ls
? getattr( ), access( ), and readdir( ) are
called.
hello
.
..
12Hello world file system programming tutorial
(3/)
static const char hello_path "/hello" static
const char hello_str "Hello World!\n" static
int hello_read(const char path, char buf,
size_t size, off_t offset, struct
fuse_file_info fi) size_t len (void)
fi if(strcmp(path, hello_path) ! 0) return
-ENOENT len strlen(hello_str) if (offset lt
len) if (offset size gt len) size len -
offset memcpy(buf, hello_str offset,
size) else size 0 return size
cd /mnt/mount_point
cat hello
? getattr( ), access( ), and read( ) are called.
Hello World!
13Demo a simple fuse file system example
14File system operations interface FUSE specified
Common operations
Low-level operations