Esempio n. 1
0
 def unlink(self, path):
     print "in unlink(%s)" % path
     parts = path.split("/")
     parent = string.join(parts[:-1], "/")
     child = parts[-1]
     pptr = vfs_dir.lookup(self.fs, self.root, parent)
     if pptr == None:
         return -errno.ENOENT
     return vfs_dir.unlink(self.fs, pptr, child)
Esempio n. 2
0
 def read(self, path, length, offset, fh=None):
     ptr = vfs_dir.lookup(self.fs, self.root, path)
     if ptr == None:
         return -errno.ENOENT
     total = ""
     while len(total) < length:
         new_data = self.fs.get_data(ptr, offset, length)
         if not len(new_data):
             break
         total += new_data
         offset += len(new_data)
     return total
Esempio n. 3
0
 def readdir(self, path, offset=0):
     print "in readdir(%s,0x%x)" % (path, offset)
     ptr = vfs_dir.lookup(self.fs, self.root, path)
     if ptr == None:
         raise IOError, "directory not found"
         return
     coll = Collector()
     vfs_dir.enum(self.fs, ptr, coll, offset)
     for name, hash in coll.result:
         x = fuse.Direntry(name)
         x.ino = hash
         yield x
Esempio n. 4
0
 def mkdir(self, path, mode):
     parts = path.split("/")
     parent = string.join(parts[:-1], "/")
     child = parts[-1]
     pptr = vfs_dir.lookup(self.fs, self.root, parent)
     if pptr == None:
         return -errno.ENOENT
     cptr = vfs_base.get_new_key()
     vfs_dir.mkdir(self.fs, cptr, mode)
     try:
         vfs_dir.link(self.fs, pptr, child, cptr)
     except vfs_dir.DupFileExc:
         return -errno.EEXIST
Esempio n. 5
0
 def create(self, path, flags, mode):
     print "in create(%s,0x%x,0x%x)" % (path, flags, mode)
     parts = path.split("/")
     parent = string.join(parts[:-1], "/")
     child = parts[-1]
     pptr = vfs_dir.lookup(self.fs, self.root, parent)
     if pptr == None:
         return -errno.ENOENT
     cptr = vfs_base.get_new_key()
     self.fs.create_inode(cptr, mode)
     try:
         vfs_dir.link(self.fs, pptr, child, cptr)
     except vfs_dir.DupFileExc:
         return -errno.EEXIST
Esempio n. 6
0
 def getattr(self, path):
     ptr = vfs_dir.lookup(self.fs, self.root, path)
     if ptr == None:
         return -errno.ENOENT
     try:
         idata, vector = self.fs.get_inode(ptr)
         inode = struct.unpack(vfs_base.INODE_FMT, idata[: vfs_base.INODE_SZ])
     except:
         print "<<<%s>>>" % repr(ptr)
         traceback.print_exc()
         return -errno.EIO
     it = NullObject()
     it.st_mode = inode[0]
     it.st_ino = inode[1]
     it.st_dev = inode[2]
     it.st_nlink = inode[3]
     it.st_uid = inode[4]
     it.st_gid = inode[5]
     it.st_size = inode[6]
     it.st_atime = inode[7]
     it.st_mtime = inode[8]
     it.st_ctime = inode[9]
     return it
Esempio n. 7
0
 def write(self, path, buf, offset, fh=None):
     ptr = vfs_dir.lookup(self.fs, self.root, path)
     if ptr == None:
         return -errno.ENOENT
     return self.fs.put_data(ptr, offset, buf)
Esempio n. 8
0
    try:
        vfs_dir.link(fs, "root", path, key)
        print "add(%s) OK" % path
    except:
        traceback.print_exc()
        print "add(%s) FAILED" % path
        status = "FAILED"

print "adding file0 AGAIN"
key = struct.pack(vfs_base.PTR_FMT, 1, 1, 0)
vfs_dir.link(fs, "root", "file0", key)

for i in range(1000):
    path = "/file%d" % i
    try:
        ptr = vfs_dir.lookup(fs, "root", path)
        if not ptr:
            raise RuntimeError, "lookup failed"
        print "lookup(%s) OK" % path
    except:
        traceback.print_exc()
        print "lookup(%s) FAILED" % path
        status = "FAILED"

if status != "OK":
    print "status = <<%s>>, skipping other tests" % status
    raise SystemExit

### TEST SET 2: test multi-level lookup

vfs_dir.mkdir(fs, "multi", 0755)