SCCS-vsn: usr.bin/fstat/fstat.c 5.8
#endif /* !lint */
#ifndef lint
#endif /* !lint */
#ifndef lint
-static char sccsid[] = "@(#)fstat.c 5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)fstat.c 5.8 (Berkeley) %G%";
struct devs *next;
dev_t dev;
int inum;
struct devs *next;
dev_t dev;
int inum;
- printf("USER\t CMD\t PID FD\tDEVICE\tINODE\t SIZE\tTYPE\n");
+ printf("USER\t CMD\t PID FD\tDEVICE\tINODE\t SIZE TYPE");
+ if (fflg)
+ printf(" NAME\n");
+ else
+ printf("\n");
+
openfiles();
if (nlist(N_UNIX, nl) == -1 || !nl[0].n_type) {
openfiles();
if (nlist(N_UNIX, nl) == -1 || !nl[0].n_type) {
struct inode inode;
dev_t idev;
char *comm, *itype();
struct inode inode;
dev_t idev;
char *comm, *itype();
+ char *name = (char *)NULL; /* set by devmatch() on a match */
if (g || fflg) {
(void)lseek(kmem, (off_t)g, L_SET);
if (g || fflg) {
(void)lseek(kmem, (off_t)g, L_SET);
return;
}
idev = inode.i_dev;
return;
}
idev = inode.i_dev;
- if (fflg && !devmatch(idev, inode.i_number))
+ if (fflg && !devmatch(idev, inode.i_number, &name))
return;
}
if (mproc->p_pid == 0)
return;
}
if (mproc->p_pid == 0)
switch(ftype) {
case DTYPE_INODE:
switch(ftype) {
case DTYPE_INODE:
- printf("\t%2d, %2d\t%5lu\t%6ld\t%3s\n", major(inode.i_dev),
+ printf("\t%2d, %2d\t%5lu\t%6ld\t%3s %s\n", major(inode.i_dev),
minor(inode.i_dev), inode.i_number,
inode.i_mode == IFSOCK ? 0 : inode.i_size,
minor(inode.i_dev), inode.i_number,
inode.i_mode == IFSOCK ? 0 : inode.i_size,
+ itype(inode.i_mode), name ? name : "");
break;
case DTYPE_SOCKET:
socktrans((struct socket *)g);
break;
case DTYPE_SOCKET:
socktrans((struct socket *)g);
+devmatch(idev, inum, name)
{
register DEVS *d;
for (d = devs; d; d = d->next)
{
register DEVS *d;
for (d = devs; d; d = d->next)
- if (d->dev == idev && (!d->inum || d->inum == inum))
+ if (d->dev == idev && (d->inum == 0 || d->inum == inum)) {
+ *name = d->name;
cur->inum = 0;
cur->dev = statbuf.st_rdev;
}
cur->inum = 0;
cur->dev = statbuf.st_rdev;
}