summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2018-03-27 19:51:48 -0700
committerGitHub <noreply@github.com>2018-03-27 19:51:48 -0700
commit6711c5c90d497ce68ea1df249d36b32bdf2f4c6c (patch)
treee4457f190841f25ab8954a057dcd8ce3ff8b4d10 /shared-bindings
parent1eba5804434a8acc182c23aadf5b5a5dcbe901fa (diff)
parent34f5498760452e30cb9b76e43f5ec65f36936376 (diff)
Merge pull request #712 from jepler/fslabel
Add ability to get, set filesystem label from CircuitPython
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/storage/__init__.c53
-rw-r--r--shared-bindings/storage/__init__.h1
2 files changed, 54 insertions, 0 deletions
diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c
index 6f6a30da6..734cabcc1 100644
--- a/shared-bindings/storage/__init__.c
+++ b/shared-bindings/storage/__init__.c
@@ -122,12 +122,22 @@ mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_a
}
MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 1, storage_remount);
+//| .. function:: getmount(mount_path)
+//|
+//| Retrieves the mount object associated with the mount path
+//|
+mp_obj_t storage_getmount(const mp_obj_t mnt_in) {
+ return common_hal_storage_getmount(mp_obj_str_get_str(mnt_in));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount);
+
STATIC const mp_rom_map_elem_t storage_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_storage) },
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&storage_mount_obj) },
{ MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&storage_umount_obj) },
{ MP_ROM_QSTR(MP_QSTR_remount), MP_ROM_PTR(&storage_remount_obj) },
+ { MP_ROM_QSTR(MP_QSTR_getmount), MP_ROM_PTR(&storage_getmount_obj) },
//| .. class:: VfsFat(block_device)
//|
@@ -135,6 +145,49 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = {
//|
//| :param block_device: Block device the the filesystem lives on
//|
+ //| .. attribute:: label
+ //|
+ //| The filesystem label, up to 11 case-insensitive bytes. Note that
+ //| this property can only be set when the device is writable by the
+ //| microcontroller.
+ //|
+ //| .. method:: mkfs
+ //|
+ //| Format the block device, deleting any data that may have been there
+ //|
+ //| .. method:: open(path, mode)
+ //|
+ //| Like builtin ``open()``
+ //|
+ //| .. method:: ilistdir([path])
+ //|
+ //| Return an iterator whose values describe files and folders within
+ //| ``path``
+ //|
+ //| .. method:: mkdir(path)
+ //|
+ //| Like `os.mkdir`
+ //|
+ //| .. method:: rmdir(path)
+ //|
+ //| Like `os.rmdir`
+ //|
+ //| .. method:: stat(path)
+ //|
+ //| Like `os.stat`
+ //|
+ //| .. method:: statvfs(path)
+ //|
+ //| Like `os.statvfs`
+ //|
+ //| .. method:: mount(readonly, mkfs)
+ //|
+ //| Don't call this directly, call `storage.mount`.
+ //|
+ //| .. method:: umount
+ //|
+ //| Don't call this directly, call `storage.umount`.
+ //|
{ MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
};
diff --git a/shared-bindings/storage/__init__.h b/shared-bindings/storage/__init__.h
index 574b5ff8d..76b9ae854 100644
--- a/shared-bindings/storage/__init__.h
+++ b/shared-bindings/storage/__init__.h
@@ -34,5 +34,6 @@ void common_hal_storage_mount(mp_obj_t vfs_obj, const char* path, bool readonly)
void common_hal_storage_umount_path(const char* path);
void common_hal_storage_umount_object(mp_obj_t vfs_obj);
void common_hal_storage_remount(const char* path, bool readonly);
+mp_obj_t common_hal_storage_getmount(const char* path);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_STORAGE___INIT___H