Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jan 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2390,6 +2390,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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a versionadded?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, @csabella . PR updated.

Thanks.

On Mac OS systems, the following attributes may also be available:

.. attribute:: st_rsize
Expand Down Expand Up @@ -2433,6 +2441,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)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Under Solaris and derivatives, :class:`os.stat_result` provides a st_fstype attribute.
17 changes: 17 additions & 0 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
};
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down