tests/vfs_fat_ramdisk: Allow to override sector size.
This commit is contained in:
parent
9d0525182d
commit
9fdac9144d
@ -8,23 +8,28 @@ except AttributeError:
|
||||
|
||||
|
||||
class RAMFS:
|
||||
|
||||
SEC_SIZE = 512
|
||||
|
||||
def __init__(self, blocks):
|
||||
self.data = bytearray(blocks * 512)
|
||||
self.data = bytearray(blocks * self.SEC_SIZE)
|
||||
|
||||
def readblocks(self, n, buf):
|
||||
#print("readblocks(%s, %x(%d))" % (n, id(buf), len(buf)))
|
||||
for i in range(len(buf)):
|
||||
buf[i] = self.data[n*512+i]
|
||||
buf[i] = self.data[n * self.SEC_SIZE + i]
|
||||
|
||||
def writeblocks(self, n, buf):
|
||||
#print("writeblocks(%s, %x)" % (n, id(buf)))
|
||||
for i in range(len(buf)):
|
||||
self.data[n*512+i] = buf[i]
|
||||
self.data[n * self.SEC_SIZE + i] = buf[i]
|
||||
|
||||
def ioctl(self, op, arg):
|
||||
#print("ioctl(%d, %r)" % (op, arg))
|
||||
if op == 4: # BP_IOCTL_SEC_COUNT
|
||||
return len(self.data) // 512
|
||||
return len(self.data) // self.SEC_SIZE
|
||||
if op == 5: # BP_IOCTL_SEC_SIZE
|
||||
return self.SEC_SIZE
|
||||
|
||||
|
||||
bdev = RAMFS(48)
|
||||
|
Loading…
Reference in New Issue
Block a user