Flags in fuse python

Sreejith K sreejithemk at gmail.com
Mon Mar 16 07:54:48 CET 2009


I'm writing a file system under fuse-python. The main problem I'm
facing now is that the flags which are provided by the fuse module
when r/w are called, are screwing up the situation.

I wrote a file class for fuse as shown below.

class FlusterFile(object):
		def __init__(self, path, flags, *mode):
			global WRITE_METHOD
			global NORMAL_WRITE
			global SNAP_WRITE
			global FRESH_SNAP
			tf.writelines("File initiating..\n")
			curdir = GetDirPath('.' + path)
			snapdir = '.' + path + '_snaps'
			snap_cnt = 0
			if os.path.exists(snapdir):
				snap_cnt = len(os.listdir(snapdir))
			elif FRESH_SNAP == 1:
			if FRESH_SNAP == 1:
				tf.writelines("Creating Fresh Snap\n")
				tf.writelines("File flags: %s mode: %s\n" % (flags,mode))
				### FIXME ###
				self.file = os.fdopen(os.open(snapdir + "/snap%s" % repr(snap_cnt
+1), flags),flag2mode(flags))
				self.fd = self.file.fileno()
				FRESH_SNAP = 0
				snap_cnt += 1
				tf.writelines("Fresh Snap created %s %s %s\n" %
			elif snap_cnt is 0:
				tf.writelines("Initiating Normal File...\n")
				self.file = os.fdopen(os.open("." + path, flags, *mode),flag2mode
				self.fd = self.file.fileno()
				tf.writelines("Initiating latest Snap file..\n")
				self.file = os.fdopen(os.open(snapdir + "/snap%s" % repr
(snap_cnt), flags, *mode),flag2mode(flags))
				self.fd = self.file.fileno()

This init is called when we are accessing a file for r/w.

Suppose the filesystem source is named fluster.py. (the filesystem
mirrors files under /mnt/gfs_local to /fluster). When I set the
FRESH_SNAP variable to 1 the error occurs and no file gets created.

[root at sreejith fuse]# ./flusterbeta.py /fluster/
[root at sreejith fuse]# echo 'revenge' >> /fluster/fuse/fuse.txt
-bash: /fluster/fuse/fuse.txt: No such file or directory

Here I'm trying to pass the new data to a new snap file, which is to
be created (but fuse doesn't allow this)
Does this mean the fuse checks if the file is existing or not before
it generates the appropriate flags ?

More information about the Python-list mailing list