diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-10-24 21:20:58 +0300 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-10-24 21:20:58 +0300 |
commit | 1e1ca969454f6449efac3001add1df6a383bebfb (patch) | |
tree | bf345c9f1839ecc3bd9cdf15c859ffe8dfb48d6f | |
parent | 06c265bafc204be4b8cbc8bbf10213397750e7a0 (diff) | |
download | psutil-disk-part-ext.tar.gz |
implement posix max file/path lendisk-part-ext
-rw-r--r-- | psutil/__init__.py | 19 | ||||
-rw-r--r-- | psutil/_common.py | 3 | ||||
-rw-r--r-- | psutil/_psutil_bsd.c | 5 | ||||
-rw-r--r-- | psutil/arch/freebsd/specific.c | 24 |
4 files changed, 33 insertions, 18 deletions
diff --git a/psutil/__init__.py b/psutil/__init__.py index b2a6efd5..4efc6423 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -2002,7 +2002,24 @@ def disk_partitions(all=False): If *all* parameter is False return physical devices only and ignore all others. """ - return _psplatform.disk_partitions(all) + def getconf(mountp, name): + try: + return os.pathconf(mountp, name) + except (OSError, AttributeError): + pass + + ret = _psplatform.disk_partitions(all) + if POSIX: + new = [] + for item in ret: + nt = _common.sdiskpartext( + *item, + maxfile=getconf(item.mountpoint, 'PC_NAME_MAX'), + maxpath=getconf(item.mountpoint, 'PC_PATH_MAX')) + new.append(nt) + return new + else: + return ret def disk_io_counters(perdisk=False, nowrap=True): diff --git a/psutil/_common.py b/psutil/_common.py index b7a54786..bd3579db 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -179,6 +179,9 @@ sdiskio = namedtuple('sdiskio', ['read_count', 'write_count', 'read_time', 'write_time']) # psutil.disk_partitions() sdiskpart = namedtuple('sdiskpart', ['device', 'mountpoint', 'fstype', 'opts']) +# psutil.disk_partitions() +sdiskpartext = namedtuple('sdiskpartext', ['device', 'mountpoint', 'fstype', + 'opts', 'maxfile', 'maxpath']) # psutil.net_io_counters() snetio = namedtuple('snetio', ['bytes_sent', 'bytes_recv', 'packets_sent', 'packets_recv', diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c index 6933260a..c1b811c6 100644 --- a/psutil/_psutil_bsd.c +++ b/psutil/_psutil_bsd.c @@ -443,17 +443,12 @@ psutil_proc_environ(PyObject *self, PyObject *args) { // On *BSD kernels there are a few kernel-only system processes without an // environment (See e.g. "procstat -e 0 | 1 | 2 ..." on FreeBSD.) - // // Some system process have no stats attached at all // (they are marked with P_SYSTEM.) - // // On FreeBSD, it's possible that the process is swapped or paged out, // then there no access to the environ stored in the process' user area. - // // On NetBSD, we cannot call kvm_getenvv2() for a zombie process. - // // To make unittest suite happy, return an empty environment. - // #if defined(PSUTIL_FREEBSD) #if (defined(__FreeBSD_version) && __FreeBSD_version >= 700000) if (!((p)->ki_flag & P_INMEM) || ((p)->ki_flag & P_SYSTEM)) { diff --git a/psutil/arch/freebsd/specific.c b/psutil/arch/freebsd/specific.c index fcfce131..e7517a40 100644 --- a/psutil/arch/freebsd/specific.c +++ b/psutil/arch/freebsd/specific.c @@ -1142,19 +1142,19 @@ psutil_proc_setrlimit(PyObject *self, PyObject *args) { name[4] = resource; #if defined(HAVE_LONG_LONG) - new.rlim_cur = PyLong_AsLongLong(py_soft); - if (new.rlim_cur == (rlim_t) - 1 && PyErr_Occurred()) - return NULL; - new.rlim_max = PyLong_AsLongLong(py_hard); - if (new.rlim_max == (rlim_t) - 1 && PyErr_Occurred()) - return NULL; + new.rlim_cur = PyLong_AsLongLong(py_soft); + if (new.rlim_cur == (rlim_t) - 1 && PyErr_Occurred()) + return NULL; + new.rlim_max = PyLong_AsLongLong(py_hard); + if (new.rlim_max == (rlim_t) - 1 && PyErr_Occurred()) + return NULL; #else - new.rlim_cur = PyLong_AsLong(py_soft); - if (new.rlim_cur == (rlim_t) - 1 && PyErr_Occurred()) - return NULL; - new.rlim_max = PyLong_AsLong(py_hard); - if (new.rlim_max == (rlim_t) - 1 && PyErr_Occurred()) - return NULL; + new.rlim_cur = PyLong_AsLong(py_soft); + if (new.rlim_cur == (rlim_t) - 1 && PyErr_Occurred()) + return NULL; + new.rlim_max = PyLong_AsLong(py_hard); + if (new.rlim_max == (rlim_t) - 1 && PyErr_Occurred()) + return NULL; #endif newp = &new; ret = sysctl(name, 5, NULL, 0, newp, sizeof(*newp)); |