Skip to content

Implement os.statvfs

ave requested to merge add-sd-total-capacity into main
# statvfs used to be unimplemented before, but only on vfs_posix.c, vfs.c would still present it as an option:
>>> import os
>>> help(os)
object <module 'os' from 'os/__init__.py'> is of type module
...
  statvfs -- <function>
...
# and it would throw a cryptic error:
>>> os.statvfs("/sd")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'VfsPosix' object has no attribute 'statvfs'

# that has also been replaced by this:
>>> os.statvfs("/flash")
(0, 4096, 0, 1293, 1880, 0, 0, 0, 0, 255)
>>> os.statvfs("/sd")
(0, 512, 0, 962888, 979040, 0, 0, 0, 0, 255)
>>> os.statvfs("")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 2] ENOENT

not all fields are implemented, only block size, and total/empty blocks.

Edited by ave

Merge request reports

Loading