Skip to content

Commit 9fdac91

Browse files
committed
tests/vfs_fat_ramdisk: Allow to override sector size.
1 parent 9d05251 commit 9fdac91

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

tests/extmod/vfs_fat_ramdisk.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,28 @@
88

99

1010
class RAMFS:
11+
12+
SEC_SIZE = 512
13+
1114
def __init__(self, blocks):
12-
self.data = bytearray(blocks * 512)
15+
self.data = bytearray(blocks * self.SEC_SIZE)
1316

1417
def readblocks(self, n, buf):
1518
#print("readblocks(%s, %x(%d))" % (n, id(buf), len(buf)))
1619
for i in range(len(buf)):
17-
buf[i] = self.data[n*512+i]
20+
buf[i] = self.data[n * self.SEC_SIZE + i]
1821

1922
def writeblocks(self, n, buf):
2023
#print("writeblocks(%s, %x)" % (n, id(buf)))
2124
for i in range(len(buf)):
22-
self.data[n*512+i] = buf[i]
25+
self.data[n * self.SEC_SIZE + i] = buf[i]
2326

2427
def ioctl(self, op, arg):
2528
#print("ioctl(%d, %r)" % (op, arg))
2629
if op == 4: # BP_IOCTL_SEC_COUNT
27-
return len(self.data) // 512
30+
return len(self.data) // self.SEC_SIZE
31+
if op == 5: # BP_IOCTL_SEC_SIZE
32+
return self.SEC_SIZE
2833

2934

3035
bdev = RAMFS(48)

0 commit comments

Comments
 (0)