diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-01-21 12:21:58 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-01-21 12:21:58 +0000 |
commit | 6bd0cda03d38ebcc96e7a942a050d91e1bcbf49f (patch) | |
tree | 730882ef521a0e676ce3af8f0ca956f52cfdd8f2 /usr.bin/fstat | |
parent | 317a3316db00a846d0557607b3632f91118e82f7 (diff) |
Expose the close-on-exec flag near the R/W flags.
ok guenther
Diffstat (limited to 'usr.bin/fstat')
-rw-r--r-- | usr.bin/fstat/fstat.1 | 18 | ||||
-rw-r--r-- | usr.bin/fstat/fstat.c | 19 |
2 files changed, 20 insertions, 17 deletions
diff --git a/usr.bin/fstat/fstat.1 b/usr.bin/fstat/fstat.1 index a3de615742c..af1b2c42819 100644 --- a/usr.bin/fstat/fstat.1 +++ b/usr.bin/fstat/fstat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fstat.1,v 1.53 2016/10/02 23:16:08 guenther Exp $ +.\" $OpenBSD: fstat.1,v 1.54 2017/01/21 12:21:56 deraadt 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: October 2 2016 $ +.Dd $Mdocdate: January 21 2017 $ .Dt FSTAT 1 .Os .Sh NAME @@ -159,13 +159,13 @@ using a symbolic format (see otherwise, the mode is printed as an octal number. .It Li R/W -This column describes the access mode that the file allows. -The letter -.Sq r -indicates open for reading; -the letter -.Sq w -indicates open for writing. +This column describes the properties of the file descriptor: +.Bd -literal -offset indent +r Open for reading +w Open for writing +e close-on-exec flag is set +.Ed +.Pp This field is useful when trying to find the processes that are preventing a file system from being downgraded to read-only. .It Li SZ | DV diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 5656574cda0..62c7ee88061 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fstat.c,v 1.89 2016/10/02 23:16:08 guenther Exp $ */ +/* $OpenBSD: fstat.c,v 1.90 2017/01/21 12:21:57 deraadt Exp $ */ /* * Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com> @@ -54,6 +54,7 @@ #include <sys/socketvar.h> #include <sys/eventvar.h> #include <sys/sysctl.h> +#include <sys/filedesc.h> #define _KERNEL /* for DTYPE_* */ #include <sys/file.h> #undef _KERNEL @@ -317,10 +318,10 @@ fstat_header(void) { if (nflg) printf("%s", -"USER CMD PID FD DEV INUM MODE R/W SZ|DV"); +"USER CMD PID FD DEV INUM MODE R/W SZ|DV"); else printf("%s", -"USER CMD PID FD MOUNT INUM MODE R/W SZ|DV"); +"USER CMD PID FD MOUNT INUM MODE R/W SZ|DV"); if (oflg) printf("%s", ":OFFSET "); if (checkfile && fsflg == 0) @@ -396,7 +397,7 @@ void vtrans(struct kinfo_file *kf) { const char *badtype = NULL; - char rw[3], mode[12]; + char rwep[5], mode[12]; char *filename = NULL; if (kf->v_type == VNON) @@ -444,12 +445,14 @@ vtrans(struct kinfo_file *kf) printf(" %8llu%s %11s", kf->va_fileid, kf->va_nlink == 0 ? "*" : " ", mode); - rw[0] = '\0'; + rwep[0] = '\0'; if (kf->f_flag & FREAD) - strlcat(rw, "r", sizeof rw); + strlcat(rwep, "r", sizeof rwep); if (kf->f_flag & FWRITE) - strlcat(rw, "w", sizeof rw); - printf(" %2s", rw); + strlcat(rwep, "w", sizeof rwep); + if (kf->fd_ofileflags & UF_EXCLOSE) + strlcat(rwep, "e", sizeof rwep); + printf(" %4s", rwep); switch (kf->v_type) { case VBLK: case VCHR: { |