On 02/08/17(Wed) 09:34, Todd C. Miller wrote:
> On Wed, 02 Aug 2017 11:01:38 +0200, Alexander Bluhm wrote:
>
> > On Wed, Aug 02, 2017 at 09:56:50AM +0200, Martin Pieuchot wrote:
> > > Simple diff to improved readability. Before:
> >
> > There are situations where you want a full match on the command.
> > For testing and scripting with long program names this is necessary.
> > With a -v switch that shows the long name I would accept the patch.
> > netstat has that, too. And it would help in my use case.
>
> Which long name do you mean? ps_comm is limited to 16 characters.
> You won't really get the full process name without fetching argv
> and even then the program is free to modify argv[0].
New diff that uses 16 characters for ps_comm.
Before:
$ fstat -f /tmp
USER CMD PID FD MOUNT INUM MODE R/W SZ|DV
mpi fstat 26025 1 /tmp 22 -rw-r--r-- w 16
mpi ksh 56160 1 /tmp 22 -rw-r--r-- w 16
mpi python3.6 72931 3 /tmp 19* -rw------- rwe 4096
mpi seahorse-sharing 14788 wd /tmp 2 drwxrwxrwt r
1024
mpi gnome-shell 59193 19 /tmp 14* -rw------- rwe 12288
$ fstat -nf /tmp
USER CMD PID FD DEV INUM MODE R/W SZ|DV
mpi fstat 39482 1 4,19 22 100644 w 495
mpi ksh 56160 1 4,19 22 100644 w 495
mpi python3.6 72931 3 4,19 19* 100600 rwe 4096
mpi seahorse-sharing 14788 wd 4,19 2 41777 r 1024
mpi gnome-shell 59193 19 4,19 14* 100600 rwe 12288
After:
$ fstat -f /tmp
USER CMD PID FD MOUNT INUM MODE R/W SZ|DV
mpi fstat 57146 1 /tmp 23 -rw-r--r-- w 16
mpi ksh 34466 1 /tmp 23 -rw-r--r-- w 16
mpi python3.6 72931 3 /tmp 19* -rw------- rwe 4096
mpi seahorse-sharing 14788 wd /tmp 2 drwxrwxrwt r 1024
mpi gnome-shell 59193 19 /tmp 14* -rw------- rwe 12288
$ fstat -nf /tmp
USER CMD PID FD DEV INUM MODE R/W SZ|DV
mpi fstat 58486 1 4,19 23 100644 w 519
mpi ksh 34466 1 4,19 23 100644 w 519
mpi python3.6 72931 3 4,19 19* 100600 rwe 4096
mpi seahorse-sharing 14788 wd 4,19 2 41777 r 1024
mpi gnome-shell 59193 19 4,19 14* 100600 rwe 12288
ok?
Index: fstat.c
===================================================================
RCS file: /cvs/src/usr.bin/fstat/fstat.c,v
retrieving revision 1.90
diff -u -p -r1.90 fstat.c
--- fstat.c 21 Jan 2017 12:21:57 -0000 1.90
+++ fstat.c 8 Aug 2017 15:24:04 -0000
@@ -316,12 +316,8 @@ main(int argc, char *argv[])
void
fstat_header(void)
{
- if (nflg)
- printf("%s",
-"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");
+ printf("USER CMD PID FD %5s INUM"
+ " MODE R/W SZ|DV", (nflg) ? "DEV " : "MOUNT");
if (oflg)
printf("%s", ":OFFSET ");
if (checkfile && fsflg == 0)
@@ -336,7 +332,7 @@ uid_t *procuid;
pid_t Pid;
#define PREFIX(i) do { \
- printf("%-8.8s %-10s %5ld", Uname, Comm, (long)Pid); \
+ printf("%-8.8s %-16.16s %5ld", Uname, Comm, (long)Pid); \
switch (i) { \
case KERN_FILE_TEXT: \
printf(" text"); \
@@ -432,14 +428,14 @@ vtrans(struct kinfo_file *kf)
}
if (nflg)
- (void)printf(" %2ld,%-2ld", (long)major(kf->va_fsid),
+ (void)printf(" %2ld,%-2ld ", (long)major(kf->va_fsid),
(long)minor(kf->va_fsid));
else if (!(kf->v_flag & VCLONE))
- (void)printf(" %-8s", kf->f_mntonname);
+ (void)printf(" %-7s", kf->f_mntonname);
else
- (void)printf(" clone ");
+ (void)printf(" clone ");
if (nflg)
- (void)snprintf(mode, sizeof(mode), "%o", kf->va_mode);
+ (void)snprintf(mode, sizeof(mode), "%o ", kf->va_mode);
else
strmode(kf->va_mode, mode);
printf(" %8llu%s %11s", kf->va_fileid,
@@ -452,7 +448,7 @@ vtrans(struct kinfo_file *kf)
strlcat(rwep, "w", sizeof rwep);
if (kf->fd_ofileflags & UF_EXCLOSE)
strlcat(rwep, "e", sizeof rwep);
- printf(" %4s", rwep);
+ printf(" %3s", rwep);
switch (kf->v_type) {
case VBLK:
case VCHR: {