示例#1
0
    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())
print(uos.listdir('/test_mnt2'))

# mounting over an existing mount point
示例#2
0
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(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()