def create(self, path, mode, flags): FSobj = FileSystem() return_value = self.open(path, flags) if return_value == -errno.ENOENT: return_value = FSobj.open(path) print "Creating the file %s" %path current_time = int(time.time()) new_time = (current_time, current_time, current_time) return_value = FSobj.utime(path, new_time) self.fd = len(FSobj.ls()) print "In create:fd = %d" %(self.fd) FSobj.setinode(path, self.fd) st = fuse.Stat() if path == '/': st.st_nlink = 2 st.st_mode = stat.S_IFDIR | 0755 if flags == 1: st.st_nlink = 2 st.st_mode = stat.S_IFDIR | 0755 else: st.st_mode = stat.S_IFREG | 0777 st.st_nlink = 1 FSobj.set_id(path, self.gid, self.uid,st.st_mode,st.st_nlink) else: print "The file %s exists!!" %path return 0
def readdir(self, path, offset): print "readdir", path yield fuse.Direntry('.') yield fuse.Direntry('..') FSobj = FileSystem() all_files = FSobj.ls() print "Rest of the files in root dir" for i in all_files: if str(i) == path: continue if (len(i.split(path))==2): print "%s" %i strpath = i.split(path) strpath = strpath[1] if path == '/': yield fuse.Direntry(str(i[1:])) elif (len(strpath.split('/')) > 2): continue else: size=len(path) + 1 yield fuse.Direntry(str(i[size:]))