##// END OF EJS Templates
osutil: implement getfsmountpoint() on BSD systems...
Matt Harbison -
r35533:e01549a7 default
parent child Browse files
Show More
@@ -1112,6 +1112,24 b' static PyObject *getfstype(PyObject *sel'
1112 }
1112 }
1113 #endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */
1113 #endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */
1114
1114
1115 #if defined(HAVE_BSD_STATFS)
1116 /* given a directory path, return filesystem mount point (best-effort) */
1117 static PyObject *getfsmountpoint(PyObject *self, PyObject *args)
1118 {
1119 const char *path = NULL;
1120 struct statfs buf;
1121 int r;
1122 if (!PyArg_ParseTuple(args, "s", &path))
1123 return NULL;
1124
1125 memset(&buf, 0, sizeof(buf));
1126 r = statfs(path, &buf);
1127 if (r != 0)
1128 return PyErr_SetFromErrno(PyExc_OSError);
1129 return Py_BuildValue("s", buf.f_mntonname);
1130 }
1131 #endif /* defined(HAVE_BSD_STATFS) */
1132
1115 static PyObject *unblocksignal(PyObject *self, PyObject *args)
1133 static PyObject *unblocksignal(PyObject *self, PyObject *args)
1116 {
1134 {
1117 int sig = 0;
1135 int sig = 0;
@@ -1311,6 +1329,10 b' static PyMethodDef methods[] = {'
1311 {"getfstype", (PyCFunction)getfstype, METH_VARARGS,
1329 {"getfstype", (PyCFunction)getfstype, METH_VARARGS,
1312 "get filesystem type (best-effort)\n"},
1330 "get filesystem type (best-effort)\n"},
1313 #endif
1331 #endif
1332 #if defined(HAVE_BSD_STATFS)
1333 {"getfsmountpoint", (PyCFunction)getfsmountpoint, METH_VARARGS,
1334 "get filesystem mount point (best-effort)\n"},
1335 #endif
1314 {"unblocksignal", (PyCFunction)unblocksignal, METH_VARARGS,
1336 {"unblocksignal", (PyCFunction)unblocksignal, METH_VARARGS,
1315 "change signal mask to unblock a given signal\n"},
1337 "change signal mask to unblock a given signal\n"},
1316 #endif /* ndef _WIN32 */
1338 #endif /* ndef _WIN32 */
@@ -1323,7 +1345,7 b' static PyMethodDef methods[] = {'
1323 {NULL, NULL}
1345 {NULL, NULL}
1324 };
1346 };
1325
1347
1326 static const int version = 2;
1348 static const int version = 3;
1327
1349
1328 #ifdef IS_PY3K
1350 #ifdef IS_PY3K
1329 static struct PyModuleDef osutil_module = {
1351 static struct PyModuleDef osutil_module = {
@@ -74,7 +74,7 b' def _importfrom(pkgname, modname):'
74 (r'cext', r'bdiff'): 1,
74 (r'cext', r'bdiff'): 1,
75 (r'cext', r'diffhelpers'): 1,
75 (r'cext', r'diffhelpers'): 1,
76 (r'cext', r'mpatch'): 1,
76 (r'cext', r'mpatch'): 1,
77 (r'cext', r'osutil'): 2,
77 (r'cext', r'osutil'): 3,
78 (r'cext', r'parsers'): 4,
78 (r'cext', r'parsers'): 4,
79 }
79 }
80
80
General Comments 0
You need to be logged in to leave comments. Login now