#!/usr/local/bin/python from fuse import Fuse import stat, os from errno import * FILES = {'/a':"hello", '/b':"world", '/c':"python"} DEBUG = 1 class MyFS(Fuse): def __init__(self, *args, **kw): Fuse.__init__(self, *args, **kw) def getattr(self, path): if DEBUG: print 'called getattr:', path t = [0,]*10 if (path == '/'): t[0] = stat.S_IFDIR | 0755 t[3] = 2 return t elif path in FILES.keys(): t[0] = stat.S_IFREG | 0644 t[3] = 1; t[6] = len(FILES[path]) return t else: return -ENOENT def getdir(self, path): if DEBUG: print 'getdir called:', path t = map(os.path.basename, FILES.keys()) return map(lambda x: (x, 0), t) server = MyFS() server.main()