Ejemplo n.º 1
0
    def sync(self):
        pass

    def count(self):
        return len(self.data) // self.SEC_SIZE


try:
    bdev = RAMFS_OLD(48)
except MemoryError:
    print("SKIP")
    sys.exit()

uos.vfs_mkfs(bdev, "/ramdisk")
uos.vfs_mount(bdev, "/ramdisk")

# file io
vfs = uos.VfsFat(bdev, "/ramdisk")
with vfs.open("file.txt", "w") as f:
    f.write("hello!")

print(vfs.listdir())

with vfs.open("file.txt", "r") as f:
    print(f.read())

vfs.remove("file.txt")
print(vfs.listdir())

# umount by device
Ejemplo n.º 2
0
    def sync(self):
        pass

    def count(self):
        return len(self.data) // self.SEC_SIZE


try:
    bdev = RAMFS_OLD(48)
except MemoryError:
    print("SKIP")
    sys.exit()

uos.vfs_mkfs(bdev, "/ramdisk")
uos.vfs_mount(bdev, "/ramdisk")

# file io
vfs = uos.VfsFat(bdev, "/ramdisk")
with vfs.open("file.txt", "w") as f:
    f.write("hello!")

print(vfs.listdir())

with vfs.open("file.txt", "r") as f:
    print(f.read())

vfs.remove("file.txt")
print(vfs.listdir())

# umount by device
Ejemplo n.º 3
0
try:
    bdev = RAMFS(48)
except MemoryError:
    print("SKIP")
    sys.exit()

# can't mkfs readonly device
try:
    uos.vfs_mkfs(bdev, "/ramdisk", readonly=True)
except OSError as e:
    print(e)

# mount before mkfs
try:
    uos.vfs_mount(bdev, "/ramdisk")
except OSError as e:
    print(e)

# invalid umount
try:
    uos.vfs_umount("/ramdisk")
except OSError as e:
    print(e.args[0] == uerrno.EINVAL)

try:
    uos.vfs_mount(None, "/ramdisk")
except OSError as e:
    print(e)

try:
Ejemplo n.º 4
0
try:
    bdev = RAMFS(48)
except MemoryError:
    print("SKIP")
    sys.exit()

# can't mkfs readonly device
try:
    uos.vfs_mkfs(bdev, "/ramdisk", readonly=True)
except OSError as e:
    print(e)

# mount before mkfs
try:
    uos.vfs_mount(bdev, "/ramdisk")
except OSError as e:
    print(e)

# invalid umount
try:
    uos.vfs_umount("/ramdisk")
except OSError as e:
    print(e.args[0] == uerrno.EINVAL)

try:
    uos.vfs_mount(None, "/ramdisk")
except OSError as e:
    print(e)

try: