diff options
| author | Christian S.J. Peron <csjp@FreeBSD.org> | 2004-11-14 19:30:02 +0000 |
|---|---|---|
| committer | Christian S.J. Peron <csjp@FreeBSD.org> | 2004-11-14 19:30:02 +0000 |
| commit | a951d1f83b127914e9d83c429b0baa1b71b81772 (patch) | |
| tree | 39318b6578337c6d25e119430005ba4d654d75a2 | |
| parent | 234657745567736fea79b96c33c82ae729cfaba3 (diff) | |
Notes
| -rw-r--r-- | bin/ps/ps.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/ps/ps.c b/bin/ps/ps.c index dcb701821f53..6455ea66202d 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/sysctl.h> +#include <sys/mount.h> #include <ctype.h> #include <err.h> @@ -128,6 +129,7 @@ struct listinfo { } l; }; +static int check_procfs(void); static int addelem_gid(struct listinfo *, const char *); static int addelem_pid(struct listinfo *, const char *); static int addelem_tty(struct listinfo *, const char *); @@ -402,6 +404,14 @@ main(int argc, char *argv[]) argv += optind; /* + * If the user specified ps -e then they want a copy of the process + * environment kvm_getenvv(3) attempts to open /proc/<pid>/mem. + * Check to make sure that procfs is mounted on /proc, otherwise + * print a warning informing the user that output will be incomplete. + */ + if (needenv == 1 && check_procfs() == 0) + warnx("Process environment requires procfs(5)"); + /* * If there arguments after processing all the options, attempt * to treat them as a list of process ids. */ @@ -1166,6 +1176,21 @@ kludge_oldps_options(const char *optlist, char *origval, const char *nextarg) return (newopts); } +static int +check_procfs(void) +{ + struct statfs *mntbuf; + size_t mntsize, i; + + 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); +} + static void usage(void) { |
