vfs.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. /*
  2. * This file is part of the MicroPython project, http://micropython.org/
  3. *
  4. * The MIT License (MIT)
  5. *
  6. * Copyright (c) 2017 Damien P. George
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. #include <stdint.h>
  27. #include <string.h>
  28. #include "py/runtime.h"
  29. #include "py/objstr.h"
  30. #include "py/mperrno.h"
  31. #include "extmod/vfs.h"
  32. #if MICROPY_VFS
  33. #if MICROPY_VFS_FAT
  34. #include "extmod/vfs_fat.h"
  35. #endif
  36. // For mp_vfs_proxy_call, the maximum number of additional args that can be passed.
  37. // A fixed maximum size is used to avoid the need for a costly variable array.
  38. #define PROXY_MAX_ARGS (2)
  39. // path is the path to lookup and *path_out holds the path within the VFS
  40. // object (starts with / if an absolute path).
  41. // Returns MP_VFS_ROOT for root dir (and then path_out is undefined) and
  42. // MP_VFS_NONE for path not found.
  43. mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_out) {
  44. if (*path == '/' || MP_STATE_VM(vfs_cur) == MP_VFS_ROOT) {
  45. // an absolute path, or the current volume is root, so search root dir
  46. bool is_abs = 0;
  47. if (*path == '/') {
  48. ++path;
  49. is_abs = 1;
  50. }
  51. if (*path == '\0') {
  52. // path is "" or "/" so return virtual root
  53. return MP_VFS_ROOT;
  54. }
  55. for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) {
  56. size_t len = vfs->len - 1;
  57. if (len == 0) {
  58. *path_out = path - is_abs;
  59. return vfs;
  60. }
  61. if (strncmp(path, vfs->str + 1, len) == 0) {
  62. if (path[len] == '/') {
  63. *path_out = path + len;
  64. return vfs;
  65. } else if (path[len] == '\0') {
  66. *path_out = "/";
  67. return vfs;
  68. }
  69. }
  70. }
  71. // if we get here then there's nothing mounted on /
  72. if (is_abs) {
  73. // path began with / and was not found
  74. return MP_VFS_NONE;
  75. }
  76. }
  77. // a relative path within a mounted device
  78. *path_out = path;
  79. return MP_STATE_VM(vfs_cur);
  80. }
  81. // Version of mp_vfs_lookup_path that takes and returns uPy string objects.
  82. STATIC mp_vfs_mount_t *lookup_path(mp_obj_t path_in, mp_obj_t *path_out) {
  83. const char *path = mp_obj_str_get_str(path_in);
  84. const char *p_out;
  85. mp_vfs_mount_t *vfs = mp_vfs_lookup_path(path, &p_out);
  86. if (vfs != MP_VFS_NONE && vfs != MP_VFS_ROOT) {
  87. *path_out = mp_obj_new_str_of_type(mp_obj_get_type(path_in),
  88. (const byte*)p_out, strlen(p_out));
  89. }
  90. return vfs;
  91. }
  92. STATIC mp_obj_t mp_vfs_proxy_call(mp_vfs_mount_t *vfs, qstr meth_name, size_t n_args, const mp_obj_t *args) {
  93. assert(n_args <= PROXY_MAX_ARGS);
  94. if (vfs == MP_VFS_NONE) {
  95. // mount point not found
  96. mp_raise_OSError(MP_ENODEV);
  97. }
  98. if (vfs == MP_VFS_ROOT) {
  99. // can't do operation on root dir
  100. mp_raise_OSError(MP_EPERM);
  101. }
  102. mp_obj_t meth[2 + PROXY_MAX_ARGS];
  103. mp_load_method(vfs->obj, meth_name, meth);
  104. if (args != NULL) {
  105. memcpy(meth + 2, args, n_args * sizeof(*args));
  106. }
  107. return mp_call_method_n_kw(n_args, 0, meth);
  108. }
  109. mp_import_stat_t mp_vfs_import_stat(const char *path) {
  110. const char *path_out;
  111. mp_vfs_mount_t *vfs = mp_vfs_lookup_path(path, &path_out);
  112. if (vfs == MP_VFS_NONE || vfs == MP_VFS_ROOT) {
  113. return MP_IMPORT_STAT_NO_EXIST;
  114. }
  115. #if MICROPY_VFS_FAT
  116. // fast paths for known VFS types
  117. if (mp_obj_get_type(vfs->obj) == &mp_fat_vfs_type) {
  118. return fat_vfs_import_stat(MP_OBJ_TO_PTR(vfs->obj), path_out);
  119. }
  120. #endif
  121. // TODO delegate to vfs.stat() method
  122. return MP_IMPORT_STAT_NO_EXIST;
  123. }
  124. mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  125. enum { ARG_readonly, ARG_mkfs };
  126. static const mp_arg_t allowed_args[] = {
  127. { MP_QSTR_readonly, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_false} },
  128. { MP_QSTR_mkfs, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_false} },
  129. };
  130. // parse args
  131. mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
  132. mp_arg_parse_all(n_args - 2, pos_args + 2, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
  133. // get the mount point
  134. size_t mnt_len;
  135. const char *mnt_str = mp_obj_str_get_data(pos_args[1], &mnt_len);
  136. // see if we need to auto-detect and create the filesystem
  137. mp_obj_t vfs_obj = pos_args[0];
  138. mp_obj_t dest[2];
  139. mp_load_method_maybe(vfs_obj, MP_QSTR_mount, dest);
  140. if (dest[0] == MP_OBJ_NULL) {
  141. // Input object has no mount method, assume it's a block device and try to
  142. // auto-detect the filesystem and create the corresponding VFS entity.
  143. // (At the moment we only support FAT filesystems.)
  144. #if MICROPY_VFS_FAT
  145. vfs_obj = mp_fat_vfs_type.make_new(&mp_fat_vfs_type, 1, 0, &vfs_obj);
  146. #endif
  147. }
  148. // create new object
  149. mp_vfs_mount_t *vfs = m_new_obj(mp_vfs_mount_t);
  150. vfs->str = mnt_str;
  151. vfs->len = mnt_len;
  152. vfs->obj = vfs_obj;
  153. vfs->next = NULL;
  154. // call the underlying object to do any mounting operation
  155. mp_vfs_proxy_call(vfs, MP_QSTR_mount, 2, (mp_obj_t*)&args);
  156. // check that the destination mount point is unused
  157. const char *path_out;
  158. mp_vfs_mount_t *existing_mount = mp_vfs_lookup_path(mp_obj_str_get_str(pos_args[1]), &path_out);
  159. if (existing_mount != MP_VFS_NONE && existing_mount != MP_VFS_ROOT) {
  160. if (vfs->len != 1 && existing_mount->len == 1) {
  161. // if root dir is mounted, still allow to mount something within a subdir of root
  162. } else {
  163. // mount point in use
  164. mp_raise_OSError(MP_EPERM);
  165. }
  166. }
  167. // insert the vfs into the mount table
  168. mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table);
  169. while (*vfsp != NULL) {
  170. if ((*vfsp)->len == 1) {
  171. // make sure anything mounted at the root stays at the end of the list
  172. vfs->next = *vfsp;
  173. break;
  174. }
  175. vfsp = &(*vfsp)->next;
  176. }
  177. *vfsp = vfs;
  178. return mp_const_none;
  179. }
  180. MP_DEFINE_CONST_FUN_OBJ_KW(mp_vfs_mount_obj, 2, mp_vfs_mount);
  181. mp_obj_t mp_vfs_umount(mp_obj_t mnt_in) {
  182. // remove vfs from the mount table
  183. mp_vfs_mount_t *vfs = NULL;
  184. size_t mnt_len;
  185. const char *mnt_str = NULL;
  186. if (MP_OBJ_IS_STR(mnt_in)) {
  187. mnt_str = mp_obj_str_get_data(mnt_in, &mnt_len);
  188. }
  189. for (mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); *vfsp != NULL; vfsp = &(*vfsp)->next) {
  190. if ((mnt_str != NULL && !memcmp(mnt_str, (*vfsp)->str, mnt_len + 1)) || (*vfsp)->obj == mnt_in) {
  191. vfs = *vfsp;
  192. *vfsp = (*vfsp)->next;
  193. break;
  194. }
  195. }
  196. if (vfs == NULL) {
  197. mp_raise_OSError(MP_EINVAL);
  198. }
  199. // if we unmounted the current device then set current to root
  200. if (MP_STATE_VM(vfs_cur) == vfs) {
  201. MP_STATE_VM(vfs_cur) = MP_VFS_ROOT;
  202. }
  203. // call the underlying object to do any unmounting operation
  204. mp_vfs_proxy_call(vfs, MP_QSTR_umount, 0, NULL);
  205. return mp_const_none;
  206. }
  207. MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_umount_obj, mp_vfs_umount);
  208. // Note: buffering and encoding args are currently ignored
  209. mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
  210. enum { ARG_file, ARG_mode, ARG_encoding };
  211. static const mp_arg_t allowed_args[] = {
  212. { MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
  213. { MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} },
  214. { MP_QSTR_buffering, MP_ARG_INT, {.u_int = -1} },
  215. { MP_QSTR_encoding, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
  216. };
  217. // parse args
  218. mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
  219. mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
  220. mp_vfs_mount_t *vfs = lookup_path((mp_obj_t)args[ARG_file].u_rom_obj, &args[ARG_file].u_obj);
  221. return mp_vfs_proxy_call(vfs, MP_QSTR_open, 2, (mp_obj_t*)&args);
  222. }
  223. MP_DEFINE_CONST_FUN_OBJ_KW(mp_vfs_open_obj, 0, mp_vfs_open);
  224. mp_obj_t mp_vfs_chdir(mp_obj_t path_in) {
  225. mp_obj_t path_out;
  226. mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
  227. MP_STATE_VM(vfs_cur) = vfs;
  228. if (vfs == MP_VFS_ROOT) {
  229. // If we change to the root dir and a VFS is mounted at the root then
  230. // we must change that VFS's current dir to the root dir so that any
  231. // subsequent relative paths begin at the root of that VFS.
  232. for (vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) {
  233. if (vfs->len == 1) {
  234. mp_obj_t root = MP_OBJ_NEW_QSTR(MP_QSTR__slash_);
  235. mp_vfs_proxy_call(vfs, MP_QSTR_chdir, 1, &root);
  236. break;
  237. }
  238. }
  239. } else {
  240. mp_vfs_proxy_call(vfs, MP_QSTR_chdir, 1, &path_out);
  241. }
  242. return mp_const_none;
  243. }
  244. MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_chdir_obj, mp_vfs_chdir);
  245. mp_obj_t mp_vfs_getcwd(void) {
  246. if (MP_STATE_VM(vfs_cur) == MP_VFS_ROOT) {
  247. return MP_OBJ_NEW_QSTR(MP_QSTR__slash_);
  248. }
  249. mp_obj_t cwd_o = mp_vfs_proxy_call(MP_STATE_VM(vfs_cur), MP_QSTR_getcwd, 0, NULL);
  250. if (MP_STATE_VM(vfs_cur)->len == 1) {
  251. // don't prepend "/" for vfs mounted at root
  252. return cwd_o;
  253. }
  254. const char *cwd = mp_obj_str_get_str(cwd_o);
  255. vstr_t vstr;
  256. vstr_init(&vstr, MP_STATE_VM(vfs_cur)->len + strlen(cwd) + 1);
  257. vstr_add_strn(&vstr, MP_STATE_VM(vfs_cur)->str, MP_STATE_VM(vfs_cur)->len);
  258. if (!(cwd[0] == '/' && cwd[1] == 0)) {
  259. vstr_add_str(&vstr, cwd);
  260. }
  261. return mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
  262. }
  263. MP_DEFINE_CONST_FUN_OBJ_0(mp_vfs_getcwd_obj, mp_vfs_getcwd);
  264. typedef struct _mp_vfs_ilistdir_it_t {
  265. mp_obj_base_t base;
  266. mp_fun_1_t iternext;
  267. union {
  268. mp_vfs_mount_t *vfs;
  269. mp_obj_t iter;
  270. } cur;
  271. bool is_str;
  272. bool is_iter;
  273. } mp_vfs_ilistdir_it_t;
  274. STATIC mp_obj_t mp_vfs_ilistdir_it_iternext(mp_obj_t self_in) {
  275. mp_vfs_ilistdir_it_t *self = MP_OBJ_TO_PTR(self_in);
  276. if (self->is_iter) {
  277. // continue delegating to root dir
  278. return mp_iternext(self->cur.iter);
  279. } else if (self->cur.vfs == NULL) {
  280. // finished iterating mount points and no root dir is mounted
  281. return MP_OBJ_STOP_ITERATION;
  282. } else {
  283. // continue iterating mount points
  284. mp_vfs_mount_t *vfs = self->cur.vfs;
  285. self->cur.vfs = vfs->next;
  286. if (vfs->len == 1) {
  287. // vfs is mounted at root dir, delegate to it
  288. mp_obj_t root = MP_OBJ_NEW_QSTR(MP_QSTR__slash_);
  289. self->is_iter = true;
  290. self->cur.iter = mp_vfs_proxy_call(vfs, MP_QSTR_ilistdir, 1, &root);
  291. return mp_iternext(self->cur.iter);
  292. } else {
  293. // a mounted directory
  294. mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL));
  295. t->items[0] = mp_obj_new_str_of_type(
  296. self->is_str ? &mp_type_str : &mp_type_bytes,
  297. (const byte*)vfs->str + 1, vfs->len - 1);
  298. t->items[1] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR);
  299. t->items[2] = MP_OBJ_NEW_SMALL_INT(0); // no inode number
  300. return MP_OBJ_FROM_PTR(t);
  301. }
  302. }
  303. }
  304. mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args) {
  305. mp_obj_t path_in;
  306. if (n_args == 1) {
  307. path_in = args[0];
  308. } else {
  309. path_in = MP_OBJ_NEW_QSTR(MP_QSTR_);
  310. }
  311. mp_obj_t path_out;
  312. mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
  313. if (vfs == MP_VFS_ROOT) {
  314. // list the root directory
  315. mp_vfs_ilistdir_it_t *iter = m_new_obj(mp_vfs_ilistdir_it_t);
  316. iter->base.type = &mp_type_polymorph_iter;
  317. iter->iternext = mp_vfs_ilistdir_it_iternext;
  318. iter->cur.vfs = MP_STATE_VM(vfs_mount_table);
  319. iter->is_str = mp_obj_get_type(path_in) == &mp_type_str;
  320. iter->is_iter = false;
  321. return MP_OBJ_FROM_PTR(iter);
  322. }
  323. return mp_vfs_proxy_call(vfs, MP_QSTR_ilistdir, 1, &path_out);
  324. }
  325. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_ilistdir_obj, 0, 1, mp_vfs_ilistdir);
  326. mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) {
  327. mp_obj_t iter = mp_vfs_ilistdir(n_args, args);
  328. mp_obj_t dir_list = mp_obj_new_list(0, NULL);
  329. mp_obj_t next;
  330. while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
  331. mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL));
  332. }
  333. return dir_list;
  334. }
  335. MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_vfs_listdir_obj, 0, 1, mp_vfs_listdir);
  336. mp_obj_t mp_vfs_mkdir(mp_obj_t path_in) {
  337. mp_obj_t path_out;
  338. mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
  339. if (vfs == MP_VFS_ROOT || (vfs != MP_VFS_NONE && !strcmp(mp_obj_str_get_str(path_out), "/"))) {
  340. mp_raise_OSError(MP_EEXIST);
  341. }
  342. return mp_vfs_proxy_call(vfs, MP_QSTR_mkdir, 1, &path_out);
  343. }
  344. MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_mkdir_obj, mp_vfs_mkdir);
  345. mp_obj_t mp_vfs_remove(mp_obj_t path_in) {
  346. mp_obj_t path_out;
  347. mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
  348. return mp_vfs_proxy_call(vfs, MP_QSTR_remove, 1, &path_out);
  349. }
  350. MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_remove_obj, mp_vfs_remove);
  351. mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) {
  352. mp_obj_t args[2];
  353. mp_vfs_mount_t *old_vfs = lookup_path(old_path_in, &args[0]);
  354. mp_vfs_mount_t *new_vfs = lookup_path(new_path_in, &args[1]);
  355. if (old_vfs != new_vfs) {
  356. // can't rename across filesystems
  357. mp_raise_OSError(MP_EPERM);
  358. }
  359. return mp_vfs_proxy_call(old_vfs, MP_QSTR_rename, 2, args);
  360. }
  361. MP_DEFINE_CONST_FUN_OBJ_2(mp_vfs_rename_obj, mp_vfs_rename);
  362. mp_obj_t mp_vfs_rmdir(mp_obj_t path_in) {
  363. mp_obj_t path_out;
  364. mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
  365. return mp_vfs_proxy_call(vfs, MP_QSTR_rmdir, 1, &path_out);
  366. }
  367. MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_rmdir_obj, mp_vfs_rmdir);
  368. mp_obj_t mp_vfs_stat(mp_obj_t path_in) {
  369. mp_obj_t path_out;
  370. mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
  371. if (vfs == MP_VFS_ROOT) {
  372. mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL));
  373. t->items[0] = MP_OBJ_NEW_SMALL_INT(MP_S_IFDIR); // st_mode
  374. for (int i = 1; i <= 9; ++i) {
  375. t->items[i] = MP_OBJ_NEW_SMALL_INT(0); // dev, nlink, uid, gid, size, atime, mtime, ctime
  376. }
  377. return MP_OBJ_FROM_PTR(t);
  378. }
  379. return mp_vfs_proxy_call(vfs, MP_QSTR_stat, 1, &path_out);
  380. }
  381. MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_stat_obj, mp_vfs_stat);
  382. mp_obj_t mp_vfs_statvfs(mp_obj_t path_in) {
  383. mp_obj_t path_out;
  384. mp_vfs_mount_t *vfs = lookup_path(path_in, &path_out);
  385. if (vfs == MP_VFS_ROOT) {
  386. // statvfs called on the root directory, see if there's anything mounted there
  387. for (vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) {
  388. if (vfs->len == 1) {
  389. break;
  390. }
  391. }
  392. // If there's nothing mounted at root then return a mostly-empty tuple
  393. if (vfs == NULL) {
  394. mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(10, NULL));
  395. // fill in: bsize, frsize, blocks, bfree, bavail, files, ffree, favail, flags
  396. for (int i = 0; i <= 8; ++i) {
  397. t->items[i] = MP_OBJ_NEW_SMALL_INT(0);
  398. }
  399. // Put something sensible in f_namemax
  400. t->items[9] = MP_OBJ_NEW_SMALL_INT(MICROPY_ALLOC_PATH_MAX);
  401. return MP_OBJ_FROM_PTR(t);
  402. }
  403. // VFS mounted at root so delegate the call to it
  404. path_out = MP_OBJ_NEW_QSTR(MP_QSTR__slash_);
  405. }
  406. return mp_vfs_proxy_call(vfs, MP_QSTR_statvfs, 1, &path_out);
  407. }
  408. MP_DEFINE_CONST_FUN_OBJ_1(mp_vfs_statvfs_obj, mp_vfs_statvfs);
  409. #endif // MICROPY_VFS