diff options
author | Damien George <damien.p.george@gmail.com> | 2016-02-09 14:28:50 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-02-10 08:59:31 +0000 |
commit | c33ad60a676d46cb18883beedd6c383d6fae9dd8 (patch) | |
tree | 2ac56735b689abc47fb435268ce1e9fdaa7d459c /extmod/fsusermount.c | |
parent | 3846fd56c150646099d530196fd6ab9a54536a24 (diff) |
extmod/fsusermount: Change block protocol to support ioctl method.
The new block protocol is:
- readblocks(self, n, buf)
- writeblocks(self, n, buf)
- ioctl(self, cmd, arg)
The new ioctl method handles the old sync and count methods, as well as
a new "get sector size" method.
The old protocol is still supported, and used if the device doesn't have
the ioctl method.
Diffstat (limited to 'extmod/fsusermount.c')
-rw-r--r-- | extmod/fsusermount.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/extmod/fsusermount.c b/extmod/fsusermount.c index 74525ef74..441711ae2 100644 --- a/extmod/fsusermount.c +++ b/extmod/fsusermount.c @@ -76,8 +76,15 @@ STATIC mp_obj_t fatfs_mount_mkfs(mp_uint_t n_args, const mp_obj_t *pos_args, mp_ // load block protocol methods mp_load_method(device, MP_QSTR_readblocks, vfs->readblocks); mp_load_method_maybe(device, MP_QSTR_writeblocks, vfs->writeblocks); - mp_load_method_maybe(device, MP_QSTR_sync, vfs->sync); - mp_load_method(device, MP_QSTR_count, vfs->count); + mp_load_method_maybe(device, MP_QSTR_ioctl, vfs->u.ioctl); + if (vfs->u.ioctl[0] != MP_OBJ_NULL) { + // device supports new block protocol, so indicate it + vfs->u.old.count[1] = MP_OBJ_SENTINEL; + } else { + // no ioctl method, so assume the device uses the old block protocol + mp_load_method_maybe(device, MP_QSTR_sync, vfs->u.old.sync); + mp_load_method(device, MP_QSTR_count, vfs->u.old.count); + } // Read-only device indicated by writeblocks[0] == MP_OBJ_NULL. // User can specify read-only device by: |