Discussion:
[fuse-devel] invalid argument on stat call
s***@speakeasy.net
2006-07-19 19:22:50 UTC
Permalink
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.
Csaba Henk
2006-07-20 08:17:31 UTC
Permalink
Post by s***@speakeasy.net
Playing with fuse-python, I have tried to write a trivial, bogus filesystem.
[...]
[...]
Post by s***@speakeasy.net
stbuf = (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The new fuse-python API doesn't accept tuples as the return value for
getattr(). Please consult with

http://fuse4bsd.creo.hu/README.new_fusepy_api.html#simple-objects-to-represent-system-structures

to get informed about the respective changes, or

http://fuse4bsd.creo.hu/README.new_fusepy_api.html#enforcing-compatibility

if you want to stick with the old API (not recommended).

Regards,
Csaba
Sean Perry
2006-07-21 02:22:31 UTC
Permalink
Post by Csaba Henk
Post by s***@speakeasy.net
Playing with fuse-python, I have tried to write a trivial, bogus filesystem.
[...]
[...]
Post by s***@speakeasy.net
stbuf = (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The new fuse-python API doesn't accept tuples as the return value for
getattr(). Please consult with
http://fuse4bsd.creo.hu/README.new_fusepy_api.html#simple-objects-to-represent-system-structures
to get informed about the respective changes, or
http://fuse4bsd.creo.hu/README.new_fusepy_api.html#enforcing-compatibility
if you want to stick with the old API (not recommended).
Thanks. Some how I missed that in the code. Would be nice if the Python
api could do a "if type(stat) == type(tuple): complain()".
Csaba Henk
2006-07-25 07:23:04 UTC
Permalink
Post by Sean Perry
Thanks. Some how I missed that in the code. Would be nice if the Python
api could do a "if type(stat) == type(tuple): complain()".
I'm actually fond of the idea of making people learn how to RTFM in the
hard way :)

(OK, OK, I know it's a bad joke but I couldn't resist...)

Regards,
Csaba

Continue reading on narkive:
Loading...