def mount(mountpoint, file_mappings, background=True): server = DXFuse(file_mappings) llfuse.init(server, mountpoint, [ b'fsname=dxfuse', b'subtype=dnanexus', b'ro' ]) if background: daemonize('/') llfuse.main() llfuse.close()
def main(): options = parse_args() sys.stderr.write('\n' * ddrescue_pollution) sys.stderr.flush() term_up = '\x1B[A' clear_to_eol = '\x1B[K' logging.basicConfig( format='\r' + (term_up * ddrescue_pollution) + '%(asctime)-23s %(levelname)-7s %(name)s: %(message)s' + clear_to_eol + ('\n' * ddrescue_pollution)) if options.debug: logging.getLogger().setLevel(logging.DEBUG) logging.getLogger().debug('Debug logging enabled') else: logging.getLogger().setLevel(logging.INFO) fs = DDRescueFS(options) fuse_options = set(llfuse.default_options) fuse_options.add('fsname=ddrescuefs') if options.debug_fuse: fuse_options.add('debug') llfuse.init(fs, options.mountpoint, fuse_options) try: llfuse.main(workers=1) except: llfuse.close(unmount=False) raise llfuse.close()
def runTest(self): operations = fuse.Operations(os.getuid(), os.getgid()) e = operations.inodes.add_entry( fuse.ProjectDirectory(llfuse.ROOT_INODE, operations.inodes, self.api, 0, self.api.users().current().execute())) llfuse.init(operations, self.mounttmp, []) t = threading.Thread(None, lambda: llfuse.main()) t.start() # wait until the driver is finished initializing operations.initlock.wait() d1 = os.listdir(self.mounttmp) d1.sort() self.assertIn('Unrestricted public data', d1) d2 = os.listdir(os.path.join(self.mounttmp, 'Unrestricted public data')) d2.sort() self.assertEqual(['GNU General Public License, version 3'], d2) d3 = os.listdir( os.path.join(self.mounttmp, 'Unrestricted public data', 'GNU General Public License, version 3')) d3.sort() self.assertEqual(["GNU_General_Public_License,_version_3.pdf"], d3)
def main(): options = parse_args(sys.argv[1:]) init_logging(options.debug) operations = Operations(options.source) log.debug('Mounting...') fuse_options = set(llfuse.default_options) fuse_options.add('fsname=passthroughfs') fuse_options.add('default_permissions') if options.debug_fuse: fuse_options.add('debug') llfuse.init(operations, options.mountpoint, fuse_options) try: log.debug('Entering main loop..') if options.single: llfuse.main(workers=1) else: llfuse.main() except: llfuse.close(unmount=False) raise log.debug('Unmounting..') llfuse.close()
def runTest(self): operations = fuse.Operations(os.getuid(), os.getgid()) e = operations.inodes.add_entry( fuse.TagsDirectory(llfuse.ROOT_INODE, operations.inodes, self.api, 0)) llfuse.init(operations, self.mounttmp, []) t = threading.Thread(None, lambda: llfuse.main()) t.start() # wait until the driver is finished initializing operations.initlock.wait() d1 = os.listdir(self.mounttmp) d1.sort() self.assertEqual(['foo_tag'], d1) d2 = os.listdir(os.path.join(self.mounttmp, 'foo_tag')) d2.sort() self.assertEqual(['zzzzz-4zz18-fy296fx3hot09f7'], d2) d3 = os.listdir( os.path.join(self.mounttmp, 'foo_tag', 'zzzzz-4zz18-fy296fx3hot09f7')) d3.sort() self.assertEqual(['foo'], d3)
def main(): options = parse_args(sys.argv[1:]) init_logging(options.debug) operations = Operations(options.source) log.debug("Mounting...") fuse_options = set(llfuse.default_options) fuse_options.add("fsname=passthroughfs") fuse_options.add("default_permissions") if options.debug_fuse: fuse_options.add("debug") llfuse.init(operations, options.mountpoint, fuse_options) try: log.debug("Entering main loop..") if options.single: llfuse.main(workers=1) else: llfuse.main() except: llfuse.close(unmount=False) raise log.debug("Unmounting..") llfuse.close()
def _vt_runfuse(self, mnt, fsname=None): ''' Run the filesystem once. Return a Thread managing the mount. ''' fs = self._vtfs S = fs.S if fsname is None: fsname = str(S) # llfuse reads additional mount options from the fsname :-( fsname = fsname.replace(',', ':') with S: opts = set(self._vt_llf_opts) opts.add("fsname=" + fsname) ##opts.add('noappledouble') llfuse.init(self, mnt, opts) # record the full path to the mount point # this is used to support '..' at the top of the tree fs.mnt_path = abspath(mnt) @logexc def mainloop(): ''' Worker main loop to run the filesystem then tidy up. ''' with stackattrs(defaults, fs=fs): with S: with defaults.common_S(S): llfuse.main(workers=32) llfuse.close() S.close() T = PfxThread(target=mainloop) S.open() T.start() return T
def mount(operations, mountpoint, options=None, *, override_default_options=False, workers=30): """Mount a file system. Args ---- operations: `~.Operations` The operations handler for the file system. mountpoint: str The directory on which the file system should be mounted. options: set A set of options that should be used when mounting. override_default_options: bool If this is set to `True` only the supplied options will be used. Otherwise the options will be added to the defaults. The defaults are the defaults supplied by `llfuse.default_options`. workers: int The amount of worker threads that should be spawned to handle the file operations. """ operations.mountpoint = os.path.abspath(mountpoint) if options is None: options = llfuse.default_options elif not override_default_options: options |= llfuse.default_options llfuse.init(operations, mountpoint, options) try: llfuse.main(workers=workers) finally: llfuse.close()
def runTest(self): # Create the request handler operations = fuse.Operations(os.getuid(), os.getgid()) e = operations.inodes.add_entry(fuse.MagicDirectory(llfuse.ROOT_INODE, operations.inodes)) self.mounttmp = tempfile.mkdtemp() llfuse.init(operations, self.mounttmp, []) t = threading.Thread(None, lambda: llfuse.main()) t.start() # wait until the driver is finished initializing operations.initlock.wait() # now check some stuff d1 = os.listdir(self.mounttmp) d1.sort() self.assertEqual([], d1) d2 = os.listdir(os.path.join(self.mounttmp, self.testcollection)) d2.sort() self.assertEqual(['thing1.txt'], d2) d3 = os.listdir(self.mounttmp) d3.sort() self.assertEqual([self.testcollection], d3) files = {} files[os.path.join(self.mounttmp, self.testcollection, 'thing1.txt')] = 'data 1' for k, v in files.items(): with open(os.path.join(self.mounttmp, k)) as f: self.assertEqual(v, f.read())
def runTest(self): # Create the request handler operations = fuse.Operations(os.getuid(), os.getgid()) e = operations.inodes.add_entry( fuse.MagicDirectory(llfuse.ROOT_INODE, operations.inodes)) self.mounttmp = tempfile.mkdtemp() llfuse.init(operations, self.mounttmp, []) t = threading.Thread(None, lambda: llfuse.main()) t.start() # wait until the driver is finished initializing operations.initlock.wait() # now check some stuff d1 = os.listdir(self.mounttmp) d1.sort() self.assertEqual(d1, []) d2 = os.listdir(os.path.join(self.mounttmp, self.testcollection)) d2.sort() self.assertEqual(d2, ['thing1.txt']) d3 = os.listdir(self.mounttmp) d3.sort() self.assertEqual(d3, [self.testcollection]) files = {} files[os.path.join(self.mounttmp, self.testcollection, 'thing1.txt')] = 'data 1' for k, v in files.items(): with open(os.path.join(self.mounttmp, k)) as f: self.assertEqual(f.read(), v)
def runTest(self): run_test_server.authorize_with("admin") api = arvados.api('v1', cache=False) operations = fuse.Operations(os.getuid(), os.getgid()) e = operations.inodes.add_entry(fuse.TagsDirectory(llfuse.ROOT_INODE, operations.inodes, api)) llfuse.init(operations, self.mounttmp, []) t = threading.Thread(None, lambda: llfuse.main()) t.start() # wait until the driver is finished initializing operations.initlock.wait() d1 = os.listdir(self.mounttmp) d1.sort() self.assertEqual(['foo_tag'], d1) d2 = os.listdir(os.path.join(self.mounttmp, 'foo_tag')) d2.sort() self.assertEqual(['1f4b0bc7583c2a7f9102c395f4ffc5e3+45'], d2) d3 = os.listdir(os.path.join(self.mounttmp, 'foo_tag', '1f4b0bc7583c2a7f9102c395f4ffc5e3+45')) d3.sort() self.assertEqual(['foo'], d3) files = {} files[os.path.join(self.mounttmp, 'foo_tag', '1f4b0bc7583c2a7f9102c395f4ffc5e3+45', 'foo')] = 'foo' for k, v in files.items(): with open(os.path.join(self.mounttmp, k)) as f: self.assertEqual(v, f.read())
def mount(self, mountpoint, mount_options, foreground=False): """Mount filesystem on *mountpoint* with *mount_options*.""" options = ['fsname=borgfs', 'ro'] if mount_options: options.extend(mount_options.split(',')) try: options.remove('allow_damaged_files') self.allow_damaged_files = True except ValueError: pass try: options.remove('versions') self.versions = True except ValueError: pass self._create_filesystem() llfuse.init(self, mountpoint, options) if not foreground: daemonize() # If the file system crashes, we do not want to umount because in that # case the mountpoint suddenly appears to become empty. This can have # nasty consequences, imagine the user has e.g. an active rsync mirror # job - seeing the mountpoint empty, rsync would delete everything in the # mirror. umount = False try: signal = fuse_main() # no crash and no signal (or it's ^C and we're in the foreground) -> umount request umount = (signal is None or (signal == SIGINT and foreground)) finally: llfuse.close(umount)
def mount(self, mountpoint, mount_options, foreground=False): """Mount filesystem on *mountpoint* with *mount_options*.""" options = ['fsname=borgfs', 'ro'] if mount_options: options.extend(mount_options.split(',')) try: options.remove('allow_damaged_files') self.allow_damaged_files = True except ValueError: pass try: options.remove('versions') self.versions = True except ValueError: pass self._create_filesystem() llfuse.init(self, mountpoint, options) if not foreground: daemonize() # If the file system crashes, we do not want to umount because in that # case the mountpoint suddenly appears to become empty. This can have # nasty consequences, imagine the user has e.g. an active rsync mirror # job - seeing the mountpoint empty, rsync would delete everything in the # mirror. umount = False try: signal = fuse_main() umount = (signal is None) # no crash and no signal -> umount request finally: llfuse.close(umount)
def main(): options = parse_args(sys.argv[1:]) init_logging(options.debug) operations = Operations(options.source, { "jquery.min.js": b"/usr/share/javascript/jquery/jquery.min.js" }) log.debug('Mounting...') fuse_options = set(llfuse.default_options) fuse_options.add('fsname=passthroughfs') fuse_options.add('default_permissions') if options.debug_fuse: fuse_options.add('debug') llfuse.init(operations, options.mountpoint, fuse_options) try: log.debug('Entering main loop..') if options.single: llfuse.main(workers=1) else: llfuse.main() except: llfuse.close(unmount=False) raise log.debug('Unmounting..') llfuse.close()
def __enter__(self): llfuse.init(self.operations, self.args.mountpoint, self._fuse_options()) if self.listen_for_events: self.operations.listen_for_events() self.llfuse_thread = threading.Thread(None, lambda: self._llfuse_main()) self.llfuse_thread.daemon = True self.llfuse_thread.start() self.operations.initlock.wait()
def make_mount(self, root_class, **root_kwargs): operations = fuse.Operations(os.getuid(), os.getgid()) operations.inodes.add_entry(root_class( llfuse.ROOT_INODE, operations.inodes, self.api, 0, **root_kwargs)) llfuse.init(operations, self.mounttmp, []) threading.Thread(None, llfuse.main).start() # wait until the driver is finished initializing operations.initlock.wait()
def mount(mountpoint, file_mappings, background=True): server = DXFuse(file_mappings) llfuse.init(server, mountpoint, [b'fsname=dxfuse', b'subtype=dnanexus', b'ro']) if background: daemonize('/') llfuse.main() llfuse.close()
def run_fuse_mount(ops, options, mount_opts): mount_opts = ['fsname=gridfs_fuse'] + mount_opts llfuse.init(ops, options.mount_point, mount_opts) try: llfuse.main(single=True) finally: llfuse.close()
def run_fs(mountpoint, cross_process): testfs = Fs(cross_process) fuse_options = set(llfuse.default_options) fuse_options.add('fsname=llfuse_testfs') llfuse.init(testfs, mountpoint, fuse_options) try: llfuse.main(workers=1) finally: llfuse.close()
def _llfuse_worker(self, fs, mountpoint, init_event): fuse_options = set(llfuse.default_options) fuse_options.add('fsname=marty') llfuse.init(fs, mountpoint, fuse_options) init_event.set() try: llfuse.main(workers=1) finally: llfuse.close()
def __enter__(self): llfuse.init(self.operations, self.args.mountpoint, self._fuse_options()) if self.listen_for_events and not self.args.disable_event_listening: self.operations.listen_for_events() self.llfuse_thread = threading.Thread(None, lambda: self._llfuse_main()) self.llfuse_thread.daemon = True self.llfuse_thread.start() self.operations.initlock.wait() return self
def main(): ops = TestOperations() fuse_options = set(llfuse.default_options) fuse_options.add('fsname=test_fs') fuse_options.discard('nonempty') fuse_options.add('max_read=60000') # fuse_options.add('debug') llfuse.init(ops, MOUNTPOINT, fuse_options) r = llfuse.main() if r is None: llfuse.close()
def mount(self, mountpoint, extra_options, foreground=False): options = ['fsname=borgfs', 'ro'] if extra_options: options.extend(extra_options.split(',')) llfuse.init(self, mountpoint, options) if not foreground: daemonize() try: llfuse.main(single=True) finally: llfuse.close()
def runRealTest(self): run_test_server.authorize_with("admin") api = arvados.api('v1', cache=False) operations = fuse.Operations(os.getuid(), os.getgid()) e = operations.inodes.add_entry(fuse.TagsDirectory(llfuse.ROOT_INODE, operations.inodes, api, poll_time=1)) llfuse.init(operations, self.mounttmp, []) t = threading.Thread(None, lambda: llfuse.main()) t.start() # wait until the driver is finished initializing operations.initlock.wait() d1 = os.listdir(self.mounttmp) d1.sort() self.assertEqual(['foo_tag'], d1) api.links().create(body={'link': { 'head_uuid': 'fa7aeb5140e2848d39b416daeef4ffc5+45', 'link_class': 'tag', 'name': 'bar_tag' }}).execute() time.sleep(1) d2 = os.listdir(self.mounttmp) d2.sort() self.assertEqual(['bar_tag', 'foo_tag'], d2) d3 = os.listdir(os.path.join(self.mounttmp, 'bar_tag')) d3.sort() self.assertEqual(['fa7aeb5140e2848d39b416daeef4ffc5+45'], d3) l = api.links().create(body={'link': { 'head_uuid': 'ea10d51bcf88862dbcc36eb292017dfd+45', 'link_class': 'tag', 'name': 'bar_tag' }}).execute() time.sleep(1) d4 = os.listdir(os.path.join(self.mounttmp, 'bar_tag')) d4.sort() self.assertEqual(['ea10d51bcf88862dbcc36eb292017dfd+45', 'fa7aeb5140e2848d39b416daeef4ffc5+45'], d4) api.links().delete(uuid=l['uuid']).execute() time.sleep(1) d5 = os.listdir(os.path.join(self.mounttmp, 'bar_tag')) d5.sort() self.assertEqual(['fa7aeb5140e2848d39b416daeef4ffc5+45'], d5)
def make_mount(self, root_class, **root_kwargs): self.operations = fuse.Operations(os.getuid(), os.getgid(), enable_write=True) self.operations.inodes.add_entry( root_class(llfuse.ROOT_INODE, self.operations.inodes, self.api, 0, **root_kwargs)) llfuse.init(self.operations, self.mounttmp, []) threading.Thread(None, llfuse.main).start() # wait until the driver is finished initializing self.operations.initlock.wait() return self.operations.inodes[llfuse.ROOT_INODE]
def __init__(self, rootpath): MOUNT_POINT = "/tmp/mountpoint" ops = FuseOperations(rootpath) fuse_options = set(llfuse.default_options) fuse_options.add("fsname=testfs") fuse_options.discard("default_permissions") j.sal.fs.createDir(MOUNT_POINT) llfuse.init(ops, MOUNT_POINT, fuse_options) try: llfuse.main(workers=1) except BaseException: llfuse.close(unmount=False) raise llfuse.close()
def make_mount(self, root_class, **root_kwargs): self.operations = fuse.Operations( os.getuid(), os.getgid(), api_client=self.api, enable_write=True) self.operations.inodes.add_entry(root_class( llfuse.ROOT_INODE, self.operations.inodes, self.api, 0, **root_kwargs)) llfuse.init(self.operations, self.mounttmp, []) self.llfuse_thread = threading.Thread(None, lambda: self._llfuse_main()) self.llfuse_thread.daemon = True self.llfuse_thread.start() # wait until the driver is finished initializing self.operations.initlock.wait() return self.operations.inodes[llfuse.ROOT_INODE]
def run(): fs = Lisk() fw = FileWorker() llfuse.init(fs, "/home/heidar/fs", [b"fsname=lisk", b"nonempty"]) print "here" print llfuse.ROOT_INODE fw.start() try: llfuse.main(single=True) except: llfuse.close() raise llfuse.close()
def mount(self, log=True): self.init_logging(log) fs = zfsfuse(self.dataset) fuse_options = set(llfuse.default_options) fuse_options.add('fsname=zfsrescue') #fuse_options.add('debug') llfuse.init(fs, self.mountpoint, fuse_options) try: llfuse.main(workers=1) except Exception as e: print(str(e)) llfuse.close(unmount=False) raise e llfuse.close()
def run_fuse_mount(self): self.mountdir = tempfile.mkdtemp() self.operations = Operations(os.getuid(), os.getgid(), "utf-8") self.cdir = CollectionDirectory(llfuse.ROOT_INODE, self.operations.inodes, self.api, 2, self.collection) self.operations.inodes.add_entry(self.cdir) # Initialize the fuse connection llfuse.init(self.operations, self.mountdir, ['allow_other']) t = threading.Thread(None, llfuse.main) t.start() # wait until the driver is finished initializing self.operations.initlock.wait()
def run(self, debug=False): # Setup our fuse interaction, but don't process requests yet. opts = ['fsname=thingfs', 'nonempty'] if debug: opts.append('debug') llfuse.init(self, self.mount_path, opts) self.ready_ = True try: llfuse.main(workers=1) except: llfuse.close(unmount=False) raise llfuse.close()
def main(): options = parse_args() init_logging(options.debug) testfs = TestFs() fuse_options = set(llfuse.default_options) fuse_options.add('fsname=lltest') llfuse.init(testfs, options.mountpoint, fuse_options) try: llfuse.main(single=True) except: llfuse.close(unmount=False) raise llfuse.close()
def runTest(self): operations = fuse.Operations(os.getuid(), os.getgid()) e = operations.inodes.add_entry( fuse.SharedDirectory(llfuse.ROOT_INODE, operations.inodes, self.api, 0, self.api.users().current().execute()['uuid'])) llfuse.init(operations, self.mounttmp, []) t = threading.Thread(None, lambda: llfuse.main()) t.start() # wait until the driver is finished initializing operations.initlock.wait() d1 = os.listdir(self.mounttmp) d1.sort() self.assertIn('Active User', d1) d2 = os.listdir(os.path.join(self.mounttmp, 'Active User')) d2.sort() self.assertEqual([ 'A Project', "Empty collection", "Empty collection.link", "Pipeline Template with Input Parameter with Search.pipelineTemplate", "Pipeline Template with Jobspec Components.pipelineTemplate", "collection_expires_in_future", "collection_with_same_name_in_aproject_and_home_project", "owned_by_active", "pipeline_to_merge_params.pipelineInstance", "pipeline_with_job.pipelineInstance", "pipeline_with_tagged_collection_input.pipelineInstance", "real_log_collection" ], d2) d3 = os.listdir(os.path.join(self.mounttmp, 'Active User', 'A Project')) d3.sort() self.assertEqual([ "A Subproject", "Two Part Pipeline Template.pipelineTemplate", "collection_to_move_around", "collection_with_same_name_in_aproject_and_home_project", "zzzzz-4zz18-fy296fx3hot09f7 added sometime" ], d3) with open( os.path.join( self.mounttmp, 'Active User', "A Project", "Two Part Pipeline Template.pipelineTemplate")) as f: j = json.load(f) self.assertEqual("Two Part Pipeline Template", j['name'])
def runTest(self): # Create the request handler operations = fuse.Operations(os.getuid(), os.getgid()) e = operations.inodes.add_entry(fuse.Directory(llfuse.ROOT_INODE)) operations.inodes.load_collection( e, arvados.CollectionReader(arvados.Keep.get(self.testcollection))) self.mounttmp = tempfile.mkdtemp() llfuse.init(operations, self.mounttmp, []) t = threading.Thread(None, lambda: llfuse.main()) t.start() # wait until the driver is finished initializing operations.initlock.wait() # now check some stuff d1 = os.listdir(self.mounttmp) d1.sort() self.assertEqual(d1, ['dir1', 'dir2', 'thing1.txt', 'thing2.txt']) d2 = os.listdir(os.path.join(self.mounttmp, 'dir1')) d2.sort() self.assertEqual(d2, ['thing3.txt', 'thing4.txt']) d3 = os.listdir(os.path.join(self.mounttmp, 'dir2')) d3.sort() self.assertEqual(d3, ['dir3', 'thing5.txt', 'thing6.txt']) d4 = os.listdir(os.path.join(self.mounttmp, 'dir2/dir3')) d4.sort() self.assertEqual(d4, ['thing7.txt', 'thing8.txt']) files = { 'thing1.txt': 'data 1', 'thing2.txt': 'data 2', 'dir1/thing3.txt': 'data 3', 'dir1/thing4.txt': 'data 4', 'dir2/thing5.txt': 'data 5', 'dir2/thing6.txt': 'data 6', 'dir2/dir3/thing7.txt': 'data 7', 'dir2/dir3/thing8.txt': 'data 8' } for k, v in files.items(): with open(os.path.join(self.mounttmp, k)) as f: self.assertEqual(f.read(), v)
def mount(self,stream,mountpt,foreground=False,debug=False): mountpt = os.path.abspath(mountpt) ops = Operations(stream,self) args = ['fsname=u4pak', 'subtype=u4pak', 'ro'] if debug: foreground = True args.append('debug') if not foreground: deamonize() llfuse.init(ops, mountpt, args) try: llfuse.main() finally: llfuse.close()
def mount(self,stream,mountpt,foreground=False,debug=False): mountpt = os.path.abspath(mountpt) ops = Operations(stream,self) args = ['fsname=u4pak', 'subtype=u4pak', 'ro'] if debug: foreground = True args.append('debug') if not foreground: deamonize() llfuse.init(ops, mountpt, args) try: llfuse.main(single=False) finally: llfuse.close()
def main(): options = parse_args() init_logging(options.debug) testfs = JsonSysClassFS(TestJscfsMethods.test_json_str) fuse_options = set(llfuse.default_options) fuse_options.add('fsname=jscfs') if options.debug_fuse: fuse_options.add('debug') llfuse.init(testfs, options.mountpoint, fuse_options) try: llfuse.main(workers=1) except: llfuse.close(unmount=False) raise llfuse.close()
def main(): options = parse_args() init_logging(options.debug) testfs = TestFs() fuse_options = set(llfuse.default_options) fuse_options.add('fsname=lltest') if options.debug_fuse: fuse_options.add('debug') llfuse.init(testfs, options.mountpoint, fuse_options) try: llfuse.main(workers=1) except: llfuse.close(unmount=False) raise llfuse.close()
def main(): options = parse_args() init_logging(options.debug) remotefs = RemoteFileFS(options.base_url, options.block_size) fuse_options = set(llfuse.default_options) fuse_options.add('fsname=Tiler.filesystem') if options.debug_fuse: fuse_options.add('debug') llfuse.init(remotefs, options.mountpoint, fuse_options) try: llfuse.main(workers=1) except: llfuse.close(unmount=False) raise llfuse.close()
def main(): global deley_time options = parse_args(sys.argv[1:]) init_logging(options.debug) print("\nMounting Image {} -to-> {} and version period is {}..\n".format( options.image, options.mountpoint, options.time)) file = open(options.image, "rb") try: loaded_data = pickle.load(file) try: inodestruct.r_inode = loaded_data[0] pp.pprint(inodestruct.r_inode.slot) except: print("fail to load inodestruct.r_inode") try: inodestruct.datablockT = loaded_data[1] pp.pprint(inodestruct.datablockT.slot) except: print("fail to load inodestruct.datablockT") except: print("empty image") file.close() deley_time = int(options.time) print(deley_time) testfs = Vcowfs() fuse_options = set(llfuse.default_options) fuse_options.add('fsname=vcowfs') fuse_options.discard('default_permissions') if options.debug_fuse: fuse_options.add('debug') llfuse.init(testfs, options.mountpoint, fuse_options) try: llfuse.main(workers=1) except: llfuse.close(unmount=False) raise file = open(options.image, "wb") print("Saving Complete XD XD XD XD XD XD") print(inodestruct.r_inode) print(inodestruct.datablockT) pickler = pickle.Pickler(file, -1) pickler.dump([inodestruct.r_inode, inodestruct.datablockT]) file.close() llfuse.close()
def main(): options = parse_args(sys.argv[1:]) init_logging(options.debug) operations = Operations(options.source) log.debug('Mounting...') llfuse.init(operations, options.mountpoint, [ b'fsname=passthroughfs', b"nonempty" ]) try: log.debug('Entering main loop..') llfuse.main(options.single) except: llfuse.close(unmount=False) raise log.debug('Unmounting..') llfuse.close()
def __enter__(self): if self.args.replace: unmount(path=self.args.mountpoint, timeout=self.args.unmount_timeout) llfuse.init(self.operations, self.args.mountpoint, self._fuse_options()) if self.daemon: daemon.DaemonContext( working_directory=os.path.dirname(self.args.mountpoint), files_preserve=range( 3, resource.getrlimit(resource.RLIMIT_NOFILE)[1]) ).open() if self.listen_for_events and not self.args.disable_event_listening: self.operations.listen_for_events() self.llfuse_thread = threading.Thread(None, lambda: self._llfuse_main()) self.llfuse_thread.daemon = True self.llfuse_thread.start() self.operations.initlock.wait() return self
def mount(archive, mountpt, foreground=False, debug=False): archive = os.path.abspath(archive) mountpt = os.path.abspath(mountpt) with open(archive, "rb") as fp: ops = Operations(fp) args = ['fsname=bf64', 'subtype=bf64', 'ro'] if debug: foreground = True args.append('debug') if not foreground: deamonize() llfuse.init(ops, mountpt, args) try: llfuse.main() finally: llfuse.close()
def mount(self, mountpoint, extra_options, foreground=False): options = ['fsname=borgfs', 'ro'] if extra_options: options.extend(extra_options.split(',')) llfuse.init(self, mountpoint, options) if not foreground: daemonize() # If the file system crashes, we do not want to umount because in that # case the mountpoint suddenly appears to become empty. This can have # nasty consequences, imagine the user has e.g. an active rsync mirror # job - seeing the mountpoint empty, rsync would delete everything in the # mirror. umount = False try: signal = fuse_main() umount = (signal is None) # no crash and no signal -> umount request finally: llfuse.close(umount)
def mount(archive, mountpt, foreground=False, debug=False): archive = os.path.abspath(archive) mountpt = os.path.abspath(mountpt) with open(archive, "rb") as fp: ops = Operations(fp) args = ['fsname=psypkg', 'subtype=psypkg', 'ro'] if debug: foreground = True args.append('debug') if not foreground: deamonize() llfuse.init(ops, mountpt, args) try: llfuse.main(single=False) finally: llfuse.close()
def make_mount(self, root_class, **root_kwargs): enable_write = True if 'enable_write' in root_kwargs: enable_write = root_kwargs.pop('enable_write') self.operations = fuse.Operations(os.getuid(), os.getgid(), api_client=self.api, enable_write=enable_write) self.operations.inodes.add_entry( root_class(llfuse.ROOT_INODE, self.operations.inodes, self.api, 0, enable_write, **root_kwargs)) llfuse.init(self.operations, self.mounttmp, []) self.llfuse_thread = threading.Thread(None, lambda: self._llfuse_main()) self.llfuse_thread.daemon = True self.llfuse_thread.start() # wait until the driver is finished initializing self.operations.initlock.wait() return self.operations.inodes[llfuse.ROOT_INODE]
def setup(args, config, db): from .util import noop_context_manager bithorde = Client(parseConfig(config.items('BITHORDE'))) # fsopts = set(llfuse.default_options()) fsopts = ['nonempty', 'allow_other', 'max_read=262144', 'fsname=bhindex'] if args.fs_debug: fsopts.append('debug') ops = Operations(database=db, bithorde=bithorde) llfuse.init(ops, args.mountpoint, fsopts) if args.scan: scanner = Thread(target=background_scan, args=(args, config, bithorde)) scanner.setDaemon(True) else: scanner = None return noop_context_manager(), (scanner,)
def mount(archive,mountpt,ext_func=lambda data,offset,size:'',foreground=False,debug=False): archive = os.path.abspath(archive) mountpt = os.path.abspath(mountpt) with open(archive,"rb") as fp: ops = Operations(fp,ext_func) args = ['fsname=fezpak', 'subtype=fezpak', 'ro'] if debug: foreground = True args.append('debug') if not foreground: deamonize() llfuse.init(ops, mountpt, args) try: llfuse.main() finally: llfuse.close()
def runTest(self): operations = fuse.Operations(os.getuid(), os.getgid()) e = operations.inodes.add_entry(fuse.SharedDirectory(llfuse.ROOT_INODE, operations.inodes, self.api, 0, self.api.users().current().execute()['uuid'])) llfuse.init(operations, self.mounttmp, []) t = threading.Thread(None, lambda: llfuse.main()) t.start() # wait until the driver is finished initializing operations.initlock.wait() d1 = os.listdir(self.mounttmp) d1.sort() self.assertIn('Active User', d1) d2 = os.listdir(os.path.join(self.mounttmp, 'Active User')) d2.sort() self.assertEqual(['A Project', "Empty collection", "Empty collection.link", "Pipeline Template with Input Parameter with Search.pipelineTemplate", "Pipeline Template with Jobspec Components.pipelineTemplate", "collection_expires_in_future", "collection_with_same_name_in_aproject_and_home_project", "owned_by_active", "pipeline_to_merge_params.pipelineInstance", "pipeline_with_job.pipelineInstance", "pipeline_with_tagged_collection_input.pipelineInstance", "real_log_collection" ], d2) d3 = os.listdir(os.path.join(self.mounttmp, 'Active User', 'A Project')) d3.sort() self.assertEqual(["A Subproject", "Two Part Pipeline Template.pipelineTemplate", "collection_to_move_around", "collection_with_same_name_in_aproject_and_home_project", "zzzzz-4zz18-fy296fx3hot09f7 added sometime" ], d3) with open(os.path.join(self.mounttmp, 'Active User', "A Project", "Two Part Pipeline Template.pipelineTemplate")) as f: j = json.load(f) self.assertEqual("Two Part Pipeline Template", j['name'])
def _run_standalone(self): try: llfuse.init(self.operations, self.args.mountpoint, self._fuse_options()) if not self.args.foreground: self.daemon_ctx = daemon.DaemonContext( working_directory=os.path.dirname(self.args.mountpoint), files_preserve=range( 3, resource.getrlimit(resource.RLIMIT_NOFILE)[1])) self.daemon_ctx.open() # Subscribe to change events from API server if self.listen_for_events: self.operations.listen_for_events() self._llfuse_main() except Exception as e: self.logger.exception('arv-mount: exception during mount: %s', e) exit(getattr(e, 'errno', 1)) exit(0)
def main(self): self.preInit() self._checkNotUnmounted() self.setupSignals() error = False ex = None try: fuse.init(self.operations, self.mountpoint, self._opts) fuse.main(single=True) except Exception as e: error = True ex = e self.getLogger().error(traceback.format_exc()) self.onSignalUmount(error=error) if ex: raise ex
def main(): options = parse_args(sys.argv[1:]) init_logging(options.debug) operations = Operations(options.source) log.debug('Mounting...') fuse_options = set(llfuse.default_options) fuse_options.add('fsname=passthroughfs') fuse_options.add('default_permissions') llfuse.init(operations, options.mountpoint, fuse_options) try: log.debug('Entering main loop..') llfuse.main(options.single) except: llfuse.close(unmount=False) raise log.debug('Unmounting..') llfuse.close()
def runTest(self): # Create the request handler operations = fuse.Operations(os.getuid(), os.getgid()) e = operations.inodes.add_entry(fuse.CollectionDirectory(llfuse.ROOT_INODE, operations.inodes, self.testcollection)) llfuse.init(operations, self.mounttmp, []) t = threading.Thread(None, lambda: llfuse.main()) t.start() # wait until the driver is finished initializing operations.initlock.wait() # now check some stuff d1 = os.listdir(self.mounttmp) d1.sort() self.assertEqual(['dir1', 'dir2', 'thing1.txt', 'thing2.txt'], d1) d2 = os.listdir(os.path.join(self.mounttmp, 'dir1')) d2.sort() self.assertEqual(['thing3.txt', 'thing4.txt'], d2) d3 = os.listdir(os.path.join(self.mounttmp, 'dir2')) d3.sort() self.assertEqual(['dir3', 'thing5.txt', 'thing6.txt'], d3) d4 = os.listdir(os.path.join(self.mounttmp, 'dir2/dir3')) d4.sort() self.assertEqual(['thing7.txt', 'thing8.txt'], d4) files = {'thing1.txt': 'data 1', 'thing2.txt': 'data 2', 'dir1/thing3.txt': 'data 3', 'dir1/thing4.txt': 'data 4', 'dir2/thing5.txt': 'data 5', 'dir2/thing6.txt': 'data 6', 'dir2/dir3/thing7.txt': 'data 7', 'dir2/dir3/thing8.txt': 'data 8'} for k, v in files.items(): with open(os.path.join(self.mounttmp, k)) as f: self.assertEqual(v, f.read())
def run_fs(mountpoint, cross_process): # Logging (note that we run in a new process, so we can't # rely on direct log capture and instead print to stdout) root_logger = logging.getLogger() formatter = logging.Formatter('%(asctime)s.%(msecs)03d %(levelname)s ' '%(funcName)s(%(threadName)s): %(message)s', datefmt="%M:%S") handler = logging.StreamHandler(sys.stdout) handler.setLevel(logging.DEBUG) handler.setFormatter(formatter) root_logger.addHandler(handler) root_logger.setLevel(logging.DEBUG) testfs = Fs(cross_process) fuse_options = set(llfuse.default_options) fuse_options.add('fsname=llfuse_testfs') llfuse.init(testfs, mountpoint, fuse_options) try: llfuse.main(workers=1) finally: llfuse.close()