[Python-checkins] bpo-32659: Solaris "stat" should support "st_fstype" (#5307)

jcea webhook-mailer at python.org
Sun Jan 28 08:00:12 EST 2018


https://github.com/python/cpython/commit/6c51d518800cdda7ba16ae163be0d211d2c4fa12
commit: 6c51d518800cdda7ba16ae163be0d211d2c4fa12
branch: master
author: jcea <jcea at jcea.es>
committer: GitHub <noreply at github.com>
date: 2018-01-28T14:00:08+01:00
summary:

bpo-32659: Solaris "stat" should support "st_fstype" (#5307)

* bpo-32659: Solaris "stat" should support "st_fstype"

* Add 'versionadded'

files:
A Misc/NEWS.d/next/Library/2018-01-25-03-46-00.bpo-32659.VHYoON.rst
M Doc/library/os.rst
M Modules/posixmodule.c

diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index b8f57f55eb41..bae432d33b0b 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -2474,6 +2474,14 @@ features:
 
       Time of file creation.
 
+   On Solaris and derivatives, the following attributes may also be
+   available:
+
+   .. attribute:: st_fstype
+
+      String that uniquely identifies the type of the filesystem that
+      contains the file.
+
    On Mac OS systems, the following attributes may also be available:
 
    .. attribute:: st_rsize
@@ -2517,6 +2525,8 @@ features:
    .. versionadded:: 3.5
       Added the :attr:`st_file_attributes` member on Windows.
 
+   .. versionadded:: 3.7
+      Added the :attr:`st_fstype` member to Solaris/derivatives.
 
 .. function:: statvfs(path)
 
diff --git a/Misc/NEWS.d/next/Library/2018-01-25-03-46-00.bpo-32659.VHYoON.rst b/Misc/NEWS.d/next/Library/2018-01-25-03-46-00.bpo-32659.VHYoON.rst
new file mode 100644
index 000000000000..f29f08786f55
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-01-25-03-46-00.bpo-32659.VHYoON.rst
@@ -0,0 +1 @@
+Under Solaris and derivatives, :class:`os.stat_result` provides a st_fstype attribute.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index a1a38ebda387..ceea85559c85 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -394,6 +394,10 @@ static int win32_can_symlink = 0;
 #define MODNAME "posix"
 #endif
 
+#if defined(__sun)
+/* Something to implement in autoconf, not present in autoconf 2.69 */
+#define HAVE_STRUCT_STAT_ST_FSTYPE 1
+#endif
 
 #ifdef HAVE_FORK
 static void
@@ -1788,6 +1792,9 @@ static PyStructSequence_Field stat_result_fields[] = {
 #endif
 #ifdef HAVE_STRUCT_STAT_ST_FILE_ATTRIBUTES
     {"st_file_attributes", "Windows file attribute bits"},
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_FSTYPE
+    {"st_fstype",  "Type of filesystem"},
 #endif
     {0}
 };
@@ -1834,6 +1841,12 @@ static PyStructSequence_Field stat_result_fields[] = {
 #define ST_FILE_ATTRIBUTES_IDX ST_BIRTHTIME_IDX
 #endif
 
+#ifdef HAVE_STRUCT_STAT_ST_FSTYPE
+#define ST_FSTYPE_IDX (ST_FILE_ATTRIBUTES_IDX+1)
+#else
+#define ST_FSTYPE_IDX ST_FILE_ATTRIBUTES_IDX
+#endif
+
 static PyStructSequence_Desc stat_result_desc = {
     "stat_result", /* name */
     stat_result__doc__, /* doc */
@@ -2057,6 +2070,10 @@ _pystat_fromstructstat(STRUCT_STAT *st)
     PyStructSequence_SET_ITEM(v, ST_FILE_ATTRIBUTES_IDX,
                               PyLong_FromUnsignedLong(st->st_file_attributes));
 #endif
+#ifdef HAVE_STRUCT_STAT_ST_FSTYPE
+   PyStructSequence_SET_ITEM(v, ST_FSTYPE_IDX,
+                              PyUnicode_FromString(st->st_fstype));
+#endif
 
     if (PyErr_Occurred()) {
         Py_DECREF(v);



More information about the Python-checkins mailing list