Exemple #1
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
Exemple #2
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
Exemple #3
0
        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)

# Create a couple of levels of directories.
sd1_key = vfs_base.get_new_key()
vfs_dir.mkdir(fs, sd1_key, 0755)
vfs_dir.link(fs, "multi", "a", sd1_key)

sd2_key = vfs_base.get_new_key()
vfs_dir.mkdir(fs, sd2_key, 0755)
vfs_dir.link(fs, sd1_key, "b", sd2_key)

# Create an actual file in the lower subdirectory.
a_key = vfs_base.get_new_key()
a_file = fs.create_inode(a_key, 0644)
fs.put_data(a_key, 0, "hello world")
vfs_dir.link(fs, sd2_key, "cde", a_key)

print "Setup complete, let's see if we can read it back"