def stat(self, path): print(self.id, 'stat', path) return (self.id,) def statvfs(self, path): print(self.id, 'statvfs', path) return (self.id,) def open(self, file, mode): print(self.id, 'open', file, mode) # first we umount any existing mount points the target may have for path in uos.listdir('/'): uos.umount('/' + path) # stat root dir print(uos.stat('/')) # getcwd when in root dir print(uos.getcwd()) # basic mounting and listdir uos.mount(Filesystem(1), '/test_mnt') print(uos.listdir()) # referencing the mount point in different ways print(uos.listdir('test_mnt')) print(uos.listdir('/test_mnt')) # mounting another filesystem uos.mount(Filesystem(2), '/test_mnt2', readonly=True) print(uos.listdir())
return (self.id, ) def open(self, file, mode): print(self.id, 'open', file, mode) # first we umount any existing mount points the target may have try: uos.umount('/') except OSError: pass for path in uos.listdir('/'): uos.umount('/' + path) # stat root dir print(uos.stat('/')) # getcwd when in root dir print(uos.getcwd()) # basic mounting and listdir uos.mount(Filesystem(1), '/test_mnt') print(uos.listdir()) # ilistdir i = uos.ilistdir() print(next(i)) try: next(i) except StopIteration: print('StopIteration')
pass for path in uos.listdir('/'): uos.umount('/' + path) uos.VfsFat.mkfs(bdev) uos.mount(bdev, '/') print(uos.getcwd()) f = open('test.txt', 'w') f.write('hello') f.close() print(uos.listdir()) print(uos.listdir('/')) print(uos.stat('')[:-3]) print(uos.stat('/')[:-3]) print(uos.stat('test.txt')[:-3]) print(uos.stat('/test.txt')[:-3]) f = open('/test.txt') print(f.read()) f.close() uos.rename('test.txt', 'test2.txt') print(uos.listdir()) uos.rename('test2.txt', '/test3.txt') print(uos.listdir()) uos.rename('/test3.txt', 'test4.txt') print(uos.listdir()) uos.rename('/test4.txt', '/test5.txt')