From 9fdac9144d08d62aa23869c3c55eb4cc7a724703 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 14 Feb 2016 20:52:38 +0200 Subject: [PATCH] tests/vfs_fat_ramdisk: Allow to override sector size. --- tests/extmod/vfs_fat_ramdisk.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/extmod/vfs_fat_ramdisk.py b/tests/extmod/vfs_fat_ramdisk.py index 919117a9ce..f122e4f961 100644 --- a/tests/extmod/vfs_fat_ramdisk.py +++ b/tests/extmod/vfs_fat_ramdisk.py @@ -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)