Exemplo n.º 1
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
Exemplo n.º 2
0
    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
Exemplo n.º 3
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
Exemplo n.º 4
0
    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
Exemplo n.º 5
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
Exemplo n.º 6
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
Exemplo n.º 7
0
    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
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
    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
Exemplo n.º 10
0
 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
Exemplo n.º 11
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
Exemplo n.º 12
0
    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
Exemplo n.º 13
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
Exemplo n.º 14
0
    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
Exemplo n.º 15
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
Exemplo n.º 16
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
Exemplo n.º 17
0
 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
Exemplo n.º 18
0
    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
Exemplo n.º 19
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:]))
Exemplo n.º 20
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:]))
Exemplo n.º 21
0
    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
Exemplo n.º 22
0
    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
Exemplo n.º 23
0
 def unlink(self, path):
     print "In unlink path %s" % path
     sefs = seFS()
     ret = sefs.remove(path)
     return
Exemplo n.º 24
0
    def unlink(self,path):
	print "In unlink path %s" %path
	sefs = seFS()
	ret = sefs.remove(path)
	return