def write(self, path, data, offset): print "In write path=%s" % path length = len(data) print "The data is %s len=%d offset=%d" % (str(data), length, offset) sefs = seFS() ret = sefs.write(path, data) return length
def create(self, path, flags=None, mode=None): print "trying to create %s", path print path print flags sefs = seFS() ret = self.open(path, flags) print ret if ret == -errno.ENOENT: # Create the file in database ret = sefs.open(path) print ret print "Creating the file %s" % path t = int(time.time()) mytime = (t, t, t) ret = sefs.utime(path, mytime) print ret self.fd = len(sefs.ls()) print "In create:fd = %d" % (self.fd) sefs.setinode(path, self.fd) print sefs.ls() else: print "The file %s exists!!" % path return 0
def write(self, path, data, offset): print "In write path=%s" %path length = len(data) print "The data is %s len=%d offset=%d" %(str(data), length, offset) sefs = seFS() ret = sefs.write(path, data) return length
def create(self, path, flags=None, mode=None): print "trying to create %s", path print path print flags sefs = seFS() ret = self.open(path, flags) print ret if ret == -errno.ENOENT: # Create the file in database ret = sefs.open(path) print ret print "Creating the file %s" %path t = int(time.time()) mytime = (t, t, t) ret = sefs.utime(path, mytime) print ret self.fd = len(sefs.ls()) print "In create:fd = %d" %(self.fd) sefs.setinode(path, self.fd) print sefs.ls() else: print "The file %s exists!!" %path return 0
def getattr(self, path): sefs = seFS() st = fuse.Stat() c = fuse.FuseGetContext() print c print "getattr called path= %s", path if path == '/': st.st_nlink = 2 st.st_mode = stat.S_IFDIR | 0755 else: print "For a regular file %s" %path st.st_mode = stat.S_IFREG | 0777 st.st_nlink = 1 st.st_uid, st.st_gid = (c['uid'], c['gid']) ret = sefs.search(path) print "From database getattr ret=", ret if ret is True: tup = sefs.getutime(path) print tup st.st_mtime = int(tup[0].strip().split('.')[0]) st.st_ctime = int(tup[1].strip().split('.')[0]) st.st_atime = int(tup[2].strip().split('.')[0]) st.st_ino = int(sefs.getinode(path)) print "inode = %d" %st.st_ino if sefs.getlength(path) is not None: st.st_size = int(sefs.getlength(path)) else: st.st_size = 0 return st else: return - errno.ENOENT
def getattr(self, path): sefs = seFS() st = fuse.Stat() c = fuse.FuseGetContext() print c print "getattr called path= %s", path if path == '/': st.st_nlink = 2 st.st_mode = stat.S_IFDIR | 0755 else: print "For a regular file %s" % path st.st_mode = stat.S_IFREG | 0777 st.st_nlink = 1 st.st_uid, st.st_gid = (c['uid'], c['gid']) ret = sefs.search(path) print "From database getattr ret=", ret if ret is True: tup = sefs.getutime(path) print tup st.st_mtime = int(tup[0].strip().split('.')[0]) st.st_ctime = int(tup[1].strip().split('.')[0]) st.st_atime = int(tup[2].strip().split('.')[0]) st.st_ino = int(sefs.getinode(path)) print "inode = %d" % st.st_ino if sefs.getlength(path) is not None: st.st_size = int(sefs.getlength(path)) else: st.st_size = 0 return st else: return -errno.ENOENT
def open(self, path, flags): print "open: trying to open %s" %path sefs = seFS() ret = sefs.search(path) print ret if ret is True: return 0 return -errno.ENOENT
def open(self, path, flags): print "open: trying to open %s" % path sefs = seFS() ret = sefs.search(path) print ret if ret is True: return 0 return -errno.ENOENT
def access(self, path, flag): print "access path=%s" %path sefs = seFS() if sefs.search(path) is True: print "In access, found the file %s" %path return 0 else: print "Could not find the file %s" %path return -errno.EACCES
def access(self, path, flag): print "access path=%s" % path sefs = seFS() if sefs.search(path) is True: print "In access, found the file %s" % path return 0 else: print "Could not find the file %s" % path return -errno.EACCES
def utimens(self, path, ts_acc, ts_mod): print "In utimens %s" % (path) print ts_acc, ts_mod atime = ts_acc.tv_sec + (ts_acc.tv_nsec / 1000000.0) mtime = ts_mod.tv_sec + (ts_mod.tv_nsec / 1000000.0) ctime = atime mytime = (mtime, ctime, atime) sefs = seFS() ret = sefs.utime(path, mytime) print ret
def utime(self, path, times=None): print "In utime %s" %(path) print times atime, mtime = times sefs = seFS() ret = sefs.utime(path, (atime, mtime, atime)) print ret return 0
def utimens(self, path, ts_acc, ts_mod): print "In utimens %s" %(path) print ts_acc, ts_mod atime = ts_acc.tv_sec + (ts_acc.tv_nsec / 1000000.0) mtime = ts_mod.tv_sec + (ts_mod.tv_nsec / 1000000.0) ctime = atime mytime = (mtime, ctime, atime) sefs = seFS() ret = sefs.utime(path, mytime) print ret
def utime(self, path, times=None): print "In utime %s" % (path) print times atime, mtime = times sefs = seFS() ret = sefs.utime(path, (atime, mtime, atime)) print ret return 0
def read(self, path, size, offset): try: print "In read %s %d %d" %(path, size, offset) sefs = seFS() ret = sefs.read(path) print "read(): %s" %(ret) fbuf = StringIO() fbuf.write(str(ret)) return fbuf.getvalue() except Exception, e: print "read failed" return e
def read(self, path, size, offset): try: print "In read %s %d %d" % (path, size, offset) sefs = seFS() ret = sefs.read(path) print "read(): %s" % (ret) fbuf = StringIO() fbuf.write(str(ret)) return fbuf.getvalue() except Exception, e: print "read failed" return e
def release(self, path, flags): print "In release" if self.is_dirty is True: print "Flushing buffer" print self.buf.read() sefs = seFS() ret = sefs.write(path, self.buf.read()) print self.buf.read() #self.buf.close() #del self.buf self.is_dirty = False print ret return 0
def readdir(self, path, offset): print "readdir", path yield fuse.Direntry('.') yield fuse.Direntry('..') sefs = seFS() all_files = sefs.ls() print "Rest of the files in root dir" print all_files for e in all_files: if str(e) == '/': continue yield fuse.Direntry(str(e[1:]))
def __init__(self, *args, **kw): fuse.Fuse.__init__(self, *args, **kw) # Set some options required by the Python FUSE binding. self.flags = 0 self.multithreaded = 0 self.fd = 0 self.sefs = seFS() ret = self.sefs.open('/') print "Created root with %s" % ret self.sefs.write('/', "Root of the seFS") t = int(time.time()) mytime = (t, t, t) ret = self.sefs.utime('/', mytime) print ret self.sefs.setinode('/', 1) self.is_dirty = False
def __init__(self, *args, **kw): fuse.Fuse.__init__(self, *args, **kw) # Set some options required by the Python FUSE binding. self.flags = 0 self.multithreaded = 0 self.fd = 0 self.sefs = seFS() ret = self.sefs.open('/') print "Created root with %s" %ret self.sefs.write('/', "Root of the seFS") t = int(time.time()) mytime = (t, t, t) ret = self.sefs.utime('/', mytime) print ret self.sefs.setinode('/', 1) self.is_dirty = False
def unlink(self, path): print "In unlink path %s" % path sefs = seFS() ret = sefs.remove(path) return
def unlink(self,path): print "In unlink path %s" %path sefs = seFS() ret = sefs.remove(path) return