# HG changeset patch # User Matt Harbison # Date 1514609752 18000 # Node ID e01549a7bf0a6a7adbbb317a5d4bfde36c205b4d # Parent 5880318624c9dbc3529871b7b0c382f293578498 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. diff -r 5880318624c9 -r e01549a7bf0a mercurial/cext/osutil.c --- a/mercurial/cext/osutil.c Fri Dec 29 23:50:42 2017 -0500 +++ b/mercurial/cext/osutil.c Fri Dec 29 23:55:52 2017 -0500 @@ -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 = { diff -r 5880318624c9 -r e01549a7bf0a mercurial/policy.py --- a/mercurial/policy.py Fri Dec 29 23:50:42 2017 -0500 +++ b/mercurial/policy.py Fri Dec 29 23:55:52 2017 -0500 @@ -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, }