SlideShare une entreprise Scribd logo
1  sur  40
Building File Systems with  Xavid Pretzer SIPB IAP 2009
What is FUSE? ,[object Object]
What’s a File System? ,[object Object],[object Object],[object Object]
What is Userspace? ,[object Object],[object Object],[object Object]
FUSE ,[object Object],[object Object],[object Object],[object Object],[object Object]
Other Key Features ,[object Object],[object Object],[object Object],[object Object]
What do people do with FUSE? ,[object Object],[object Object],[object Object],[object Object],[object Object]
Using FUSE Filesystems ,[object Object],[object Object],[object Object],[object Object]
How FUSE Works ,[object Object],[object Object],[object Object],[object Object]
Writing FUSE Filesystems
 
Writing a FUSE Filesystem ,[object Object],[object Object],[object Object],[object Object],[object Object]
Defining FUSE Operations ,[object Object],[object Object],[object Object]
FUSE Operations ,[object Object],[object Object],[object Object],[object Object]
Directory Operations ,[object Object],[object Object],[object Object]
Basic File Operations ,[object Object],[object Object],[object Object]
Reading and Writing Files ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Metadata Operations ,[object Object],[object Object],[object Object]
Meta Operations ,[object Object],[object Object]
Other Operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Metadata Format ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
FUSE Context ,[object Object],[object Object],[object Object],[object Object],[object Object]
Errors in FUSE ,[object Object],[object Object],[object Object]
Useful Errors ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Examples
Example: hello.py ,[object Object],[object Object],[object Object],[object Object],[object Object]
readdir fuse.fuse_python_api = (0, 2) hello_path = '/hello' hello_str = 'Hello World!' class HelloFS(Fuse): def readdir(self, path, offset): for r in  '.', '..', hello_path[1:]: yield fuse.Direntry(r)
open hello_path = '/hello' hello_str = 'Hello World!' class HelloFS(Fuse): # ... def open(self, path, flags): if path != hello_path: return -errno.ENOENT accmode = os.O_RDONLY | os.O_WRONLY | os.O_RDWR if (flags & accmode) != os.O_RDONLY: return -errno.EACCES
read def read(self, path, size, offset): if path != hello_path: return -errno.ENOENT slen = len(hello_str) if offset < slen: if offset + size > slen: size = slen - offset buf = hello_str[offset:offset+size] else: buf = '' return buf
Helper Stat subclass class MyStat(fuse.Stat): def __init__(self): self.st_mode = 0 self.st_ino = 0 self.st_dev = 0 self.st_nlink = 0 self.st_uid = 0 self.st_gid = 0 self.st_size = 0 self.st_atime = 0 self.st_mtime = 0 self.st_ctime = 0
getattr def getattr(self, path): st = MyStat() if path == '/': st.st_mode = stat.S_IFDIR | 0755 st.st_nlink = 2 elif path == hello_path: st.st_mode = stat.S_IFREG | 0444 st.st_nlink = 1 st.st_size = len(hello_str) else: return -errno.ENOENT return st
Boilerplate Main def main(): usage=&quot;Userspace hello example&quot; + Fuse.fusage server = HelloFS(version=&quot;%prog &quot; + fuse.__version__, usage=usage, dash_s_do='setsingle') server.parse(errex=1) server.main() if __name__ == '__main__': main()
Example: xmp.py ,[object Object],[object Object],[object Object],[object Object],[object Object]
__init__ and fsinit fuse.fuse_python_api = (0, 2) # We use a custom file class and fsinit  feature_assert('stateful_files', 'has_init') class Xmp(Fuse): def __init__(self, *args, **kw): Fuse.__init__(self, *args, **kw) self.root = '/' self.file_class = self.XmpFile def fsinit(self): os.chdir(self.root)
Main with Options def main(): server = Xmp(version=&quot;%prog &quot; +  fuse.__version__, usage=Fuse.fusage) server.parser.add_option( mountopt=&quot;root&quot;, metavar=&quot;PATH&quot;,  default='/', help=&quot;mirror PATH [def: %default]&quot;) server.parse(values=server, errex=1) if server.fuse_args.mount_expected(): os.chdir(server.root) server.main()
Operations on Fuse Subclass def getattr(self, path): return os.lstat(&quot;.&quot; + path) def readdir(self, path, offset): for e in os.listdir(&quot;.&quot; + path): yield fuse.Direntry(e) def truncate(self, path, len): f = open(&quot;.&quot; + path, &quot;a&quot;) f.truncate(len) f.close() # ...
Operations on File class class XmpFile(object): # Called for ’open’ def __init__(self, path, flags, *mode): self.file = os.fdopen( os.open(&quot;.&quot; + path, flags, *mode), flag2mode(flags)) self.fd = self.file.fileno() def read(self, length, offset): self.file.seek(offset) return self.file.read(length) def write(self, buf, offset): self.file.seek(offset) self.file.write(buf) return len(buf) # ...
Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Try it Out ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
fuse_lowlevel.h ,[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Windows memory management
Windows memory managementWindows memory management
Windows memory management
Tech_MX
 

Tendances (20)

linux kernel overview 2013
linux kernel overview 2013linux kernel overview 2013
linux kernel overview 2013
 
Linux File System
Linux File SystemLinux File System
Linux File System
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
 
Linux MMAP & Ioremap introduction
Linux MMAP & Ioremap introductionLinux MMAP & Ioremap introduction
Linux MMAP & Ioremap introduction
 
Hypervisors
HypervisorsHypervisors
Hypervisors
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in Linux
 
Лекція №1
Лекція №1Лекція №1
Лекція №1
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
Swap Administration in linux platform
Swap Administration in linux platformSwap Administration in linux platform
Swap Administration in linux platform
 
Course 102: Lecture 5: File Handling Internals
Course 102: Lecture 5: File Handling Internals Course 102: Lecture 5: File Handling Internals
Course 102: Lecture 5: File Handling Internals
 
Linux Memory
Linux MemoryLinux Memory
Linux Memory
 
Xen & virtualization
Xen & virtualizationXen & virtualization
Xen & virtualization
 
Windows memory management
Windows memory managementWindows memory management
Windows memory management
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
Linux Kernel - Virtual File System
Linux Kernel - Virtual File SystemLinux Kernel - Virtual File System
Linux Kernel - Virtual File System
 
Linux device drivers
Linux device driversLinux device drivers
Linux device drivers
 
Le protocole HTTP
Le protocole HTTPLe protocole HTTP
Le protocole HTTP
 
OS Memory Management
OS Memory ManagementOS Memory Management
OS Memory Management
 
Files and directories in Linux 6
Files and directories  in Linux 6Files and directories  in Linux 6
Files and directories in Linux 6
 

Similaire à Building File Systems with FUSE

7 unixsecurity
7 unixsecurity7 unixsecurity
7 unixsecurity
richarddxd
 
1 CMPS 12M Data Structures Lab Lab Assignment 1 .docx
 1 CMPS 12M Data Structures Lab Lab Assignment 1  .docx 1 CMPS 12M Data Structures Lab Lab Assignment 1  .docx
1 CMPS 12M Data Structures Lab Lab Assignment 1 .docx
joyjonna282
 
1 CMPS 12M Data Structures Lab Lab Assignment 1 .docx
1 CMPS 12M Data Structures Lab Lab Assignment 1  .docx1 CMPS 12M Data Structures Lab Lab Assignment 1  .docx
1 CMPS 12M Data Structures Lab Lab Assignment 1 .docx
tarifarmarie
 

Similaire à Building File Systems with FUSE (20)

Linux filesystemhierarchy
Linux filesystemhierarchyLinux filesystemhierarchy
Linux filesystemhierarchy
 
Tutorial 2
Tutorial 2Tutorial 2
Tutorial 2
 
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
 
7 unixsecurity
7 unixsecurity7 unixsecurity
7 unixsecurity
 
Host security
Host securityHost security
Host security
 
Host security
Host securityHost security
Host security
 
Vfs
VfsVfs
Vfs
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
 
Fuse'ing python for rapid development of storage efficient
Fuse'ing python for rapid development of storage efficientFuse'ing python for rapid development of storage efficient
Fuse'ing python for rapid development of storage efficient
 
File system discovery
File system discovery File system discovery
File system discovery
 
NIO.2, the I/O API for the future
NIO.2, the I/O API for the futureNIO.2, the I/O API for the future
NIO.2, the I/O API for the future
 
Edubooktraining
EdubooktrainingEdubooktraining
Edubooktraining
 
Unix-module3.pptx
Unix-module3.pptxUnix-module3.pptx
Unix-module3.pptx
 
Writing file system in CPython
Writing file system in CPythonWriting file system in CPython
Writing file system in CPython
 
Filesystem Abstraction with Flysystem
Filesystem Abstraction with FlysystemFilesystem Abstraction with Flysystem
Filesystem Abstraction with Flysystem
 
1 CMPS 12M Data Structures Lab Lab Assignment 1 .docx
 1 CMPS 12M Data Structures Lab Lab Assignment 1  .docx 1 CMPS 12M Data Structures Lab Lab Assignment 1  .docx
1 CMPS 12M Data Structures Lab Lab Assignment 1 .docx
 
1 CMPS 12M Data Structures Lab Lab Assignment 1 .docx
1 CMPS 12M Data Structures Lab Lab Assignment 1  .docx1 CMPS 12M Data Structures Lab Lab Assignment 1  .docx
1 CMPS 12M Data Structures Lab Lab Assignment 1 .docx
 
File Context
File ContextFile Context
File Context
 
beginner.en.print
beginner.en.printbeginner.en.print
beginner.en.print
 
beginner.en.print
beginner.en.printbeginner.en.print
beginner.en.print
 

Plus de elliando dias

Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
elliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
elliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
elliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
elliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
elliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
elliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
elliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
elliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
elliando dias
 

Plus de elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

Building File Systems with FUSE

  • 1. Building File Systems with Xavid Pretzer SIPB IAP 2009
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 11.  
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 26.
  • 27. readdir fuse.fuse_python_api = (0, 2) hello_path = '/hello' hello_str = 'Hello World!' class HelloFS(Fuse): def readdir(self, path, offset): for r in '.', '..', hello_path[1:]: yield fuse.Direntry(r)
  • 28. open hello_path = '/hello' hello_str = 'Hello World!' class HelloFS(Fuse): # ... def open(self, path, flags): if path != hello_path: return -errno.ENOENT accmode = os.O_RDONLY | os.O_WRONLY | os.O_RDWR if (flags & accmode) != os.O_RDONLY: return -errno.EACCES
  • 29. read def read(self, path, size, offset): if path != hello_path: return -errno.ENOENT slen = len(hello_str) if offset < slen: if offset + size > slen: size = slen - offset buf = hello_str[offset:offset+size] else: buf = '' return buf
  • 30. Helper Stat subclass class MyStat(fuse.Stat): def __init__(self): self.st_mode = 0 self.st_ino = 0 self.st_dev = 0 self.st_nlink = 0 self.st_uid = 0 self.st_gid = 0 self.st_size = 0 self.st_atime = 0 self.st_mtime = 0 self.st_ctime = 0
  • 31. getattr def getattr(self, path): st = MyStat() if path == '/': st.st_mode = stat.S_IFDIR | 0755 st.st_nlink = 2 elif path == hello_path: st.st_mode = stat.S_IFREG | 0444 st.st_nlink = 1 st.st_size = len(hello_str) else: return -errno.ENOENT return st
  • 32. Boilerplate Main def main(): usage=&quot;Userspace hello example&quot; + Fuse.fusage server = HelloFS(version=&quot;%prog &quot; + fuse.__version__, usage=usage, dash_s_do='setsingle') server.parse(errex=1) server.main() if __name__ == '__main__': main()
  • 33.
  • 34. __init__ and fsinit fuse.fuse_python_api = (0, 2) # We use a custom file class and fsinit feature_assert('stateful_files', 'has_init') class Xmp(Fuse): def __init__(self, *args, **kw): Fuse.__init__(self, *args, **kw) self.root = '/' self.file_class = self.XmpFile def fsinit(self): os.chdir(self.root)
  • 35. Main with Options def main(): server = Xmp(version=&quot;%prog &quot; + fuse.__version__, usage=Fuse.fusage) server.parser.add_option( mountopt=&quot;root&quot;, metavar=&quot;PATH&quot;, default='/', help=&quot;mirror PATH [def: %default]&quot;) server.parse(values=server, errex=1) if server.fuse_args.mount_expected(): os.chdir(server.root) server.main()
  • 36. Operations on Fuse Subclass def getattr(self, path): return os.lstat(&quot;.&quot; + path) def readdir(self, path, offset): for e in os.listdir(&quot;.&quot; + path): yield fuse.Direntry(e) def truncate(self, path, len): f = open(&quot;.&quot; + path, &quot;a&quot;) f.truncate(len) f.close() # ...
  • 37. Operations on File class class XmpFile(object): # Called for ’open’ def __init__(self, path, flags, *mode): self.file = os.fdopen( os.open(&quot;.&quot; + path, flags, *mode), flag2mode(flags)) self.fd = self.file.fileno() def read(self, length, offset): self.file.seek(offset) return self.file.read(length) def write(self, buf, offset): self.file.seek(offset) self.file.write(buf) return len(buf) # ...
  • 38.
  • 39.
  • 40.