aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorBrian Feldman <green@FreeBSD.org>1999-11-13 21:13:25 +0000
committerBrian Feldman <green@FreeBSD.org>1999-11-13 21:13:25 +0000
commit38cd1ee7d3308704726c049f76058d2bfaf5e3f7 (patch)
treef4c8283b992eb43a84f2aa290418704228eda04e /usr.bin
parentb04b572b08da4c27b8218d137068b82f51406706 (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/fstat/fstat.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c
index b8e0c973a470..9ebfb25043cd 100644
--- a/usr.bin/fstat/fstat.c
+++ b/usr.bin/fstat/fstat.c
@@ -61,6 +61,7 @@ static const char rcsid[] =
#include <sys/filedesc.h>
#include <sys/queue.h>
#include <sys/pipe.h>
+#include <sys/conf.h>
#define KERNEL
#include <sys/file.h>
#include <ufs/ufs/quota.h>
@@ -157,6 +158,7 @@ void pipetrans __P((struct pipe *pi, int i, int flag));
void socktrans __P((struct socket *sock, int i));
void getinetproto __P((int number));
int getfname __P((char *filename));
+udev_t dev2udev __P((dev_t dev));
void usage __P((void));
@@ -487,7 +489,12 @@ ufs_filestat(vp, fsp)
(void *)VTOI(vp), Pid);
return 0;
}
- fsp->fsid = inode.i_dev & 0xffff;
+ /*
+ * The st_dev from stat(2) is a udev_t. These kernel structures
+ * contain dev_t structures. We need to convert to udev to make
+ * comparisons
+ */
+ fsp->fsid = dev2udev(inode.i_dev) & 0xffff;
fsp->fileid = (long)inode.i_number;
fsp->mode = (mode_t)inode.i_mode;
fsp->size = (u_long)inode.i_size;
@@ -729,6 +736,26 @@ bad:
printf("* error\n");
}
+
+/*
+ * Read the specinfo structure in the kernel (as pointed to by a dev_t)
+ * in order to work out the associated udev_t
+ */
+udev_t
+dev2udev(dev)
+ dev_t dev;
+{
+ struct specinfo si;
+
+ if (KVM_READ(dev, &si, sizeof si)) {
+ return si.si_udev;
+ } else {
+ dprintf(stderr, "can't convert dev_t %p to a udev_t\n",
+ (void *)dev);
+ return -1;
+ }
+}
+
/*
* getinetproto --
* print name of protocol number