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
""" Copyright (c) 2010, Jeff Darcy <*****@*****.**> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ import os import struct import sys db = __import__(os.getenv("VOLDFS_DB","voldemort")) import vfs_base import vfs_dir s = db.StoreClient("test",[("localhost",6666)]) fs = vfs_base.FS(s) vfs_dir.mkdir(fs,"root",0755)
def fsinit(self): try: if self.fs.store.auto_mkfs: vfs_dir.mkdir(self.fs, self.root, 0755) except: print "This storage type requires mkfs first"
import struct import sys import traceback db = __import__(os.getenv("VOLDFS_DB", "voldemort")) import vfs_base import vfs_dir s = db.StoreClient("test", [("localhost", 6666)]) fs = vfs_base.FS(s) status = "OK" ### TEST SET 1: create and then do single-level lookups for 1000 files. vfs_dir.mkdir(fs, "root", 0755) for i in range(1000): path = "file%d" % i key = struct.pack(vfs_base.PTR_FMT, 1, 1, i + 100) 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)