From 9fa188200688cf5fb3cdc4886bdba90c50a33d8f Mon Sep 17 00:00:00 2001 From: csjp Date: Fri, 19 Nov 2004 16:11:54 +0000 Subject: Use statfs instead of getmntinfo(). This will make the procfs checks play nicer in prisons. It also simplifies things. Reviewed by: rwatson Bumped into by: Jilles Tjoelker --- bin/ps/ps.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'bin/ps') diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 6455ea6..2bedc17 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -1179,16 +1179,13 @@ kludge_oldps_options(const char *optlist, char *origval, const char *nextarg) static int check_procfs(void) { - struct statfs *mntbuf; - size_t mntsize, i; + struct statfs mnt; - mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); - for (i = 0; i < mntsize; i++) - if (strcmp(mntbuf[i].f_mntonname, "/proc") == 0 && - strcmp(mntbuf[i].f_fstypename, "procfs") == 0) { - return (1); - } - return (0); + if (statfs("/proc", &mnt) < 0) + return (0); + if (strcmp(mnt.f_fstypename, "procfs") != 0) + return (0); + return (1); } static void -- cgit v1.1