Пример #1
0
 def write(self, path, buf, offset):
     logging.debug("write %s, %s, %d" % (path, buf, offset))
     if lmdbfs.exists(path):
         st, data = lmdbfs.read_file(path)
         st.st_size = len(buf)
         lmdbfs.write_file(path, st, buf)
         return len(buf)
     return -errno.ENOENT
Пример #2
0
 def truncate(self, path, size):
     logging.debug("truncate %s, %d" % (path, size))
     if lmdbfs.exists(path):
         st, data = lmdbfs.read_file(path)
         st.st_size = size
         data = data[:size]
         lmdbfs.write_file(path, st, data)
         return 0
     return -errno.ENOENT
Пример #3
0
    def test(self):
        st = fuse.Stat()
        st.st_nlink = 1
        st.st_mode = 0
        data = 'file1datadatadata'
        lmdbfs.write_file('file1', st, data)

        st_r, data_r = lmdbfs.read_file('file1')
        self.assertEqual(data, data_r)
        self.assertEquals(st.st_nlink, st_r.st_nlink)
Пример #4
0
 def getattr(self, path):
     logging.debug("getattr %s" % (path))
     ret = LMDBStat()
     if path == '/':
         ret.st_mode = stat.S_IFDIR | 0755
         ret.st_nlink = 2
         ret.st_size = DIRSIZE
         return ret
     else:
         meta, _ = lmdbfs.read_file(path)
         if meta:
             return meta
         else:
             return -errno.ENOENT
Пример #5
0
 def read(self, path, size, offset):
     logging.debug("read %s, %d, %d" % (path, size, offset))
     if lmdbfs.exists(path):
         _, data = lmdbfs.read_file(path)
         return data[offset:offset+size]
     return -errno.ENOENT
Пример #6
0
 def testNonExistentRead(self):
     st_r, data_r = lmdbfs.read_file('file2')
     self.assertIsNone(st_r)
     self.assertIsNone(data_r)