aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/fstat
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2005-03-17 13:26:06 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2005-03-17 13:26:06 +0000
commit138e5a3468a5601324dd49136e655e005fc1011e (patch)
tree45186bfd95409d1a723db8c159d164060cef8afe /usr.bin/fstat
parentb7fff749242d6a0779596ec685407388a2020b0e (diff)
Notes
Diffstat (limited to 'usr.bin/fstat')
-rw-r--r--usr.bin/fstat/fstat.111
-rw-r--r--usr.bin/fstat/fstat.c15
2 files changed, 21 insertions, 5 deletions
diff --git a/usr.bin/fstat/fstat.1 b/usr.bin/fstat/fstat.1
index 01143ab7c6d9..55ac95bcaa8d 100644
--- a/usr.bin/fstat/fstat.1
+++ b/usr.bin/fstat/fstat.1
@@ -51,8 +51,8 @@ The
.Nm
utility identifies open files.
A file is considered open by a process if it was explicitly opened,
-is the working directory, root directory, active executable text, or kernel
-trace file for that process.
+is the working directory, root directory, jail root directory,
+active executable text, or kernel trace file for that process.
If no options are specified,
.Nm
reports on all open files in the system.
@@ -121,11 +121,12 @@ The file number in the per-process open file table or one of the following
special names:
.Pp
.Bd -literal -offset indent -compact
-text - executable text inode
-wd - current working directory
+jail - jail root directory
+mmap - memory-mapped file
root - root inode
+text - executable text inode
tr - kernel trace file
-mmap - memory-mapped file
+wd - current working directory
.Ed
.Pp
If the file number is followed by an asterisk (``*''), the file is
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c
index a20469e63742..86eee92acfdc 100644
--- a/usr.bin/fstat/fstat.c
+++ b/usr.bin/fstat/fstat.c
@@ -106,6 +106,7 @@ __FBSDID("$FreeBSD$");
#define RDIR -3
#define TRACE -4
#define MMAP -5
+#define JDIR -6
DEVS *devs;
@@ -309,6 +310,9 @@ int Pid;
case MMAP: \
printf(" mmap"); \
break; \
+ case JDIR: \
+ printf(" jail"); \
+ break; \
default: \
printf(" %4d", i); \
break; \
@@ -345,6 +349,11 @@ dofiles(struct kinfo_proc *kp)
*/
vtrans(filed.fd_cdir, CDIR, FREAD);
/*
+ * jail root, if any.
+ */
+ if (filed.fd_jdir)
+ vtrans(filed.fd_jdir, JDIR, FREAD);
+ /*
* ktrace vnode, if one
*/
if (kp->ki_tracep)
@@ -358,6 +367,12 @@ dofiles(struct kinfo_proc *kp)
* open files
*/
#define FPSIZE (sizeof (struct file *))
+#define MAX_LASTFILE (0x1000000)
+
+ /* Sanity check on filed.fd_lastfile */
+ if (filed.fd_lastfile <= -1 || filed.fd_lastfile > MAX_LASTFILE)
+ return;
+
ALLOC_OFILES(filed.fd_lastfile+1);
if (!KVM_READ(filed.fd_ofiles, ofiles,
(filed.fd_lastfile+1) * FPSIZE)) {