dest='redis_uri', help='URI for Redis instance for metadata', default='redis://localhost:6379/0') parser.add_argument('-b', '--base', dest='base_key', help='Base path for redis keys if cluster is shared for different uses', default='') parser.add_argument('-s', '--service-account', dest='service_account', help='Path to service account credentials for GCS bucket') parser.add_argument('-i', '--init', dest='init', action='store_true', help='Should this instance initialize the Redis metadata instance') parser.add_argument('-d', '--debug', dest='debug', action='store_true', help='Debug mode') args = parser.parse_args() print(args) FUSE(Festivus(args.bucket_name, args.service_account, args.redis_uri, args.base_key, args.init), args.mount_point, foreground=True, nothreads=True, debug=args.debug)
sys.exit(1) else: if arg == 'foreground': foreground = True elif arg == 'getall': getall = True else: print("unrecognized option: %s" % arg) sys.exit(1) mountpoint = "".join(args) if mountpoint == "": print 'invalid mountpoint' sys.exit(1) mountpoint = os.path.realpath(mountpoint) if command: retcode = send_sharebox_command(command, mountpoint) sys.exit(retcode) else: if not gitdir: print "Can't mount, missing the gitdir option." print __doc__ sys.exit(1) gitdir = os.path.realpath(gitdir) sharebox = ShareBox(gitdir, mountpoint, numversions, getall, notifycmd) fuse = FUSE(sharebox, mountpoint, foreground=foreground) ########NEW FILE########
def main(mountpoint): # shutil.rmtree(".backend") os.mkdir(".backend") FUSE(Passthrough(root_folder), mountpoint, nothreads=True, foreground=True)
def main(mountpoint, root): FUSE(Passthrough(root), mountpoint, nothreads=True, foreground=True)
def main(mountpoint): FUSE(DriveFS(), mountpoint, nothreads=True, foreground=False)
if __name__ == '__main__': parser = argparse.ArgumentParser(description='Collect IO events') parser.add_argument('-m', '--mountpoint', required=True, help='Directory to use as mountpoint') parser.add_argument('-b', '--backend', required=True, help='File system backend to pass requests to') parser.add_argument('-f', '--flush', default=False, action="store_true", help='Flush log messages immediately') parser.add_argument( '-c', '--clear', default=False, action="store_true", help='Clear backend before mounting, removes previous traces as well.') args = parser.parse_args() if not os.path.isdir(args.mountpoint): os.mkdir(args.mountpoint) FUSE(TraceGenerator(args.backend, flush=args.flush, clear=args.clear), args.mountpoint, nothreads=True, foreground=True)
if __name__ == '__main__': import syslog try: logger.info("Starting Azure Files Fuse Driver") if len(argv) == 2: # read file in from disk as specified, then pipe them into the arg list for below scriptargsfile = argv[1] logger.info("Starting Azure Files Fuse Driver using args file:%s", scriptargsfile) with open(scriptargsfile) as f: argsFromFile = f.readline().rstrip() splitArgs = argsFromFile.split(' ') argv = argv[0:1] + splitArgs logger.info("Removing args file after getting args") try: os.remove(scriptargsfile) except Exception as e: logger.error("Failed to remove fuseArgs file:%s", e) if len(argv) != 5: print('usage: {} <azure_storage_account_name> <azure_file_share_name> <sas_token> <mount_point>'.format(argv[0])) syslog.syslog(syslog.LOG_ERR, "Arguments to Python Fuse Driver Bad: {}".format(argv)) exit(1) syslog.syslog("fuse = FUSE(AzureFiles({}, {}, {}), {}, foreground=True, nothreads=True)".format(argv[1], argv[2], argv[3], argv[4])) logging.basicConfig(level=LOGGING_LEVEL) fuse = FUSE(AzureFiles(argv[1], argv[2], argv[3]), argv[4], foreground=True, nothreads=True, debug=False) except Exception as e: logger.error("Python Fuse Top-Level Exception: %s", e) logger.error("Python Fuse Top-Level Trace Exception: %s", traceback.format_exc())
def statfs(self, path): stv = os.statvfs(path) return dict((key, getattr(stv, key)) for key in ('f_bavail', 'f_bfree', 'f_blocks', 'f_bsize', 'f_favail', 'f_ffree', 'f_files', 'f_flag', 'f_frsize', 'f_namemax')) def symlink(self, target, source): return os.symlink(source, target) def truncate(self, path, length, fh=None): with open(path, 'r+') as f: f.truncate(length) unlink = os.unlink utimens = os.utime def write(self, path, data, offset, fh): with self.rwlock: os.lseek(fh, offset, 0) return os.write(fh, data) if __name__ == '__main__': if len(argv) != 3: print('usage: %s <root> <mountpoint>' % argv[0]) exit(1) fuse = FUSE(Loopback(argv[1]), argv[2], foreground=True)
r.raise_for_status() return r.json() except requests.RequestException as e: print e raise self.RubrikException("Rubrik API Call Failed: " + str(e)) except (requests.exceptions.HTTPError, requests.exceptions.RequestException) as e: print e response = r.json() if response.has_key('message'): print response['message'] raise self.RubrikException("Call Failed: " + response['message']) sys.exit(1) if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument('mount') args = parser.parse_args() logging.basicConfig(level=logging.DEBUG) fuse = FUSE(RubrikFS(), args.mount, foreground=True, ro=True, allow_other=True)
from sys import argv import logging from fuse import FUSE from dochub_api import DochubAPI from fs import DochubFileSystem import config logging.basicConfig(level=logging.INFO) if __name__ == "__main__": if len(argv) != 2: print('usage: %s <mountpoint>' % argv[0]) exit(1) api = DochubAPI(base_url=config.BASE_URL, token=config.TOKEN) fs = DochubFileSystem(api=api) FUSE(fs, argv[1], foreground=True)
def main(): mountpoint = sys.argv[1] FUSE(PrintlessFS(mountpoint), mountpoint, foreground=True)
raise FuseOSError(ENOENT) cur.close() if not to_return: raise FuseOSError(ENOENT) return to_return + ['.', '..'] if __name__ == '__main__': parser = argparse.ArgumentParser( description="Mount a postgresql database with FUSE.") parser.add_argument('mount_point', type=str) parser.add_argument('--port', dest='port', type=int) parser.add_argument('--host', dest='host', type=str) parser.add_argument('-d', '--database', dest='database', required=True, type=str) parser.add_argument('-u', '--username', dest='username', type=str) parser.add_argument('-p', '--password', dest='password', type=str) args = parser.parse_args() fsthing = PostgresFS( args.database, port=args.port if args.port else 5432, username=args.username if args.username else getpass.getuser(), host=args.host if args.host else None, password=args.password if args.password else None) fuse = FUSE(fsthing, args.mount_point, foreground=True, nothreads=True)
else: raise FuseOSError(ENOENT) print("local write") print("current contents:", self.data[path]) print("offset", offset) print("fh", fh) self.data[path] = self.data[path][:offset].ljust( offset, b'\x00'.decode()) self.data[path] += data.decode() self.data[path] += self.data[path][offset + len(data):] # self.data[path] = ( # # make sure the data gets inserted at the right offset # self.data[path][:offset].ljust(offset, '\x00'.encode('ascii')) # + data.decode() # # and only overwrites the bytes that data is replacing # + self.data[path][offset + len(data):]) self.files[path]['st_size'] = len(self.data[path]) print("current contents:", self.data[path]) return len(data) if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument('mount') args = parser.parse_args() logging.basicConfig(level=logging.DEBUG) if not os.path.exists(args.mount): os.makedirs(args.mount) fuse = FUSE(Memory(), args.mount, foreground=True)
help='folder containing your encrypted files') parser.add_argument('-d', '--debug', help='run in debug mode', action='store_true', default=False) parser.add_argument('-t', '--multithread', help='run in multi-threaded mode', action='store_true', default=False) args = parser.parse_args() data = args.data mountpoint = args.mountpoint print(f"[*] Mounting FreyaFS...") fs = FreyaFS(data, mountpoint) FUSE(fs, mountpoint, foreground=True, debug=args.debug, nothreads=not args.multithread, big_writes=True) print("\n[*] Unmounting FreyaFS...") print("[*] FreyaFS unmounted") print("[*] Updating FreyaFS metadata...") fs.metadata.dump() print("[*] FreyaFS metadata updated")
return 0 def chown(self, path, uid, gid): global count count += 1 print("CallCount {} " " Time {}".format(count, datetime.datetime.now().time())) print('In function chown()') self.FS.update_meta(path, uid=uid, gid=gid) if __name__ == "__main__": if len(argv) < 5: print 'usage: %s <mountpoint> <Qr> <Qw> <meta port> <data ports>' % argv[ 0] exit(1) url_list = [] Qr = int(sys.argv[2]) #Qr should be greater than 3 to be tolerated error Qw = int(sys.argv[3]) #Qw cannot be equal to len(url_list) for i in xrange(4, len(argv)): url_string = "http://localhost:" + argv[i] url_list.append(url_string) #url_list = sys.argv[4:] print "Length", len(sys.argv) print "Arguments", (url_list) fuse = FUSE(Memory(url_list), argv[1], foreground=True)
def unlink(self, path): return self.data.pop(path) self.files.pop(path) def utimens(self, path, times=None): now = time() atime, mtime = times if times else (now, now) self.files[path]['st_atime'] = atime self.files[path]['st_mtime'] = mtime def write(self, path, data, offset, fh): path = clean(path) return write(path, data, offset) if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument('mount') args = parser.parse_args() logging.basicConfig(level=logging.INFO) fuse = FUSE(Memory(), args.mount, foreground=True, allow_other=True, iosize=128 * 1024, direct_io=True)
block = self.block_cache.get(block_hash) data += block return data[offset % config.block_size:offset % config.block_size + size] else: raise FuseOSError(ENOENT) def readdir(self, path, fh=None): items = ['.', '..'] path = path[1:] if path == '': for p in self.remotefs.dict: if p and '/' not in p: items.append(p) return items elif path in self.remotefs.dict and self.remotefs.dict[path].is_dir: for p in self.remotefs.dict: if p.startswith(path + '/') and '/' not in p[len(path) + 1:]: items.append(p[len(path) + 1:]) return items else: raise FuseOSError(ENOENT) if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) if len(sys.argv) >= 5: key = sys.argv[4] else: key = None fuse = FUSE(CubicFS(sys.argv[1], sys.argv[2], key), sys.argv[3], foreground=True)
def start_fuse(mount_point, safe_point): os.system("mkdir -p " + safe_point) os.system("mount --bind " + mount_point + " " + safe_point) fuse = FUSE(MyDLPFilter(safe_point), mount_point, foreground=True, nonempty=True, allow_other=True)
# def rmdir(self, path): # return self.sftp.rmdir(path) # def symlink(self, target, source): # return self.sftp.symlink(source, target) # def truncate(self, path, length, fh=None): # return self.sftp.truncate(path, length) # def unlink(self, path): # return self.sftp.unlink(path) # def utimens(self, path, times=None): # return self.sftp.utime(path, times) # def write(self, path, data, offset, fh): # f = self.sftp.open(path, 'r+') # f.seek(offset, 0) # f.write(data) # f.close() # return len(data) if __name__ == '__main__': if len(argv) != 2: print('usage: %s <mountpoint>' % argv[0]) exit(1) fuse = FUSE(baidufs(), argv[1], foreground=True, nothreads=True)
def start(work_dir, sis_graph, mountpoint): FUSE(SISFilesystem(work_dir, sis_graph, mountpoint), mountpoint, foreground=True)
def main(mountpoint, root, foreground=True): FUSE(Passthrough(root), mountpoint, nothreads=True, foreground=foreground) # , allow_other=True)
def bundle_mount(client, mountpoint, bundle_uuid, verbose=False): ''' Mount the filesystem on the mountpoint. ''' FUSE(BundleFuse(client, bundle_uuid, verbose), mountpoint, nothreads=True, foreground=True)
attrs[name] = value def getxattr(self, path, name, position=0): attrs = self.files[path].get('attrs', {}) try: return attrs[name] except KeyError: return '' # Should return ENOATTR def listxattr(self, path): attrs = self.files[path].get('attrs', {}) return attrs.keys() def utimens(self, path, times=None): now = time() atime, mtime = times if times else (now, now) self.files[path]['st_atime'] = atime self.files[path]['st_mtime'] = mtime if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument('mount') args = parser.parse_args() logging.basicConfig(level=logging.DEBUG) fuse = FUSE(CloudFS(), args.mount, foreground=True, allow_other=True)
if args.account_id: config["accountId"] = args.account_id if args.application_key: config["applicationKey"] = args.application_key if args.bucket_id: config["bucketId"] = args.bucket_id if args.enable_hashfiles: config["enableHashfiles"] = args.enable_hashfiles else: config["enableHashfiles"] = False if args.memory_limit: config["memoryLimit"] = args.memory_limit if args.temp_folder: config["tempFolder"] = args.temp_folder if args.use_disk: config["useDisk"] = args.use_disk else: config["useDisk"] = False with B2Fuse(config["accountId"], config["applicationKey"], config["bucketId"], config["enableHashfiles"], config["memoryLimit"], config["tempFolder"], config["useDisk"]) as filesystem: FUSE(filesystem, args.mountpoint, nothreads=True, foreground=True)
def main(): global info, log, dbg time.strptime("19970815", "%Y%m%d") # python#7980 # filecache helps for reads that are ~64k or smaller; # linux generally does 128k so the cache is a slowdown, # windows likes to use 4k and 64k so cache is required, # value is numChunks (1~3M each) to keep in the cache nf = 24 # dircache is always a boost, # only want to disable it for tests etc, # value is numSec until an entry goes stale nd = 1 where = "local directory" if WINDOWS: where += " or DRIVE:" ex_pre = "\n " + os.path.basename(__file__) + " " examples = ["http://192.168.1.69:3923/music/ ./music"] if WINDOWS: examples.append("http://192.168.1.69:3923/music/ M:") ap = argparse.ArgumentParser( formatter_class=TheArgparseFormatter, epilog="example:" + ex_pre + ex_pre.join(examples), ) ap.add_argument("-cd", metavar="NUM_SECONDS", type=float, default=nd, help="directory cache") ap.add_argument("-cf", metavar="NUM_BLOCKS", type=int, default=nf, help="file cache") ap.add_argument("-a", metavar="PASSWORD", help="password") ap.add_argument("-d", action="store_true", help="enable debug") ap.add_argument("-te", metavar="PEM_FILE", help="certificate to expect/verify") ap.add_argument("-td", action="store_true", help="disable certificate check") ap.add_argument("base_url", type=str, help="remote copyparty URL to mount") ap.add_argument("local_path", type=str, help=where + " to mount it on") ar = ap.parse_args() if ar.d: # windows terminals are slow (cmd.exe, mintty) # otoh fancy_log beats RecentLog on linux logger = RecentLog().put if WINDOWS else fancy_log info = logger log = logger dbg = logger else: # debug=off, speed is dontcare info = fancy_log log = null_log dbg = null_log if ar.a and ar.a.startswith("$"): fn = ar.a[1:] log("reading password from file [{}]".format(fn)) with open(fn, "rb") as f: ar.a = f.read().decode("utf-8").strip() if WINDOWS: os.system("rem") for ch in '<>:"\\|?*': # microsoft maps illegal characters to f0xx # (e000 to f8ff is basic-plane private-use) bad_good[ch] = chr(ord(ch) + 0xF000) for n in range(0, 0x100): # map surrogateescape to another private-use area bad_good[chr(n + 0xDC00)] = chr(n + 0xF100) for k, v in bad_good.items(): good_bad[v] = k register_wtf8() try: with open("/etc/fuse.conf", "rb") as f: allow_other = b"\nuser_allow_other" in f.read() except: allow_other = WINDOWS or MACOS args = {"foreground": True, "nothreads": True, "allow_other": allow_other} if not MACOS: args["nonempty"] = True FUSE(CPPF(ar), ar.local_path, encoding="wtf-8", **args)
args = vars(p.parse_args(sys.argv[1:])) fsroot = six.text_type(args.pop("http_resource").strip("/")) mountpoint = args.pop("mountpoint") x_api_key = args.pop("x-api-key") fuse_kwargs = { 'nothreads': True if args.pop("nothreads") else False, 'foreground': True if args.pop("foreground") else False, 'debug': True if args.pop("debug") else False, 'allow_other': True if args.pop("allow_other") else False, } # o_args_list = [x.strip() for x in args.pop("o").split(",")] # o_args = {} # for x in o_args_list: # xs = [y.strip() for y in x.split("=")] # if len(xs) > 1: # fuse_kwargs[xs[0]] = xs[1:] # else: # fuse_kwargs[x] = True if fuse_kwargs['debug']: logging.basicConfig(level=logging.DEBUG, format=FORMAT) FUSE( AlveoFS(fsroot, x_api_key, verify_ssl=False if args.pop("no_ssl_verify") else True), mountpoint, **fuse_kwargs)
else: break else: # Local block size = self.datanode.getBlockSize(blockId) if size < BLOCK_SIZE: self.datanode.truncateBlock(blockId, BLOCK_SIZE) else: break except Exception, e2: print "[TODO] fix write:", e2 return len(data) def createBlock(self, path, iBlock): # Get id for the new block blockId = self.getNamenodeClient().addBlock(self.hostname, path, iBlock) #print "add block", self.hostname, path, iBlock, "=>", blockId # Purge file info if path in self.datanode.cacheFileBlocks: del self.datanode.cacheFileBlocks[path] # Create new block and write data in self.datanode.createBlock(blockId) return blockId if __name__ == "__main__": if len(argv) != 3: print 'usage: %s <host> <mountpoint>' % argv[0] exit(1) fuse = FUSE(HDFS(hostnamenode=argv[1], path=argv[2]), argv[2], foreground=True, nothreads=True, debug=False, allow_other=True)
def main(mft_filename, mountpoint): with Mmap(mft_filename) as buf: tree = MFTTree(buf) tree.build(progress_class=ProgressBarProgress) handler = MFTFuseOperations(mountpoint, tree, buf) FUSE(handler, mountpoint, foreground=True)
def main(mountpoint): FUSE(VersionFS(), mountpoint, nothreads=True, foreground=True)
def main(): args = parse_options() config = ConfigParser() creds = ConfigParser() keys = {} login_success = False # configure logging if args.verbosity == 1: log_level = logging.INFO elif args.verbosity == 2: log_level = logging.DEBUG else: log_level = logging.ERROR logging.basicConfig(level=log_level, format='%(levelname)-8s: %(message)s') if args.verbosity: args.foreground = True # figure out config files config_file = pathlib.Path(args.config) creds_file = pathlib.Path(args.creds) # remove config and quit if wanted if args.logout: try: config_file.unlink() except OSError: logging.info('No config file found.') try: creds_file.unlink() except OSError: logging.info('No creds file found.') print('Config files removed.') if not args.unmount: sys.exit(0) # make sure mountpoint is specified if not args.mountpoint: print('No mountpoint specified.') sys.exit(1) # unmount folder and quit if wanted if args.unmount: try: if platform.system().lower() != 'darwin': umount_cmd = ['fusermount', '-u'] else: umount_cmd = ['umount'] subprocess.check_call(umount_cmd + [args.mountpoint]) print(args.mountpoint + ' unmounted.') except: print('Error unmounting file system.') sys.exit(1) sys.exit(0) # keep sync_sec above the minimum sync time if args.sync_sec < MINIMUM_SYNC_SEC: sync_sec = MINIMUM_SYNC_SEC print('Sync interval must be at least', MINIMUM_SYNC_SEC, 'seconds. Using that instead.') else: sync_sec = args.sync_sec # load config file settings if not args.no_config_files: try: config_file.parent.mkdir(mode=0o0700, parents=True) except FileExistsError: pass except OSError: log_msg = 'Error creating config file directory "%s".' print(log_msg % str(config_file.parent)) sys.exit(1) finally: log_msg = 'Using config directory "%s".' logging.info(log_msg % str(config_file.parent)) try: with config_file.open() as f: config.read_file(f) log_msg = 'Loaded config file "%s".' logging.info(log_msg % str(config_file)) except OSError: log_msg = 'Unable to read config file "%s".' logging.info(log_msg % str(config_file)) # load creds file settings if not args.no_config_files: try: creds_file.parent.mkdir(mode=0o0700, parents=True) except FileExistsError: pass except OSError: log_msg = 'Error creating creds file directory "%s".' print(log_msg % str(creds_file.parent)) sys.exit(1) finally: log_msg = 'Using creds directory "%s".' logging.info(log_msg % str(creds_file.parent)) try: with creds_file.open() as f: creds.read_file(f) log_msg = 'Loaded creds file "%s".' logging.info(log_msg % str(creds_file)) except OSError: log_msg = 'Unable to read creds file "%s".' logging.info(log_msg % str(creds_file)) # figure out all login params if args.sync_url: sync_url = args.sync_url elif config.has_option('user', 'sync_url'): sync_url = config.get('user', 'sync_url') else: sync_url = OFFICIAL_SERVER_URL log_msg = 'Using sync URL "%s".' logging.info(log_msg % sync_url) if (config.has_option('user', 'username') and creds.has_section('keys') and not args.username and not args.password): username = config.get('user', 'username') keys = dict(creds.items('keys')) else: username = (args.username if args.username else input('Please enter your Standard Notes username: '******'Please enter your password (hidden): ')) # log the user in try: sn_api = StandardNotesAPI(sync_url, username) if not keys: keys = sn_api.gen_keys(password) del password keys = sn_api.sign_in(keys) log_msg = 'Successfully logged into account "%s".' logging.info(log_msg % username) login_success = True except SNAPIException as e: print(e) except ConnectionError: log_msg = 'Unable to connect to the sync server at "%s".' print(log_msg % sync_url) sys.exit(1) except MissingSchema: log_msg = 'Invalid sync server url "%s".' print(log_msg % sync_url) sys.exit(1) # write config back if good, clear if not if not args.no_config_files: try: with config_file.open(mode='w+') as f: if login_success: config.read_dict( dict(user=dict(sync_url=sync_url, username=username), )) config.remove_section('keys') config.write(f) log_msg = 'Config written to file "%s".' else: log_msg = 'Clearing config file "%s".' logging.info(log_msg % config_file) config_file.chmod(0o600) except OSError: log_msg = 'Unable to write config file "%s".' print(log_msg % str(config_file)) # write creds back if good, clear if not if not args.no_config_files: try: with creds_file.open(mode='w+') as f: if login_success: creds.read_dict(dict(keys=keys)) creds.write(f) log_msg = 'Creds written to file "%s".' else: log_msg = 'Clearing creds file "%s".' logging.info(log_msg % creds_file) creds_file.chmod(0o600) except OSError: log_msg = 'Unable to write creds file "%s".' print(log_msg % str(creds_file)) if login_success: logging.info('Starting FUSE filesystem.') try: fuse = FUSE(StandardNotesFUSE(sn_api, sync_sec, args.ext), args.mountpoint, use_ino=True, foreground=args.foreground, nothreads=True) # FUSE can't make threads, but we can except RuntimeError as e: print('Error mounting file system.') logging.info('Exiting.')