]> granicus.if.org Git - python/commitdiff
bpo-32143: add f_fsid to os.statvfs() (#4571)
authorGiuseppe Scrivano <gscrivano@gnu.org>
Thu, 14 Dec 2017 22:46:46 +0000 (23:46 +0100)
committerFred Drake <fred@fdrake.net>
Thu, 14 Dec 2017 22:46:46 +0000 (17:46 -0500)
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Doc/library/os.rst
Lib/test/test_os.py
Misc/NEWS.d/next/Library/2017-11-26-17-28-26.bpo-32143.o7YdXL.rst [new file with mode: 0644]
Modules/posixmodule.c

index 95c81137230816e76f14661cd30b0875fd91f82a..a24934ceb7b5ffddb2b814139450784aeb7ca888 100644 (file)
@@ -2436,7 +2436,7 @@ features:
    correspond to the members of the :c:type:`statvfs` structure, namely:
    :attr:`f_bsize`, :attr:`f_frsize`, :attr:`f_blocks`, :attr:`f_bfree`,
    :attr:`f_bavail`, :attr:`f_files`, :attr:`f_ffree`, :attr:`f_favail`,
-   :attr:`f_flag`, :attr:`f_namemax`.
+   :attr:`f_flag`, :attr:`f_namemax`, :attr:`f_fsid`.
 
    Two module-level constants are defined for the :attr:`f_flag` attribute's
    bit-flags: if :const:`ST_RDONLY` is set, the filesystem is mounted
@@ -2471,6 +2471,9 @@ features:
    .. versionchanged:: 3.6
       Accepts a :term:`path-like object`.
 
+   .. versionadded:: 3.7
+      Added :attr:`f_fsid`.
+
 
 .. data:: supports_dir_fd
 
index 22412569092228b1726af10ae0ed9f39c7653803..f235f801e0315d3b7c6fb8c511f85430ae569ecd 100644 (file)
@@ -352,6 +352,11 @@ class StatAttributeTests(unittest.TestCase):
         for value, member in enumerate(members):
             self.assertEqual(getattr(result, 'f_' + member), result[value])
 
+        self.assertTrue(isinstance(result.f_fsid, int))
+
+        # Test that the size of the tuple doesn't change
+        self.assertEqual(len(result), 10)
+
         # Make sure that assignment really fails
         try:
             result.f_bfree = 1
diff --git a/Misc/NEWS.d/next/Library/2017-11-26-17-28-26.bpo-32143.o7YdXL.rst b/Misc/NEWS.d/next/Library/2017-11-26-17-28-26.bpo-32143.o7YdXL.rst
new file mode 100644 (file)
index 0000000..f416ec5
--- /dev/null
@@ -0,0 +1 @@
+os.statvfs() includes the f_fsid field from statvfs(2)
index fb879e3821aa683afd1de6e61ef75dafb16f84a8..448d4b7428ede10cb12cdc13f62e08c0a51e7c07 100644 (file)
@@ -1860,6 +1860,7 @@ static PyStructSequence_Field statvfs_result_fields[] = {
     {"f_favail", },
     {"f_flag",   },
     {"f_namemax",},
+    {"f_fsid",   },
     {0}
 };
 
@@ -9324,6 +9325,7 @@ _pystatvfs_fromstructstatvfs(struct statvfs st) {
     PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag));
     PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax));
 #endif
+    PyStructSequence_SET_ITEM(v, 10, PyLong_FromUnsignedLong(st.f_fsid));
     if (PyErr_Occurred()) {
         Py_DECREF(v);
         return NULL;