if op == 4: # BP_IOCTL_SEC_COUNT return len(self.data) // self.SEC_SIZE if op == 5: # BP_IOCTL_SEC_SIZE return self.SEC_SIZE try: bdev = RAMFS(50) bdev2 = RAMFS(50) except MemoryError: print("SKIP") raise SystemExit # 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) uos.VfsFat.mkfs(bdev) uos.mount(bdev, '/') print(uos.getcwd()) f = open('test.txt', 'w') f.write('hello') f.close() print(uos.listdir())
print(self.id, 'rename', old_path, new_path) def rmdir(self, path): print(self.id, 'rmdir', path) 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'))
def chdir(self, dir): print(self.id, 'chdir', dir) def open(self, file, mode): print(self.id, 'open', file, mode) # 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()) print(uos.listdir('/test_mnt2')) # chdir uos.chdir('test_mnt') print(uos.listdir()) # open open('test_file') open('test_file', 'wb') # umount uos.umount('/test_mnt') uos.umount('/test_mnt2')
print(b"FOO_FILETXT" in bdev.data) print(b"hello!" in bdev.data) vfs.mkdir("foo_dir") vfs.chdir("foo_dir") print("getcwd:", vfs.getcwd()) print(list(vfs.ilistdir())) with vfs.open("sub_file.txt", "w") as f: f.write("subdir file") try: vfs.chdir("sub_file.txt") except OSError as e: print(e.args[0] == uerrno.ENOENT) vfs.chdir("..") print("getcwd:", vfs.getcwd()) uos.umount(vfs) vfs = uos.VfsFat(bdev) print(list(vfs.ilistdir(b""))) # list a non-existent directory try: vfs.ilistdir(b"no_exist") except OSError as e: print('ENOENT:', e.args[0] == uerrno.ENOENT)
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 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())
uos.mkdir('dir') print(uos.listdir()) uos.mkdir('/dir2') print(uos.listdir()) uos.mkdir('dir/subdir') print(uos.listdir('dir')) for exist in ('', '/', 'dir', '/dir', 'dir/subdir'): try: uos.mkdir(exist) except OSError as er: print('mkdir OSError', er.args[0] == 17) # EEXIST uos.chdir('/') print(uos.stat('test5.txt')[:-3]) uos.VfsFat.mkfs(bdev2) uos.mount(bdev2, '/sys') print(uos.listdir()) print(uos.listdir('sys')) print(uos.listdir('/sys')) uos.rmdir('dir2') uos.remove('test5.txt') print(uos.listdir()) uos.umount('/') print(uos.getcwd()) print(uos.listdir()) print(uos.listdir('sys'))
with vfs.open("foo_file.txt", "w") as f: f.write("hello!") print(list(vfs.ilistdir())) print("stat root:", vfs.stat("/")) print("stat file:", vfs.stat("foo_file.txt")[:-3]) # timestamps differ across runs print(b"FOO_FILETXT" in bdev.data) print(b"hello!" in bdev.data) vfs.mkdir("foo_dir") vfs.chdir("foo_dir") print("getcwd:", vfs.getcwd()) print(list(vfs.ilistdir())) with vfs.open("sub_file.txt", "w") as f: f.write("subdir file") try: vfs.chdir("sub_file.txt") except OSError as e: print(e.args[0] == uerrno.ENOENT) vfs.chdir("..") print("getcwd:", vfs.getcwd()) uos.umount(vfs) vfs = uos.VfsFat(bdev) print(list(vfs.ilistdir(b"")))