Skip to content
Snippets Groups Projects
Commit e01549a7 authored by Matt Harbison's avatar Matt Harbison
Browse files

osutil: implement getfsmountpoint() on BSD systems

I don't have a BSD system handy to test this, but it looks simple enough from
the man page.
parent 58803186
No related branches found
No related tags found
No related merge requests found
......@@ -1112,6 +1112,24 @@
}
#endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */
#if defined(HAVE_BSD_STATFS)
/* given a directory path, return filesystem mount point (best-effort) */
static PyObject *getfsmountpoint(PyObject *self, PyObject *args)
{
const char *path = NULL;
struct statfs buf;
int r;
if (!PyArg_ParseTuple(args, "s", &path))
return NULL;
memset(&buf, 0, sizeof(buf));
r = statfs(path, &buf);
if (r != 0)
return PyErr_SetFromErrno(PyExc_OSError);
return Py_BuildValue("s", buf.f_mntonname);
}
#endif /* defined(HAVE_BSD_STATFS) */
static PyObject *unblocksignal(PyObject *self, PyObject *args)
{
int sig = 0;
......@@ -1311,6 +1329,10 @@
{"getfstype", (PyCFunction)getfstype, METH_VARARGS,
"get filesystem type (best-effort)\n"},
#endif
#if defined(HAVE_BSD_STATFS)
{"getfsmountpoint", (PyCFunction)getfsmountpoint, METH_VARARGS,
"get filesystem mount point (best-effort)\n"},
#endif
{"unblocksignal", (PyCFunction)unblocksignal, METH_VARARGS,
"change signal mask to unblock a given signal\n"},
#endif /* ndef _WIN32 */
......@@ -1323,7 +1345,7 @@
{NULL, NULL}
};
static const int version = 2;
static const int version = 3;
#ifdef IS_PY3K
static struct PyModuleDef osutil_module = {
......
......@@ -74,7 +74,7 @@
(r'cext', r'bdiff'): 1,
(r'cext', r'diffhelpers'): 1,
(r'cext', r'mpatch'): 1,
(r'cext', r'osutil'): 2,
(r'cext', r'osutil'): 3,
(r'cext', r'parsers'): 4,
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment