diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2009-07-19 12:56:20 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2009-07-19 12:56:20 +0000 |
commit | 46b6a514f4de53a5ae1a61be419d3e14534f3ab4 (patch) | |
tree | 2da28c5a6cd333d21d407764354fb6b68dac049a | |
parent | a6eb7b3bc0342e3540566537ce60fa5d2fca5de4 (diff) |
Hook up "text" (executable) output and implement for fuser too.
Man page bits adapted from FreeBSD. OK miod@
-rw-r--r-- | sys/kern/kern_sysctl.c | 4 | ||||
-rw-r--r-- | usr.bin/fstat/fstat.1 | 8 | ||||
-rw-r--r-- | usr.bin/fstat/fstat.h | 7 | ||||
-rw-r--r-- | usr.bin/fstat/fuser.1 | 6 | ||||
-rw-r--r-- | usr.bin/fstat/fuser.c | 9 |
5 files changed, 22 insertions, 12 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 313fb8402f0..86a14a2f8b1 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.175 2009/06/15 17:59:45 deraadt Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.176 2009/07/19 12:56:19 millert Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1232,6 +1232,8 @@ sysctl_file2(int *name, u_int namelen, char *where, size_t *sizep, continue; } fdp = pp->p_fd; + if (pp->p_textvp) + FILLIT(NULL, NULL, KERN_FILE_TEXT, pp->p_textvp, pp); if (fdp->fd_cdir) FILLIT(NULL, NULL, KERN_FILE_CDIR, fdp->fd_cdir, pp); if (fdp->fd_rdir) diff --git a/usr.bin/fstat/fstat.1 b/usr.bin/fstat/fstat.1 index e7c419ebce0..fbee8c14da8 100644 --- a/usr.bin/fstat/fstat.1 +++ b/usr.bin/fstat/fstat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fstat.1,v 1.41 2009/07/08 16:04:00 millert Exp $ +.\" $OpenBSD: fstat.1,v 1.42 2009/07/19 12:56:19 millert Exp $ .\" .\" Copyright (c) 1987, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)fstat.1 8.3 (Berkeley) 2/25/94 .\" -.Dd $Mdocdate: July 8 2009 $ +.Dd $Mdocdate: July 19 2009 $ .Dt FSTAT 1 .Os .Sh NAME @@ -47,7 +47,7 @@ .Nm identifies open files. A file is considered open by a process if it was explicitly opened, -is the working directory, root directory, active pure text, or kernel +is the working directory, root directory, active executable text, or kernel trace file for that process. If no options are specified, .Nm @@ -121,7 +121,7 @@ The process ID. The file number in the per-process open file table or one of the following special names: .Bd -literal -offset indent -text \- pure text inode +text \- executable text inode wd \- current working directory root \- root inode tr \- kernel trace file diff --git a/usr.bin/fstat/fstat.h b/usr.bin/fstat/fstat.h index ba0337b5ff2..6e2b230261f 100644 --- a/usr.bin/fstat/fstat.h +++ b/usr.bin/fstat/fstat.h @@ -19,9 +19,10 @@ struct fuser { uid_t uid; pid_t pid; int flags; -#define F_ROOT 0x01 /* is procs root directory */ -#define F_CWD 0x02 /* is procs cwd */ -#define F_OPEN 0x04 /* just has it open */ +#define F_ROOT 0x01 /* is procs root directory */ +#define F_CWD 0x02 /* is procs cwd */ +#define F_OPEN 0x04 /* just has it open */ +#define F_TEXT 0x08 /* is procs executable text */ }; struct filearg { diff --git a/usr.bin/fstat/fuser.1 b/usr.bin/fstat/fuser.1 index f855c644d29..baab373d021 100644 --- a/usr.bin/fstat/fuser.1 +++ b/usr.bin/fstat/fuser.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fuser.1,v 1.1 2009/07/08 16:04:00 millert Exp $ +.\" $OpenBSD: fuser.1,v 1.2 2009/07/19 12:56:19 millert Exp $ .\" .\" Copyright (c) 2002 Peter Werner <peterw@ifost.org.au> .\" All rights reserved. @@ -23,7 +23,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 8 2009 $ +.Dd $Mdocdate: July 19 2009 $ .Dt FUSER 1 .Os .Sh NAME @@ -100,6 +100,8 @@ if the described conditions are true: The file is the process's current working directory. .It r The file is the process's root directory. +.It t +The file is the process's executable text. .El .Pp .Ex -std fuser diff --git a/usr.bin/fstat/fuser.c b/usr.bin/fstat/fuser.c index 3f146373d72..8486d33ac89 100644 --- a/usr.bin/fstat/fuser.c +++ b/usr.bin/fstat/fuser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuser.c,v 1.1 2009/07/08 16:04:00 millert Exp $ */ +/* $OpenBSD: fuser.c,v 1.2 2009/07/19 12:56:19 millert Exp $ */ /* * Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com> @@ -114,8 +114,10 @@ fuser_check(struct kinfo_file2 *kf) case KERN_FILE_RDIR: fu->flags |= F_ROOT; break; - case KERN_FILE_TRACE: case KERN_FILE_TEXT: + fu->flags |= F_TEXT; + break; + case KERN_FILE_TRACE: /* ignore */ break; default: @@ -142,6 +144,9 @@ printfu(struct fuser *fu) if (fu->flags & F_ROOT) fprintf(stderr, "r"); + if (fu->flags & F_TEXT) + fprintf(stderr, "t"); + if (uflg) { pwd = getpwuid(fu->uid); if (pwd != NULL) |