s***@speakeasy.net
2006-07-19 19:22:50 UTC
Playing with fuse-python, I have tried to write a trivial, bogus filesystem.
class TestFS(fuse.Fuse):
def __init__(self, *args, **kw):
fuse.Fuse.__init__(self, *args, **kw)
self.time_on_init = int(time.time())
# Setup logging
handler = logging.handlers.RotatingFileHandler('/tmp/testfs.log',
"a", 5242880, 3)
handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)-10s %(message)s", "%x %X"))
self.log = logging.getLogger('testfs')
self.log.setLevel(logging.DEBUG)
self.log.addHandler(handler)
self.log.info("TestFS initialized. %s, %s" % (args, kw))
def getattr(self, path):
self.log.warn("gettatr %s" % path)
if path != "/": return -fuse.ENOENT
ctx = self.GetContext()
mode = stat.S_IFDIR | 0755
ino = 0
dev = 0
nlink = 2
uid = ctx["uid"]
gid = ctx["gid"]
size = 1024
atime = self.time_on_init
mtime = self.time_on_init
ctime = self.time_on_init
stbuf = (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)
return stbuf
def __getattr__(self, name):
self.log.warn(name)
return self.__getattribute__(self, name)
That's it. Nothing fancy. I get an EINVAL whenever I try to ls, stat or otherwise look at the mount point. I have added debug to both the lib and the module. Nowhere is fuse setting the EINVAL (that I can find).
My end goal is going to be a bogus in memory FS, so being able to hand create the stat result is important. Any words of wisdom will be appreciated.
Oh, right. Versions.
fuse-2.5.3
fuse-python-hg$ hg head
changeset: 52:e1f57b73714a
tag: tip
user: dzsekijo
date: Mon Jul 17 10:26:25 2006 +0000
summary: Resolve some Python 2.3 compatibility problems.
class TestFS(fuse.Fuse):
def __init__(self, *args, **kw):
fuse.Fuse.__init__(self, *args, **kw)
self.time_on_init = int(time.time())
# Setup logging
handler = logging.handlers.RotatingFileHandler('/tmp/testfs.log',
"a", 5242880, 3)
handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)-10s %(message)s", "%x %X"))
self.log = logging.getLogger('testfs')
self.log.setLevel(logging.DEBUG)
self.log.addHandler(handler)
self.log.info("TestFS initialized. %s, %s" % (args, kw))
def getattr(self, path):
self.log.warn("gettatr %s" % path)
if path != "/": return -fuse.ENOENT
ctx = self.GetContext()
mode = stat.S_IFDIR | 0755
ino = 0
dev = 0
nlink = 2
uid = ctx["uid"]
gid = ctx["gid"]
size = 1024
atime = self.time_on_init
mtime = self.time_on_init
ctime = self.time_on_init
stbuf = (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)
return stbuf
def __getattr__(self, name):
self.log.warn(name)
return self.__getattribute__(self, name)
That's it. Nothing fancy. I get an EINVAL whenever I try to ls, stat or otherwise look at the mount point. I have added debug to both the lib and the module. Nowhere is fuse setting the EINVAL (that I can find).
My end goal is going to be a bogus in memory FS, so being able to hand create the stat result is important. Any words of wisdom will be appreciated.
Oh, right. Versions.
fuse-2.5.3
fuse-python-hg$ hg head
changeset: 52:e1f57b73714a
tag: tip
user: dzsekijo
date: Mon Jul 17 10:26:25 2006 +0000
summary: Resolve some Python 2.3 compatibility problems.