SlideShare a Scribd company logo
FUSE
Filesystem in User space



                  Chian yu Tseng
                  2012-6-11

                                   1
Outline
• Introduction
• The FUSE structure
• 如何運作
• Struct fuse_operations
• Example




                             2
Introduction(1/2)
• FUSE is a loadable kernel module for Unix-like computer
  operating systems that lets non-privileged users create
  their own file systems without editing kernel code.
• This is achieved by running file system code in user
  space while the FUSE module provides only a "bridge" to
  the actual kernel interfaces.

• FUSE is particularly useful for writing virtual file systems.
 Unlike traditional file systems that essentially save data to
 and retrieve data from disk, virtual filesystems do not
 actually store data themselves. They act as a view or
 translation of an existing file system or storage device.
                                                                  3
Introduction(2/2)
• The FUSE system was originally part of A Virtual
 Filesystem (AVFS), but has since split off into its own
 project on SourceForge.net.

• FUSE is available for Linux, FreeBSD, NetBSD,
 OpenSolaris, and Mac OS X. It was officially merged into
 the mainstream Linux kernel tree in kernel version 2.6.14.




                                                              4
Examples(1/2)
• ExpanDrive: A commercial filesystem implementing
 SFTP/FTP/FTPS using FUSE.

• GlusterFS: Clustered Distributed Filesystem having
 capability to scale up to several petabytes.

• SSHFS: Provides access to a remote filesystem
 through SSH.

• GmailFS: Filesystem which stores data as mail in Gmail


• EncFS: Encrypted virtual filesystem

                                                           5
Examples(2/2)
• NTFS-3G和Captive NTFS: allowing access
 to NTFS filesystem.

• WikipediaFS : View and edit Wikipedia articles as if they
 were real files.

• Sun Microsystems’s Lustre cluster filesystem


• Sun Microsystems’s ZFS


• HDFS: FUSE bindings exist for the open source Hadoop
 distributed filesystem.

                                                              6
FUSE Installation
 • http://fuse.sourceforge.net/


 • ./configure
 • make
 • make install




                                  7
FUSE source code
• ./doc: contains FUSE-related documentation. Ex: how-fuse-
 works

• ./include: contains the FUSE API headers, which you need
 to create a file system. The only one you need now is fuse.h.

• ./lib: holds the source code to create the FUSE libraries that
 you will be linking with your binaries to create a file system.

• ./util: has the source code for the FUSE utility library.


• ./example: contains samples for your reference.
                                                                   8
FUSE structure
• FUSE kernel module (fuse.ko)
  • inode.c, dev.c, control.c, dir.c, file.c



• LibFUSE module (libfuse.*)
   • helper.c, fuse_kern_chan.c, fuse_mt.c, fuse.c, fuse_lowlevel.c,
     fuse_loop.c, fuse_loop_mt.c, fuse_session.c


• Mount utility(fusermount)
  • fusermount, mount.fuse.c, mount_util.c, mount.c, mount_bsd.c,




                                                                       9
FUSE Library
• include/fuse.h  the library interface of FUSE(HighLevel)


• include/fuse_common.h  common


• include/fuse_lowlevel.h  Lowlevel API


• include/fuse_opt.h  option parsing interface of FUSE




                                                          10
如何運作
• 在 FUSE daemon 啟動的時候,會先進行掛載的動作,將
/dev/fuse 掛載到指定的目錄底下,並回傳/dev/fuse 的檔
案描述詞(file descriptor),而 FUSE daemon 在預設上會使
用 multi-thread 的方式,透過/dev/fuse 的檔案描述詞來接
收requests,再根據 requests 的類別來進行處理,最後透
過 replies,將結果傳回去。




                                             11
如何運作
• ls : FUSE daemon會接收到 OPENDIR、READDIR 等
requests,並採用 userspace library(libfuse.*)的函式,讀
取 file 目錄的資訊,並將此資訊傳回去,其中 FUSE
daemon 就是透過/dev/fuse 的檔案描述詞來與 kernel
module(fuse.ko)作溝通的動作。




                                                 12
User programs

          calls
 fuse_main()
 (lib/helper.c)

                         fuse_mount()
                          (lib/mount.c)
                                            fork      fusermount()
                                          fd,exit   (util/fusermount)
                  fd



           calls          fuse_new()
                           (lib/fuse.c)


                  data structure

                                                                        13
fuse_loop(),
            calls       fuse_loop_mt()
                            (lib/fuse.c,
                         lib/fuse_mt.c)




                         session_exit
                                              n



                                           Receive session

                    y



                                           Process session


Uninstall fuse fs
                                                             14
The fuse library(1/5)
• When your user mode program calls fuse_main()
 (lib/helper.c),fuse_main() parses the arguments passed to
 your user mode program, then calls fuse_mount()
 (lib/mount.c).



           fuse_main()         fuse_mount()
           (lib/helper.c)       (lib/mount.c)




                                                             15
The fuse library(2/5)
• fuse_mount() creates a UNIX domain socket pair, then
 forks and execsfusermount (util/fusermount.c) passing it
 one end of the socket in the FUSE_COMMFD_ENV
 environment variable.



fuse_main()       fuse_mount()                      fusermount()
(lib/helper.c)     (lib/mount.c)                 (util/fusermount.c)

                                   Create socketpair
                                   fork
                                   execfusermount         /dev/fuse


                                                                       16
The fuse library(3/5)
• fusermount (util/fusermount.c) makes sure that the fuse
  module is loaded. fusermount then open /dev/fuse and
  send the file handle over a UNIX domain socket back to
  fuse_mount().


fuse_main()      fuse_mount()               fusermount()
(lib/helper.c)    (lib/mount.c)          (util/fusermount.c)
                                                      Fuse module is loaded


                                  /dev/fuse   Open /dev/fuse
                                              Send filehandle



                                                                              17
The fuse library(4/5)
• fuse_mount() returns the file handle for /dev/fuse to
 fuse_main().

• fuse_main() calls fuse_new() (lib/fuse.c) which allocates
 the struct fuse data structure that stores and maintains a
 cached image of the filesystem data.

   fuse_main()                      fuse_mount()              fusermount()
   (lib/helper.c)                    (lib/mount.c)         (util/fusermount.c)
                    Return filehandle
    fuse_new()
     (lib/fuse.c)
                                                     /dev/fuse
                                                                                 18
The fuse library (5/5)
  • Lastly, fuse_main() calls either fuse_loop() (lib/fuse.c) or
    fuse_loop_mt() (lib/fuse_mt.c) which both start to read the file system
    system calls from the /dev/fuse, call the user mode functions stored in
    struct fuse_operations data structure before calling fuse_main().

  • The results of those calls are then written back to the /dev/fuse file
    where they can be forwarded back to the system calls.
   fuse_loop(),
fuse_loop_mt()         fuse_main()               fuse_mount()           fusermount()
    (lib/fuse.c,       (lib/helper.c)             (lib/mount.c)      (util/fusermount.c)
 lib/fuse_mt.c)                    Return filehandle

                       fuse_new()
write     read          (lib/fuse.c)
                                                              /dev/fuse

                                                                                       19
Struct fuse_operations (1/9)
• int (*getattr) (const char *, struct stat *);
   • Get file attributes.
• int (*readlink) (const char *, char *, size_t);
   • Read the target of a symbolic link
• int (*mknod) (const char *, mode_t, dev_t);
   • Create a file node.
• int (*mkdir) (const char *, mode_t);
   • Create a directory. Note that the mode argument may not have the
     type specification bits set, i.e. S_ISDIR(mode) can be false. To
     obtain the correct directory type bits use mode | S_IFDIR




                                                                        20
Struct fuse_operations (2/9)
• int (*unlink) (const char *);
   • Remove a file
• int (*rmdir) (const char *);
   • Remove a directory
• int (*symlink) (const char *, const char *);
   • Create a symbolic link
• int (*rename) (const char *, const char *);
   • Rename a file
• int (*link) (const char *, const char *);
   • Create a hard link to a file




                                                 21
Struct fuse_operations (3/9)
• int (*chmod) (const char *, mode_t);
   • Change the permission bits of a file
• int (*chown) (const char *, uid_t, gid_t);
   • Change the owner and group of a file
• int (*truncate) (const char *, off_t);
   • Change the size of a file
• int (*open) (const char *, struct fuse_file_info *);
   • File open operation.




                                                         22
Struct fuse_operations (4/9)
• int (*read) (const char *, char *, size_t, off_t, struct
 fuse_file_info *);
  • Read data from an open file.



• int (*write) (const char *, const char *, size_t, off_t, struct
 fuse_file_info *);
  • Write data to an open file



• int (*statfs) (const char *, struct statvfs *);
   • Get file system statistics
• int (*flush) (const char *, struct fuse_file_info *);
   • Possibly flush cached data
                                                                    23
Struct fuse_operations (5/9)
• int (*release) (const char *, struct fuse_file_info *);
   • Release an open file. Release is called when there are no more
     references to an open file: all file descriptors are closed and all
     memory mappings are unmapped.


• int (*fsync) (const char *, int, struct fuse_file_info *);
   • Synchronize file contents
• int (*setxattr) (const char *, const char *, const char *,
 size_t, int);
  • Set extended attributes
• int (*getxattr) (const char *, const char *, char *, size_t);
   • Get extended attributes

                                                                           24
Struct fuse_operations (6/9)
• int (*listxattr) (const char *, char *, size_t);
   • List extended attributes
• int (*removexattr) (const char *, const char *);
   • Remove extended attributes



• int (*opendir) (const char *, struct fuse_file_info *);
   • Open directory. Unless the 'default_permissions' mount option is
     given, this method should check if opendir is permitted for this
     directory. Optionally opendir may also return an arbitrary filehandle
     in the fuse_file_info structure, which will be passed to readdir,
     closedir and fsyncdir.



                                                                             25
Struct fuse_operations (7/9)
• int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t,
                       struct fuse_file_info *);
  • Read directory
• int (*releasedir) (const char *, struct fuse_file_info *);
   • Release directory
• int (*fsyncdir) (const char *, int, struct fuse_file_info *);
   • Synchronize directory contents



• void *(*init) (struct fuse_conn_info *conn);
   • Initialize file system.




                                                                  26
Struct fuse_operations (8/9)
• void (*destroy) (void *);
   • Clean up filesystem
• int (*access) (const char *, int);
   • Check file access permissions
• int (*create) (const char *, mode_t, struct fuse_file_info *);
   • Create and open a file. If the file does not exist, first create it with
     the specified mode, and then open it.
• int (*ftruncate) (const char *, off_t, struct fuse_file_info *);
   • Change the size of an open file
• int (*fgetattr) (const char *, struct stat *, struct
 fuse_file_info *);
  • Get attributes from an open file

                                                                                27
Struct fuse_operations(9/9)
• int (*lock) (const char *, struct fuse_file_info *, int cmd,
                   struct flock *);
  • Perform POSIX file locking operation
• int (*utimens) (const char *, const struct timespec tv[2]);
   • Change the access and modification times of a file with
     nanosecond resolution
• int (*bmap) (const char *, size_t blocksize, uint64_t *idx);
   • Map block index within file to block index within device




                                                                 28
Example1: Hello.c




                    29
hello-getattr()




                  A component of the path path does not exis




                                                               30
hello_readdir()




                  31
hello_open()
• This function checks whatever user is permitted to open
 the /hello file with flags given in
 the fuse_file_info structure.




                                                            32
hello_read()




               33
Example1: Hello.c 執行
• ./hello /tmp/fuse -d




                         34
Example2: fusexmp_fh.c




                         35
xmp_getattr(), xmp_fgetattr()




                                36
xmp_access(), xmp_readlink()




                               37
Struct xmp_dirp, xmp_opendir()




                                 38
xmp_readdir() (1/2)




                      39
xmp_readdir() (2/2)




                      40
xmp_releasedir(), xmp_mknod()




                                41
xmp_mkdir(), xmp_unlink()




                            42
xmp_rmdir(), xmp_symlink()




                             43
xmp_rename(), xmp_link()




                           44
xmp_chmod(), xmp_chown()




                           45
xmp_truncate(), xmp_ftruncate()




                                  46
xmp_utimens(), xmp_create()




                              47
xmp_open(), xmp_read()




                         48
xmp_read_buf()




                 49
xmp_write(), xmp_write_buf()




                               50
xmp_statfs(), xmp_flush()




                            51
xmp_release(), xmp_fsync()




                             52
xmp_setattr(), xmp_getattr()




                               53
xmp_listattr(), xmp_removexatttr()




                                     54
xmp_lock(), xmp_flock()




                          55
Example2: fusexmp_fh.c 執行




                            56
26
          The End


Thank you for your listening




                                57

More Related Content

What's hot

Git, CMake, Conan - How to ship and reuse our C++ projects?
Git, CMake, Conan - How to ship and reuse our C++ projects?Git, CMake, Conan - How to ship and reuse our C++ projects?
Git, CMake, Conan - How to ship and reuse our C++ projects?
Mateusz Pusz
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
sudhir singh yadav
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
Tushar B Kute
 
Introduction To Terraform
Introduction To TerraformIntroduction To Terraform
Introduction To Terraform
Sasitha Iresh
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
Corrado Santoro
 
Scaling WebRTC applications with Janus
Scaling WebRTC applications with JanusScaling WebRTC applications with Janus
Scaling WebRTC applications with Janus
Lorenzo Miniero
 
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Anne Nicolas
 
Tutorial: Using GoBGP as an IXP connecting router
Tutorial: Using GoBGP as an IXP connecting routerTutorial: Using GoBGP as an IXP connecting router
Tutorial: Using GoBGP as an IXP connecting router
Shu Sugimoto
 
Ansible
AnsibleAnsible
Course 102: Lecture 9: Input Output Internals
Course 102: Lecture 9: Input Output Internals Course 102: Lecture 9: Input Output Internals
Course 102: Lecture 9: Input Output Internals
Ahmed El-Arabawy
 
User management
User managementUser management
User management
Mufaddal Haidermota
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking Explained
Thomas Graf
 
Some basic unix commands
Some basic unix commandsSome basic unix commands
Some basic unix commandsaaj_sarkar06
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
vceder
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
kalyanineve
 
Terraform
TerraformTerraform

What's hot (20)

Git, CMake, Conan - How to ship and reuse our C++ projects?
Git, CMake, Conan - How to ship and reuse our C++ projects?Git, CMake, Conan - How to ship and reuse our C++ projects?
Git, CMake, Conan - How to ship and reuse our C++ projects?
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Linux crontab
Linux crontabLinux crontab
Linux crontab
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
Introduction To Terraform
Introduction To TerraformIntroduction To Terraform
Introduction To Terraform
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
 
RPM (LINUX)
RPM (LINUX)RPM (LINUX)
RPM (LINUX)
 
Scaling WebRTC applications with Janus
Scaling WebRTC applications with JanusScaling WebRTC applications with Janus
Scaling WebRTC applications with Janus
 
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
 
Tutorial: Using GoBGP as an IXP connecting router
Tutorial: Using GoBGP as an IXP connecting routerTutorial: Using GoBGP as an IXP connecting router
Tutorial: Using GoBGP as an IXP connecting router
 
Ansible
AnsibleAnsible
Ansible
 
Course 102: Lecture 9: Input Output Internals
Course 102: Lecture 9: Input Output Internals Course 102: Lecture 9: Input Output Internals
Course 102: Lecture 9: Input Output Internals
 
User management
User managementUser management
User management
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking Explained
 
Linux notes
Linux notesLinux notes
Linux notes
 
Some basic unix commands
Some basic unix commandsSome basic unix commands
Some basic unix commands
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Terraform
TerraformTerraform
Terraform
 

Viewers also liked

FUSE and beyond: bridging filesystems slides by Emmanuel Dreyfus
FUSE and beyond: bridging filesystems slides by Emmanuel DreyfusFUSE and beyond: bridging filesystems slides by Emmanuel Dreyfus
FUSE and beyond: bridging filesystems slides by Emmanuel Dreyfus
eurobsdcon
 
ABB Medium-High Voltage Products - ABB HV Fuses With Temperature Control, CEF...
ABB Medium-High Voltage Products - ABB HV Fuses With Temperature Control, CEF...ABB Medium-High Voltage Products - ABB HV Fuses With Temperature Control, CEF...
ABB Medium-High Voltage Products - ABB HV Fuses With Temperature Control, CEF...
Thorne & Derrick International
 
Fuse technology-2015
Fuse technology-2015Fuse technology-2015
Fuse technology-2015
Charles Moulliard
 
Implementing File Systems-R.D.Sivakumar
Implementing File Systems-R.D.SivakumarImplementing File Systems-R.D.Sivakumar
Implementing File Systems-R.D.Sivakumar
Sivakumar R D .
 
Fuses
FusesFuses
Fuses
Noman Nomi
 
ppt on fuse by madhav chhabra
ppt on fuse by madhav chhabrappt on fuse by madhav chhabra
ppt on fuse by madhav chhabraMadhav Chhabra
 
FUSE (Filesystem in Userspace) on OpenSolaris
FUSE (Filesystem in Userspace) on OpenSolarisFUSE (Filesystem in Userspace) on OpenSolaris
FUSE (Filesystem in Userspace) on OpenSolariselliando dias
 
KubeFuse - A File-System for Kubernetes
KubeFuse - A File-System for KubernetesKubeFuse - A File-System for Kubernetes
KubeFuse - A File-System for Kubernetes
Bart Spaans
 
O Racle Asm Best Practices Presentation
O Racle Asm Best Practices PresentationO Racle Asm Best Practices Presentation
O Racle Asm Best Practices Presentationeraz
 
Copper electrical fuse contacts parts
Copper electrical fuse contacts partsCopper electrical fuse contacts parts
Copper electrical fuse contacts parts
conexcoppe
 
ResistorS
ResistorSResistorS
ResistorS
Mohammad Yousif
 
ASM
ASMASM
Fuses and its type in power system
Fuses and its type in power systemFuses and its type in power system
Fuses and its type in power system
18061994
 
Simple model of Fuse(LTspice)
Simple model of Fuse(LTspice) Simple model of Fuse(LTspice)
Simple model of Fuse(LTspice)
Tsuyoshi Horigome
 
Fuse- Power system Protection
Fuse- Power system Protection  Fuse- Power system Protection
Fuse- Power system Protection
Md. Nahid Sarker
 
Resistor and conductor
Resistor and conductor Resistor and conductor
Resistor and conductor
Hamza Sajjad
 
Scale out backups-with_bareos_and_gluster
Scale out backups-with_bareos_and_glusterScale out backups-with_bareos_and_gluster
Scale out backups-with_bareos_and_gluster
Gluster.org
 
resistor
resistorresistor
resistor
JANE MALOLES
 
Resistors: Types and Uses
Resistors: Types and UsesResistors: Types and Uses
Resistors: Types and Uses
Jessa Arnado
 

Viewers also liked (20)

FUSE and beyond: bridging filesystems slides by Emmanuel Dreyfus
FUSE and beyond: bridging filesystems slides by Emmanuel DreyfusFUSE and beyond: bridging filesystems slides by Emmanuel Dreyfus
FUSE and beyond: bridging filesystems slides by Emmanuel Dreyfus
 
ABB Medium-High Voltage Products - ABB HV Fuses With Temperature Control, CEF...
ABB Medium-High Voltage Products - ABB HV Fuses With Temperature Control, CEF...ABB Medium-High Voltage Products - ABB HV Fuses With Temperature Control, CEF...
ABB Medium-High Voltage Products - ABB HV Fuses With Temperature Control, CEF...
 
Fuse technology-2015
Fuse technology-2015Fuse technology-2015
Fuse technology-2015
 
Implementing File Systems-R.D.Sivakumar
Implementing File Systems-R.D.SivakumarImplementing File Systems-R.D.Sivakumar
Implementing File Systems-R.D.Sivakumar
 
Fuses
FusesFuses
Fuses
 
ppt on fuse by madhav chhabra
ppt on fuse by madhav chhabrappt on fuse by madhav chhabra
ppt on fuse by madhav chhabra
 
150844230001(2)
150844230001(2)150844230001(2)
150844230001(2)
 
FUSE (Filesystem in Userspace) on OpenSolaris
FUSE (Filesystem in Userspace) on OpenSolarisFUSE (Filesystem in Userspace) on OpenSolaris
FUSE (Filesystem in Userspace) on OpenSolaris
 
KubeFuse - A File-System for Kubernetes
KubeFuse - A File-System for KubernetesKubeFuse - A File-System for Kubernetes
KubeFuse - A File-System for Kubernetes
 
O Racle Asm Best Practices Presentation
O Racle Asm Best Practices PresentationO Racle Asm Best Practices Presentation
O Racle Asm Best Practices Presentation
 
Copper electrical fuse contacts parts
Copper electrical fuse contacts partsCopper electrical fuse contacts parts
Copper electrical fuse contacts parts
 
ResistorS
ResistorSResistorS
ResistorS
 
ASM
ASMASM
ASM
 
Fuses and its type in power system
Fuses and its type in power systemFuses and its type in power system
Fuses and its type in power system
 
Simple model of Fuse(LTspice)
Simple model of Fuse(LTspice) Simple model of Fuse(LTspice)
Simple model of Fuse(LTspice)
 
Fuse- Power system Protection
Fuse- Power system Protection  Fuse- Power system Protection
Fuse- Power system Protection
 
Resistor and conductor
Resistor and conductor Resistor and conductor
Resistor and conductor
 
Scale out backups-with_bareos_and_gluster
Scale out backups-with_bareos_and_glusterScale out backups-with_bareos_and_gluster
Scale out backups-with_bareos_and_gluster
 
resistor
resistorresistor
resistor
 
Resistors: Types and Uses
Resistors: Types and UsesResistors: Types and Uses
Resistors: Types and Uses
 

Similar to Fuse- Filesystem in User space

All'ombra del Leviatano: Filesystem in Userspace
All'ombra del Leviatano: Filesystem in UserspaceAll'ombra del Leviatano: Filesystem in Userspace
All'ombra del Leviatano: Filesystem in Userspace
Roberto Reale
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
Divye Kapoor
 
An Introduction to User Space Filesystem Development
An Introduction to User Space Filesystem DevelopmentAn Introduction to User Space Filesystem Development
An Introduction to User Space Filesystem Development
Matt Turner
 
Linux IO
Linux IOLinux IO
Linux IO
Liran Ben Haim
 
Glusterfs session #18 intro to fuse and its trade offs
Glusterfs session #18 intro to fuse and its trade offsGlusterfs session #18 intro to fuse and its trade offs
Glusterfs session #18 intro to fuse and its trade offs
Pranith Karampuri
 
Best Practices For Direct Admin Security
Best Practices For Direct Admin SecurityBest Practices For Direct Admin Security
Best Practices For Direct Admin Security
lisa Dsouza
 
Autotools
AutotoolsAutotools
Autotools
Thierry Gayet
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in Linux
Tushar B Kute
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
Hao-Ran Liu
 
Linux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungLinux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungdns -
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
Alexandre Moreno
 
Fun with FUSE
Fun with FUSEFun with FUSE
Fun with FUSE
Kernel TLV
 
Linux security
Linux securityLinux security
Linux security
trilokchandra prakash
 
Forensic artifacts in modern linux systems
Forensic artifacts in modern linux systemsForensic artifacts in modern linux systems
Forensic artifacts in modern linux systems
Gol D Roger
 
SELinux Kernel Internals and Architecture - FOSS.IN/2005
SELinux Kernel Internals and Architecture - FOSS.IN/2005SELinux Kernel Internals and Architecture - FOSS.IN/2005
SELinux Kernel Internals and Architecture - FOSS.IN/2005
James Morris
 
Lecture 5 Kernel Development
Lecture 5 Kernel DevelopmentLecture 5 Kernel Development
Lecture 5 Kernel Development
Mohammed Farrag
 

Similar to Fuse- Filesystem in User space (20)

Linux
LinuxLinux
Linux
 
All'ombra del Leviatano: Filesystem in Userspace
All'ombra del Leviatano: Filesystem in UserspaceAll'ombra del Leviatano: Filesystem in Userspace
All'ombra del Leviatano: Filesystem in Userspace
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
 
Linux filesystemhierarchy
Linux filesystemhierarchyLinux filesystemhierarchy
Linux filesystemhierarchy
 
An Introduction to User Space Filesystem Development
An Introduction to User Space Filesystem DevelopmentAn Introduction to User Space Filesystem Development
An Introduction to User Space Filesystem Development
 
Linux IO
Linux IOLinux IO
Linux IO
 
Glusterfs session #18 intro to fuse and its trade offs
Glusterfs session #18 intro to fuse and its trade offsGlusterfs session #18 intro to fuse and its trade offs
Glusterfs session #18 intro to fuse and its trade offs
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Best Practices For Direct Admin Security
Best Practices For Direct Admin SecurityBest Practices For Direct Admin Security
Best Practices For Direct Admin Security
 
1 04 rao
1 04 rao1 04 rao
1 04 rao
 
Autotools
AutotoolsAutotools
Autotools
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in Linux
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
 
Linux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungLinux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesung
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
 
Fun with FUSE
Fun with FUSEFun with FUSE
Fun with FUSE
 
Linux security
Linux securityLinux security
Linux security
 
Forensic artifacts in modern linux systems
Forensic artifacts in modern linux systemsForensic artifacts in modern linux systems
Forensic artifacts in modern linux systems
 
SELinux Kernel Internals and Architecture - FOSS.IN/2005
SELinux Kernel Internals and Architecture - FOSS.IN/2005SELinux Kernel Internals and Architecture - FOSS.IN/2005
SELinux Kernel Internals and Architecture - FOSS.IN/2005
 
Lecture 5 Kernel Development
Lecture 5 Kernel DevelopmentLecture 5 Kernel Development
Lecture 5 Kernel Development
 

Recently uploaded

GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 

Recently uploaded (20)

GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 

Fuse- Filesystem in User space

  • 1. FUSE Filesystem in User space Chian yu Tseng 2012-6-11 1
  • 2. Outline • Introduction • The FUSE structure • 如何運作 • Struct fuse_operations • Example 2
  • 3. Introduction(1/2) • FUSE is a loadable kernel module for Unix-like computer operating systems that lets non-privileged users create their own file systems without editing kernel code. • This is achieved by running file system code in user space while the FUSE module provides only a "bridge" to the actual kernel interfaces. • FUSE is particularly useful for writing virtual file systems. Unlike traditional file systems that essentially save data to and retrieve data from disk, virtual filesystems do not actually store data themselves. They act as a view or translation of an existing file system or storage device. 3
  • 4. Introduction(2/2) • The FUSE system was originally part of A Virtual Filesystem (AVFS), but has since split off into its own project on SourceForge.net. • FUSE is available for Linux, FreeBSD, NetBSD, OpenSolaris, and Mac OS X. It was officially merged into the mainstream Linux kernel tree in kernel version 2.6.14. 4
  • 5. Examples(1/2) • ExpanDrive: A commercial filesystem implementing SFTP/FTP/FTPS using FUSE. • GlusterFS: Clustered Distributed Filesystem having capability to scale up to several petabytes. • SSHFS: Provides access to a remote filesystem through SSH. • GmailFS: Filesystem which stores data as mail in Gmail • EncFS: Encrypted virtual filesystem 5
  • 6. Examples(2/2) • NTFS-3G和Captive NTFS: allowing access to NTFS filesystem. • WikipediaFS : View and edit Wikipedia articles as if they were real files. • Sun Microsystems’s Lustre cluster filesystem • Sun Microsystems’s ZFS • HDFS: FUSE bindings exist for the open source Hadoop distributed filesystem. 6
  • 7. FUSE Installation • http://fuse.sourceforge.net/ • ./configure • make • make install 7
  • 8. FUSE source code • ./doc: contains FUSE-related documentation. Ex: how-fuse- works • ./include: contains the FUSE API headers, which you need to create a file system. The only one you need now is fuse.h. • ./lib: holds the source code to create the FUSE libraries that you will be linking with your binaries to create a file system. • ./util: has the source code for the FUSE utility library. • ./example: contains samples for your reference. 8
  • 9. FUSE structure • FUSE kernel module (fuse.ko) • inode.c, dev.c, control.c, dir.c, file.c • LibFUSE module (libfuse.*) • helper.c, fuse_kern_chan.c, fuse_mt.c, fuse.c, fuse_lowlevel.c, fuse_loop.c, fuse_loop_mt.c, fuse_session.c • Mount utility(fusermount) • fusermount, mount.fuse.c, mount_util.c, mount.c, mount_bsd.c, 9
  • 10. FUSE Library • include/fuse.h  the library interface of FUSE(HighLevel) • include/fuse_common.h  common • include/fuse_lowlevel.h  Lowlevel API • include/fuse_opt.h  option parsing interface of FUSE 10
  • 11. 如何運作 • 在 FUSE daemon 啟動的時候,會先進行掛載的動作,將 /dev/fuse 掛載到指定的目錄底下,並回傳/dev/fuse 的檔 案描述詞(file descriptor),而 FUSE daemon 在預設上會使 用 multi-thread 的方式,透過/dev/fuse 的檔案描述詞來接 收requests,再根據 requests 的類別來進行處理,最後透 過 replies,將結果傳回去。 11
  • 12. 如何運作 • ls : FUSE daemon會接收到 OPENDIR、READDIR 等 requests,並採用 userspace library(libfuse.*)的函式,讀 取 file 目錄的資訊,並將此資訊傳回去,其中 FUSE daemon 就是透過/dev/fuse 的檔案描述詞來與 kernel module(fuse.ko)作溝通的動作。 12
  • 13. User programs calls fuse_main() (lib/helper.c) fuse_mount() (lib/mount.c) fork fusermount() fd,exit (util/fusermount) fd calls fuse_new() (lib/fuse.c) data structure 13
  • 14. fuse_loop(), calls fuse_loop_mt() (lib/fuse.c, lib/fuse_mt.c) session_exit n Receive session y Process session Uninstall fuse fs 14
  • 15. The fuse library(1/5) • When your user mode program calls fuse_main() (lib/helper.c),fuse_main() parses the arguments passed to your user mode program, then calls fuse_mount() (lib/mount.c). fuse_main() fuse_mount() (lib/helper.c) (lib/mount.c) 15
  • 16. The fuse library(2/5) • fuse_mount() creates a UNIX domain socket pair, then forks and execsfusermount (util/fusermount.c) passing it one end of the socket in the FUSE_COMMFD_ENV environment variable. fuse_main() fuse_mount() fusermount() (lib/helper.c) (lib/mount.c) (util/fusermount.c) Create socketpair fork execfusermount /dev/fuse 16
  • 17. The fuse library(3/5) • fusermount (util/fusermount.c) makes sure that the fuse module is loaded. fusermount then open /dev/fuse and send the file handle over a UNIX domain socket back to fuse_mount(). fuse_main() fuse_mount() fusermount() (lib/helper.c) (lib/mount.c) (util/fusermount.c) Fuse module is loaded /dev/fuse Open /dev/fuse Send filehandle 17
  • 18. The fuse library(4/5) • fuse_mount() returns the file handle for /dev/fuse to fuse_main(). • fuse_main() calls fuse_new() (lib/fuse.c) which allocates the struct fuse data structure that stores and maintains a cached image of the filesystem data. fuse_main() fuse_mount() fusermount() (lib/helper.c) (lib/mount.c) (util/fusermount.c) Return filehandle fuse_new() (lib/fuse.c) /dev/fuse 18
  • 19. The fuse library (5/5) • Lastly, fuse_main() calls either fuse_loop() (lib/fuse.c) or fuse_loop_mt() (lib/fuse_mt.c) which both start to read the file system system calls from the /dev/fuse, call the user mode functions stored in struct fuse_operations data structure before calling fuse_main(). • The results of those calls are then written back to the /dev/fuse file where they can be forwarded back to the system calls. fuse_loop(), fuse_loop_mt() fuse_main() fuse_mount() fusermount() (lib/fuse.c, (lib/helper.c) (lib/mount.c) (util/fusermount.c) lib/fuse_mt.c) Return filehandle fuse_new() write read (lib/fuse.c) /dev/fuse 19
  • 20. Struct fuse_operations (1/9) • int (*getattr) (const char *, struct stat *); • Get file attributes. • int (*readlink) (const char *, char *, size_t); • Read the target of a symbolic link • int (*mknod) (const char *, mode_t, dev_t); • Create a file node. • int (*mkdir) (const char *, mode_t); • Create a directory. Note that the mode argument may not have the type specification bits set, i.e. S_ISDIR(mode) can be false. To obtain the correct directory type bits use mode | S_IFDIR 20
  • 21. Struct fuse_operations (2/9) • int (*unlink) (const char *); • Remove a file • int (*rmdir) (const char *); • Remove a directory • int (*symlink) (const char *, const char *); • Create a symbolic link • int (*rename) (const char *, const char *); • Rename a file • int (*link) (const char *, const char *); • Create a hard link to a file 21
  • 22. Struct fuse_operations (3/9) • int (*chmod) (const char *, mode_t); • Change the permission bits of a file • int (*chown) (const char *, uid_t, gid_t); • Change the owner and group of a file • int (*truncate) (const char *, off_t); • Change the size of a file • int (*open) (const char *, struct fuse_file_info *); • File open operation. 22
  • 23. Struct fuse_operations (4/9) • int (*read) (const char *, char *, size_t, off_t, struct fuse_file_info *); • Read data from an open file. • int (*write) (const char *, const char *, size_t, off_t, struct fuse_file_info *); • Write data to an open file • int (*statfs) (const char *, struct statvfs *); • Get file system statistics • int (*flush) (const char *, struct fuse_file_info *); • Possibly flush cached data 23
  • 24. Struct fuse_operations (5/9) • int (*release) (const char *, struct fuse_file_info *); • Release an open file. Release is called when there are no more references to an open file: all file descriptors are closed and all memory mappings are unmapped. • int (*fsync) (const char *, int, struct fuse_file_info *); • Synchronize file contents • int (*setxattr) (const char *, const char *, const char *, size_t, int); • Set extended attributes • int (*getxattr) (const char *, const char *, char *, size_t); • Get extended attributes 24
  • 25. Struct fuse_operations (6/9) • int (*listxattr) (const char *, char *, size_t); • List extended attributes • int (*removexattr) (const char *, const char *); • Remove extended attributes • int (*opendir) (const char *, struct fuse_file_info *); • Open directory. Unless the 'default_permissions' mount option is given, this method should check if opendir is permitted for this directory. Optionally opendir may also return an arbitrary filehandle in the fuse_file_info structure, which will be passed to readdir, closedir and fsyncdir. 25
  • 26. Struct fuse_operations (7/9) • int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *); • Read directory • int (*releasedir) (const char *, struct fuse_file_info *); • Release directory • int (*fsyncdir) (const char *, int, struct fuse_file_info *); • Synchronize directory contents • void *(*init) (struct fuse_conn_info *conn); • Initialize file system. 26
  • 27. Struct fuse_operations (8/9) • void (*destroy) (void *); • Clean up filesystem • int (*access) (const char *, int); • Check file access permissions • int (*create) (const char *, mode_t, struct fuse_file_info *); • Create and open a file. If the file does not exist, first create it with the specified mode, and then open it. • int (*ftruncate) (const char *, off_t, struct fuse_file_info *); • Change the size of an open file • int (*fgetattr) (const char *, struct stat *, struct fuse_file_info *); • Get attributes from an open file 27
  • 28. Struct fuse_operations(9/9) • int (*lock) (const char *, struct fuse_file_info *, int cmd, struct flock *); • Perform POSIX file locking operation • int (*utimens) (const char *, const struct timespec tv[2]); • Change the access and modification times of a file with nanosecond resolution • int (*bmap) (const char *, size_t blocksize, uint64_t *idx); • Map block index within file to block index within device 28
  • 30. hello-getattr() A component of the path path does not exis 30
  • 32. hello_open() • This function checks whatever user is permitted to open the /hello file with flags given in the fuse_file_info structure. 32
  • 34. Example1: Hello.c 執行 • ./hello /tmp/fuse -d 34
  • 57. 26 The End Thank you for your listening 57