예제 #1
0
            self.data[n * self.SEC_SIZE + i] = buf[i]

    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())
예제 #2
0
            self.data[n * self.SEC_SIZE + i] = buf[i]

    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())
예제 #3
0
        #print("ioctl(%d, %r)" % (op, arg))
        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(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)
예제 #4
0
        #print("ioctl(%d, %r)" % (op, arg))
        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(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)