Flags in fuse python

S

Sreejith K

Hi,

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:
os.mkdir(snapdir)
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()
WRITE_METHOD = SNAP_WRITE
FRESH_SNAP = 0
snap_cnt += 1
tf.writelines("Fresh Snap created %s %s %s\n" %
(WRITE_METHOD,SNAP_WRITE,NORMAL_WRITE))
elif snap_cnt is 0:
tf.writelines("Initiating Normal File...\n")
self.file = os.fdopen(os.open("." + path, flags, *mode),flag2mode
(flags))
self.fd = self.file.fileno()
WRITE_METHOD = NORMAL_WRITE
else:
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()
WRITE_METHOD = SNAP_WRITE

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@sreejith fuse]# ./flusterbeta.py /fluster/
[root@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 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top