From: jepler@unpythonic.dhs.org To: Miklos Szeredi <Miklos.Szeredi@eth.ericsson.se> Subject: Python Userspace Filesystem (was Re: Introducing FUSE: Filesystem in USErspace) Date: Mon, 12 Nov 2001 22:45:56 -0600 Cc: linux-fsdevel@vger.kernel.org, python-announce@python.org I've written a Python interface to FUSE. This was a fun project, and relatively easy to do given the simple API that FUSE provides. Here's my README (I have copied Miklos Szeredi's explanation of what FUSE is) General Information =================== This is a Python[1] interface to FUSE[2]. FUSE (Filesystem in USErspace) is a simple interface for userspace programs to export a virtual filesystem to the linux kernel. FUSE also aims to provide a secure method for non privileged users to create and mount their own filesystem implementations. When run from the commandline, "fuse.py" simply reexports the root filesystem within the mount point as example/fusexmp does in the main FUSE distribution. It also offers a class, fuse.Fuse, which can be subclassed to create a filesystem. fuse.Xmp is the example filesystem implementation In your subclass of fuse, add attributes with the expected names ("getattr", "readlink", etc) and call signatures (refer to fuse.Xmp) then call main(). Make it runnable as a #! script, and mount with fusermount <mount point> <script name> for example fusermount /mnt/tmp /usr/src/fuse-0.9/python/fuse.py for some reason, fusermount <mount point> python <script name> does not seem to work. LIMITATIONS =========== This is minimally tested (in fact, I haven't written any files via fuse/python, just ls'd and cat'ted a bit) and there's no documentation, docstrings, or tests. The Python code should probably be refactored to provide a nice way to do try: return f(...) except OSError, detail: if hasattr(detail, "errno"): detail = detail.errno return -detail Python does not have opendir/readir/closedir, so Xmp.readdir is implemented to perform a stat call for each file. This limitation may not be important when implementing other filesystem types that don't directly map onto real filesystems. Python's lstat() does not return some fields which must be filled in (st_blksize, st_blocks, st_ino), and _fusemodule assumes that the return value from the lstat() method is identical to Python's lstat(). This limitation should be lifted, and some standard order chosen for these three values. For now, though, default (nonsensical) values are chosen, and stuff like "du" doesn't work. The Python Global Interpreter Lock is not handled, so using fuse.MULTITHREAD will not work. Modifying the PROLOGUE and EPILOGUE functions may take care of this. For now, just run without fuse.MULTITHREAD in flags. Author ====== I'm Jeff Epler <jepler@unpythonic.dhs.org>. I've been dabbling in Python for nearly 7 years now, and interested (despite the lack of a real practical use) in userspace filesystems ever since I couldn't get userfs to compile way back in '93 or so. FUSE is cool, but i'm still not sure what it's good for in practical terms. I don't know how high a level of interest I'll maintain in this project, so if you want to do something with it feel free to do so. Like FUSE, this software is distributed under the terms of the GNU General Public License, Version 2. Future versions, if any, will be available at [3]. [1] http://www.python.org [2] http://sourceforge.net/projects/avf/ [3] http://unpythonic.dhs.org/~jepler/fuse/ - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html