Skip to content

Commit 96a5e50

Browse files
giuseppefreddrake
authored andcommitted
bpo-32143: add f_fsid to os.statvfs() (#4571)
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
1 parent 2b5fd1e commit 96a5e50

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

Doc/library/os.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2436,7 +2436,7 @@ features:
24362436
correspond to the members of the :c:type:`statvfs` structure, namely:
24372437
:attr:`f_bsize`, :attr:`f_frsize`, :attr:`f_blocks`, :attr:`f_bfree`,
24382438
:attr:`f_bavail`, :attr:`f_files`, :attr:`f_ffree`, :attr:`f_favail`,
2439-
:attr:`f_flag`, :attr:`f_namemax`.
2439+
:attr:`f_flag`, :attr:`f_namemax`, :attr:`f_fsid`.
24402440

24412441
Two module-level constants are defined for the :attr:`f_flag` attribute's
24422442
bit-flags: if :const:`ST_RDONLY` is set, the filesystem is mounted
@@ -2471,6 +2471,9 @@ features:
24712471
.. versionchanged:: 3.6
24722472
Accepts a :term:`path-like object`.
24732473

2474+
.. versionadded:: 3.7
2475+
Added :attr:`f_fsid`.
2476+
24742477

24752478
.. data:: supports_dir_fd
24762479

Lib/test/test_os.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ def test_statvfs_attributes(self):
352352
for value, member in enumerate(members):
353353
self.assertEqual(getattr(result, 'f_' + member), result[value])
354354

355+
self.assertTrue(isinstance(result.f_fsid, int))
356+
357+
# Test that the size of the tuple doesn't change
358+
self.assertEqual(len(result), 10)
359+
355360
# Make sure that assignment really fails
356361
try:
357362
result.f_bfree = 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
os.statvfs() includes the f_fsid field from statvfs(2)

Modules/posixmodule.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,7 @@ static PyStructSequence_Field statvfs_result_fields[] = {
18601860
{"f_favail", },
18611861
{"f_flag", },
18621862
{"f_namemax",},
1863+
{"f_fsid", },
18631864
{0}
18641865
};
18651866

@@ -9324,6 +9325,7 @@ _pystatvfs_fromstructstatvfs(struct statvfs st) {
93249325
PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag));
93259326
PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax));
93269327
#endif
9328+
PyStructSequence_SET_ITEM(v, 10, PyLong_FromUnsignedLong(st.f_fsid));
93279329
if (PyErr_Occurred()) {
93289330
Py_DECREF(v);
93299331
return NULL;

0 commit comments

Comments
 (0)