Building File Systems with.ppt
《Building File Systems with.ppt》由会员分享,可在线阅读,更多相关《Building File Systems with.ppt(40页珍藏版)》请在麦多课文档分享上搜索。
1、Building File Systems with,Xavid Pretzer SIPB IAP 2009,What is FUSE?,Stands for “File system in USErspace”,Whats a File System?,A file system maps file paths (e.g., /etc/hostname) to file contents and metadata Metadata includes modification times, permissions, etc. File systems are mounted over a pa
2、rticular directory,What is Userspace?,Your operating system has (at least) two modes: kernel (trusted) and user Kernelspace code has real ultimate power and can only be modified by root Base system software like filesystems are traditionally kernel modules and not changeable by normal users,FUSE,Mak
3、es it easy to write new filesystems without knowing how the kernel works without breaking unrelated things more quickly/easily than traditional file systems built as a kernel module Makes it safe for sysadmins to let users they dont trust use custom file systems,Other Key Features,Cross-platform: Li
4、nux/BSD/OS X Wide language support: natively in C, with bindings in C+, Java, C#, Haskell, TCL, Python, Perl, Shell Script, SWIG, OCaml, Pliant, Ruby, Lua, Erlang, PHP (My examples use Python) Low-level interface for more efficient file systems,What do people do with FUSE?,Hardware-based: ext2, iso,
5、 ZFS Network-based: NFS, smb, SSH Nontradtional: Gmail, MySQL Loopback: compression, conversion, encryption, virus scanning, versioning Synthetic: search results, application interaction, dynamic conf files,Using FUSE Filesystems,To mount: ./hello.py /somedir To unmount: fusermount -u /somedir,How F
6、USE Works,Application makes a file-related syscall Kernel figures out that the file is in a mounted FUSE filesystem The FUSE kernel module forwards the request to your userspace FUSE app Your app tells FUSE how to reply,Writing FUSE Filesystems,Writing a FUSE Filesystem,Write an ordinary application
7、 that defines certain functions/methods that FUSE will call to handle operations 35 possible operations Many operations have useful defaults Useful filesystems can define only 4 Full-featured ones will need to define most,Defining FUSE Operations,In C, you define functions and put pointers to them o
8、n a struct In python-fuse, operations are methods on a subclass of fuse.Fuse You can set your Fuse subclasss file_class attribute to a class that implements the file operations, or implement them on your Fuse subclass,FUSE Operations,Directory Operations File Operations Metadata Operations Some othe
9、r stuff,Directory Operations,readdir(path): yield directory entries for each file in the directory mkdir(path, mode): create a directory rmdir(path): delete an empty directory,Basic File Operations,mknod(path, mode, dev): create a file (or device) unlink(path): delete a file rename(old, new): move a
10、nd/or rename a file,Reading and Writing Files,open(path, flags): open a file read(path, length, offset, fh) write(path, buf, offset, fh) truncate(path, len, fh): cut off at length flush(path, fh): one handle is closed release(path, fh): file handle is completely closed (no errors),Metadata Operation
11、s,getattr(path): read metadata chmod(path, mode): alter permissions chown(path, uid, gid): alter ownership,Meta Operations,fsinit(self): initialize filesystem state after being mounted start threads, for example,Other Operations,statfs(path) fsdestroy() create(path, flags, mode) utimens(path, times)
12、 readlink(path) symlink(target, name) link(target, name) fsync(path, fdatasync, fh) ,Metadata Format,self.st_size: size in bytes st_mode: type and permissions self.st_uid: owner id self.st_gid: group id self.st_atime: access time (often fudged) self.st_mtime: modification time self.st_ctime: metadat
13、a change time self.st_ino: doesnt matter too much self.st_dev: 0 for normal files/directories self.st_nlink: 2 for dirs, 1 for files (generally),FUSE Context,GetContext() within a Fuse object returns a dict with: uid: accessing users user ID gid: accessing users group ID pid: accessing processs ID U
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- BUILDINGFILESYSTEMSWITHPPT
