diff options
Diffstat (limited to 'util/mount.fuse')
-rw-r--r-- | util/mount.fuse | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/util/mount.fuse b/util/mount.fuse new file mode 100644 index 0000000..4ec1409 --- /dev/null +++ b/util/mount.fuse @@ -0,0 +1,85 @@ +#!/usr/bin/env python +#@+leo-ver=4 +#@+node:@file mount.fuse +#@@first #!/usr/bin/env python + +""" +This utility allows FUSE filesystems to be mounted with the regular *nix +'mount' command, or even be listed in /etc/fstab + +To enable this, you need to: + 1. set execute-permission on this script + 2. symlink this script into /sbin/mount.fuse + +Usage: + + You can use this in 3 ways: + 1. mount -t fuse /path/to/script/or/program /path/of/mount/point [options] + 2. mount -t fuse none /path/of/mount/point -o fs=/path/to/script/or/prog[,opt=val...] + 3. in /etc/fstab, add: + /path/to/script/or/prog /path/of/mount/point fuse noauto[,...] +""" + +import sys, os, time + +progname = sys.argv[0] + +def usage(ret): + print "Usage: %s /path/to/fuse/fs /path/of/mountpoint [-o options]" % progname + print "or: %s none /path/of/mountpoint [-o fs=/path/to/fuse/fs[,...]]" % progname + sys.exit(ret) + +def main(): + + # initial sanity check + argc = len(sys.argv) + if argc < 3 or sys.argv[3] != "-o": + usage(1) + + dev = sys.argv[1] + mountpoint = sys.argv[2] + + # grab options, if any + optdict = {} + optlist = [] + if argc > 4: + odata = sys.argv[4] + opts = odata.split(",") + #print opts + for o in opts: + try: + k, v = o.split("=", 1) + optdict[k] = v + except: + optlist.append(o) + else: + odata = "" + + #print sys.argv + if dev == 'none': + if not optdict.has_key("fs"): + print "%s: Must specify python file with 'fs' option\n" % progname + usage(1) + pyfile = optdict['fs'] + else: + pyfile = dev + + if not os.path.isfile(pyfile): + print "%s: file %s doesn't exist, or is not a file" % (progname, pyfile) + sys.exit(1) + pypath = os.path.abspath(pyfile) + + #print optdict, optlist + + # all seems ok - run our fuse fs as a child + if os.fork() == 0: + os.system("fusermount -c -x %s %s %s %s" % (mountpoint, pypath, mountpoint, odata)) + else: + #print "parent exiting..." + pass + +if __name__ == '__main__': + main() + +#@-node:@file mount.fuse +#@-leo |