Пример #1
0
    def create(self, path, mode, flags):
        sefs = file1()
        ret = self.open(path, flags)

        if ret == -errno.ENOENT:
            ret = sefs.open(path)
            print "Creating the file %s" % path
            current_time = int(time.time())
            new_time = (current_time, current_time, current_time)
            ret = sefs.utime(path, new_time)

            self.fd = len(sefs.ls())
            print "In create:fd = %d" % (self.fd)
            sefs.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

            sefs.set_id(path, self.gid, self.uid, st.st_mode, st.st_nlink)

        else:
            print "The file %s exists!!" % path
        return 0
Пример #2
0
 def rmdir(
     self, path
 ):  #-------------------------- working properly-----------------------------
     print "In rmDir"
     sefs = file1()
     ret = sefs.remove(path)
     return 0
Пример #3
0
    def readdir(self, path, offset):			#-------------------------- working properly-----------------------------
	print "readdir", path
	yield fuse.Direntry('.')
        yield fuse.Direntry('..')

	sefs = file1()
	all_files = sefs.ls()
	print "Rest of the files in root dir"

	for e in all_files:
		
		if str(e) == path:
			continue

		if (len(e.split(path))==2):
			  print "%s" %e
			  strpath = e.split(path)
			  strpath = strpath[1]

			  if path == '/':     		
			  	yield fuse.Direntry(str(e[1:]))
			  elif (len(strpath.split('/')) > 2):				
				continue
			  else:
				size=len(path) + 1
				yield fuse.Direntry(str(e[size:]))
Пример #4
0
    def getattr(self, path):
	sefs = file1()
        st = fuse.Stat()
	c  = fuse.FuseGetContext()

       	ret = sefs.search(path)
	print "Already present =", ret 
	if ret is True:
		st.st_ino = int(sefs.getinode(path))
		st.st_uid, st.st_gid = (c['uid'], c['gid'])
		st.st_mode = sefs.getmode(path)
		st.st_nlink = sefs.getlinkcount(path)

		if sefs.getlength(path) is not None:
			st.st_size = int(sefs.getlength(path))
		else:
			st.st_size = 0

		tup = sefs.getutime(path)
		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])

		
		print "inode numder = %d" %st.st_ino
		

		return st
	else:
       		return - errno.ENOENT
Пример #5
0
    def create(self, path, mode, flags):
	sefs = file1()
	ret = self.open(path, flags)

	if ret == -errno.ENOENT:
		ret = sefs.open(path)
		print "Creating the file %s" %path
		current_time = int(time.time())
		new_time = (current_time, current_time, current_time)
		ret = sefs.utime(path, new_time)

		self.fd = len(sefs.ls())
		print "In create:fd = %d" %(self.fd)
		sefs.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

		sefs.set_id(path, self.gid, self.uid,st.st_mode,st.st_nlink)


	else:
		print "The file %s exists!!" %path
	return 0
Пример #6
0
    def getattr(self, path):
        sefs = file1()
        st = fuse.Stat()
        c = fuse.FuseGetContext()

        ret = sefs.search(path)
        print "Already present =", ret
        if ret is True:
            st.st_ino = int(sefs.getinode(path))
            st.st_uid, st.st_gid = (c['uid'], c['gid'])
            st.st_mode = sefs.getmode(path)
            st.st_nlink = sefs.getlinkcount(path)

            if sefs.getlength(path) is not None:
                st.st_size = int(sefs.getlength(path))
            else:
                st.st_size = 0

            tup = sefs.getutime(path)
            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])

            print "inode numder = %d" % st.st_ino

            return st
        else:
            return -errno.ENOENT
Пример #7
0
 def unlink(
     self, path
 ):  #-------------------------- working properly-----------------------------
     print "In unlink path %s" % path
     sefs = file1()
     ret = sefs.remove(path)
     return
Пример #8
0
    def __init__(self, *args, **kw):
        fuse.Fuse.__init__(self, *args, **kw)

      
        self.flags = 0
        self.multithreaded = 0
	self.fd = 0
	self.gid = os.getgid()
	self.uid = os.geteuid()

	self.sefs = file1()
	self.sefs.open('/')
	ret = self.sefs.search('/')
	if ret is False:
		print "Created root with %s" %ret
		self.sefs.write('/', "Root")
		t = int(time.time())
		mytime = (t, t, t)
		ret = self.sefs.utime('/', mytime)

		self.sefs.setinode('/', 1)
		self.sefs.setmode('/', stat.S_IFDIR | 0755)
		self.sefs.setlinkcount('/', 2)
		self.is_dirty = False

  	'''  def getdir(self, path):
Пример #9
0
    def readdir(
        self, path, offset
    ):  #-------------------------- working properly-----------------------------
        print "readdir", path
        yield fuse.Direntry('.')
        yield fuse.Direntry('..')

        sefs = file1()
        all_files = sefs.ls()
        print "Rest of the files in root dir"

        for e in all_files:

            if str(e) == path:
                continue

            if (len(e.split(path)) == 2):
                print "%s" % e
                strpath = e.split(path)
                strpath = strpath[1]

                if path == '/':
                    yield fuse.Direntry(str(e[1:]))
                elif (len(strpath.split('/')) > 2):
                    continue
                else:
                    size = len(path) + 1
                    yield fuse.Direntry(str(e[size:]))
Пример #10
0
    def access(self, path, flag):
        print "access path=%s" %path
	sefs = file1()
	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
Пример #11
0
 def access(self, path, flag):
     print "access path=%s" % path
     sefs = file1()
     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
Пример #12
0
    def read(self, path, size, offset):
	try:
		print "In read %s %d %d" %(path, size, offset)
		sefs = file1()
		ret = sefs.read(path)
		print "read(): %s" %(ret[:-1])
		fbuf = StringIO()
		fbuf.write(str(ret[:-1]))
		return fbuf.getvalue()
	except Exception, e:
		print "read failed"
		return e
Пример #13
0
 def read(self, path, size, offset):
     try:
         print "In read %s %d %d" % (path, size, offset)
         sefs = file1()
         ret = sefs.read(path)
         print "read(): %s" % (ret[:-1])
         fbuf = StringIO()
         fbuf.write(str(ret[:-1]))
         return fbuf.getvalue()
     except Exception, e:
         print "read failed"
         return e
Пример #14
0
 def release(self, path, flags):
     print "In release"
     if self.is_dirty is True:
         print "Flushing buffer"
         print self.buf.read()
         sefs = file1()
         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
Пример #15
0
    def release(self, path, flags):
	print "In release"
	if self.is_dirty is True:
		print "Flushing buffer"
		print self.buf.read()
		sefs = file1()
		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
Пример #16
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 = file1()
	prev = sefs.read(path)
	data = prev + data
	ret = sefs.write(path, data)
	
	current_time = int(time.time())
	ret = sefs.set_writetime(path, current_time)

	return length
Пример #17
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 = file1()
        prev = sefs.read(path)
        data = prev + data
        ret = sefs.write(path, data)

        current_time = int(time.time())
        ret = sefs.set_writetime(path, current_time)

        return length
Пример #18
0
    def __init__(self, *args, **kw):
        fuse.Fuse.__init__(self, *args, **kw)

        self.flags = 0
        self.multithreaded = 0
        self.fd = 0
        self.gid = os.getgid()
        self.uid = os.geteuid()

        self.sefs = file1()
        self.sefs.open('/')
        ret = self.sefs.search('/')
        if ret is False:
            print "Created root with %s" % ret
            self.sefs.write('/', "Root")
            t = int(time.time())
            mytime = (t, t, t)
            ret = self.sefs.utime('/', mytime)

            self.sefs.setinode('/', 1)
            self.sefs.setmode('/', stat.S_IFDIR | 0755)
            self.sefs.setlinkcount('/', 2)
            self.is_dirty = False
        '''  def getdir(self, path):
Пример #19
0
    def rmdir(self, path):				#-------------------------- working properly-----------------------------
	print "In rmDir"
	sefs = file1()
	ret = sefs.remove(path)
	return 0
Пример #20
0
 def utime(self, path, times=None):
     atime, mtime = times
     sefs = file1()
     ret = sefs.utime(path, (atime, mtime, atime))
     return 0
Пример #21
0
    def unlink(self,path):					#-------------------------- working properly-----------------------------
	print "In unlink path %s" %path
	sefs = file1()
	ret = sefs.remove(path)
	return
Пример #22
0
    def utime(self, path, times=None):
	atime, mtime = times
	sefs = file1()
	ret = sefs.utime(path, (atime, mtime, atime))
	return 0
Пример #23
0
 def open(self, path, flags):
     sefs = file1()
     ret = sefs.search(path)
     if ret is True:
         return 0
     return -errno.ENOENT
Пример #24
0
    def open(self, path, flags):
	sefs = file1()
	ret = sefs.search(path)
	if ret is True:
		return 0
	return -errno.ENOENT