as suggested by chuck cranor, pull in some openbsd mods:

* display ip address details of tcp/udp connections
* display isofs details
* use %p instead of %lx in error messages

other mods by me:
* don't put \n at the end of err()/warn() format
* man page cleanups (use .Dq and .Pq as appropriate)
This commit is contained in:
lukem 1999-02-18 06:09:25 +00:00
parent e88f10c5f0
commit 591a968873
5 changed files with 286 additions and 110 deletions

View File

@ -1,7 +1,8 @@
# $NetBSD: Makefile,v 1.10 1998/03/04 18:07:29 mycroft Exp $
# $NetBSD: Makefile,v 1.11 1999/02/18 06:09:25 lukem Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
PROG= fstat
SRCS= fstat.c isofs.c
DPADD= ${LIBKVM}
LDADD= -lkvm
BINGRP= kmem

View File

@ -1,4 +1,4 @@
.\" $NetBSD: fstat.1,v 1.11 1998/04/28 06:00:57 fair Exp $
.\" $NetBSD: fstat.1,v 1.12 1999/02/18 06:09:25 lukem Exp $
.\"
.\" Copyright (c) 1987, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -32,9 +32,9 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)fstat.1 8.3 (Berkeley) 2/25/94
.\" $NetBSD: fstat.1,v 1.11 1998/04/28 06:00:57 fair Exp $
.\" $NetBSD: fstat.1,v 1.12 1999/02/18 06:09:25 lukem Exp $
.\"
.Dd February 25, 1994
.Dd February 18, 1999
.Dt FSTAT 1
.Os BSD 4
.Sh NAME
@ -105,24 +105,29 @@ Restrict reports to the specified files.
The following fields are printed:
.Bl -tag -width MOUNT
.It Li USER
The username of the owner of the process (effective uid).
The username of the owner of the process (effective UID).
.It Li CMD
The command name of the process.
.It Li PID
The process id.
The process ID.
.It Li FD
The file number in the per-process open file table or one of the following
special names:
.Pp
.Bd -ragged -offset indent -compact
text - pure text inode
wd - current working directory
root - root inode
tr - kernel trace file
.Ed
.Bl -tag -width MOUNT -offset -indent -compact
.It Li text
pure text inode
.It Li wd
current working directory
.It Li root
root inode
.It Li tr
kernel trace file
.El
.Pp
If the file number is followed by an asterisk (``*''), the file is
not an inode, but rather a socket,
If the file number is followed by an asterisk
.Pq Dq * ,
the file is not an inode, but rather a socket,
.Tn FIFO ,
or there is an error.
In this case the remainder of the line doesn't
@ -150,7 +155,7 @@ using a symbolic format (see
otherwise, the mode is printed
as an octal number.
.It Li SZ\&|DV
If the file is not a character or block special, prints the size of
If the file is not a character or block special file, prints the size of
the file in bytes. Otherwise, if the
.Fl n
flag is not specified, prints
@ -163,10 +168,14 @@ flag is specified, prints the major/minor device
number that the special device refers to.
.It Li R/W
This column describes the access mode that the file allows.
The letter ``r'' indicates open for reading;
the letter ``w'' indicates open for writing.
The letter
.Dq r
indicates open for reading;
the letter
.Dq
indicates open for writing.
This field is useful when trying to find the processes that are
preventing a filesystem from being down graded to read-only.
preventing a filesystem from being downgraded to read-only.
.It Li NAME
If filename arguments are specified and the
.Fl f
@ -186,7 +195,7 @@ In all cases the first field is the domain name, the second field
is the socket type (stream, dgram, etc), and the third is the socket
flags field (in hex).
The remaining fields are protocol dependent.
For tcp, it is the address of the tcpcb, and for udp, the inpcb (socket pcb).
For TCP, it is the address of the tcpcb, and for UDP, the inpcb (socket pcb).
For
.Ux
domain sockets, its the address of the socket pcb and the address
@ -207,14 +216,35 @@ connected
domain stream socket.
A unidirectional
.Ux
domain socket indicates the direction of flow with
an arrow (``<-'' or ``->''), and a full duplex socket shows a double arrow
(``<->'').
domain socket indicates the direction of flow with an arrow
.Po
.Dq <-
or
.Dq ->
.Pc ,
and a full duplex socket shows a double arrow
.Pq Dq <-> .
.Pp
For internet sockets
.Nm fstat
also attempts to print the internet address and port for the
local end of a connection.
If the socket is connected, it also prints the remote internet address
and port.
A
.Pq Dq *
is used to indicate an INADDR_ANY binding.
.Sh BUGS
Since
.Nm
takes a snapshot of the system, it is only correct for a very short period
of time.
.Pp
Moreover, because DNS resolution and YP lookups cause many file
descriptor changes,
.Nm
does not attempt to translate the internet address and port numbers into
symbolic names.
.Sh SEE ALSO
.Xr netstat 1 ,
.Xr nfsstat 1 ,

View File

@ -1,4 +1,4 @@
/* $NetBSD: fstat.c,v 1.33 1998/07/28 21:25:58 mycroft Exp $ */
/* $NetBSD: fstat.c,v 1.34 1999/02/18 06:09:25 lukem Exp $ */
/*-
* Copyright (c) 1988, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993\n\
#if 0
static char sccsid[] = "@(#)fstat.c 8.3 (Berkeley) 5/2/95";
#else
__RCSID("$NetBSD: fstat.c,v 1.33 1998/07/28 21:25:58 mycroft Exp $");
__RCSID("$NetBSD: fstat.c,v 1.34 1999/02/18 06:09:25 lukem Exp $");
#endif
#endif /* not lint */
@ -79,6 +79,8 @@ __RCSID("$NetBSD: fstat.c,v 1.33 1998/07/28 21:25:58 mycroft Exp $");
#include <netinet/ip.h>
#include <netinet/in_pcb.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <kvm.h>
@ -92,6 +94,8 @@ __RCSID("$NetBSD: fstat.c,v 1.33 1998/07/28 21:25:58 mycroft Exp $");
#include <unistd.h>
#include <err.h>
#include "fstat.h"
#define TEXT -1
#define CDIR -2
#define RDIR -3
@ -105,20 +109,6 @@ typedef struct devs {
} DEVS;
DEVS *devs;
struct filestat {
long fsid;
long fileid;
mode_t mode;
u_long size;
dev_t rdev;
};
#ifdef notdef
struct nlist nl[] = {
{ "" },
};
#endif
int fsflg, /* show files on same filesystem as file(s) argument */
pflg, /* show files open by a particular pid */
uflg; /* show files open by a particular (effective) user */
@ -126,8 +116,6 @@ int checkfile; /* true if restricting to particular files or filesystems */
int nflg; /* (numerical) display f.s. and rdev as dev_t */
int vflg; /* display errors in locating kernel data objects etc... */
#define dprintf if (vflg) fprintf
struct file **ofiles; /* buffer of pointers to file structures */
int maxfiles;
#define ALLOC_OFILES(d) \
@ -141,12 +129,6 @@ int maxfiles;
maxfiles = (d); \
}
/*
* a kvm_read that returns true if everything is read
*/
#define KVM_READ(kaddr, paddr, len) \
(kvm_read(kd, (u_long)(kaddr), (char *)(paddr), (len)) == (len))
kvm_t *kd;
void dofiles __P((struct kinfo_proc *));
@ -196,7 +178,7 @@ main(argc, argv)
if (pflg++)
usage();
if (!isdigit(*optarg)) {
warnx("-p requires a process id\n");
warnx("-p requires a process id");
usage();
}
what = KERN_PROC_PID;
@ -206,7 +188,7 @@ main(argc, argv)
if (uflg++)
usage();
if (!(passwd = getpwnam(optarg))) {
errx(1, "%s: unknown uid\n", optarg);
errx(1, "%s: unknown uid", optarg);
}
what = KERN_PROC_UID;
arg = passwd->pw_uid;
@ -255,13 +237,8 @@ main(argc, argv)
if (nlistf == NULL && memf == NULL)
(void)setgid(getgid());
#ifdef notdef
if (kvm_nlist(kd, nl) != 0) {
errx(1, "no namelist: %s\n", kvm_geterr(kd));
}
#endif
if ((p = kvm_getprocs(kd, what, arg, &cnt)) == NULL) {
errx(1, "%s\n", kvm_geterr(kd));
errx(1, "%s", kvm_geterr(kd));
}
if (nflg)
printf("%s",
@ -283,7 +260,7 @@ main(argc, argv)
}
const char *Uname, *Comm;
int Pid;
pid_t Pid;
#define PREFIX(i) printf("%-8.8s %-10s %5d", Uname, Comm, Pid); \
switch(i) { \
@ -325,14 +302,12 @@ dofiles(kp)
if (p->p_fd == NULL)
return;
if (!KVM_READ(p->p_fd, &filed0, sizeof (filed0))) {
dprintf(stderr, "can't read filedesc at %lx for pid %d\n",
(long)p->p_fd, Pid);
warnx("can't read filedesc at %p for pid %d", p->p_fd, Pid);
return;
}
if (filed.fd_nfiles < 0 || filed.fd_lastfile >= filed.fd_nfiles ||
filed.fd_freefile > filed.fd_lastfile + 1) {
dprintf(stderr, "filedesc corrupted at %lx for pid %d\n",
(long)p->p_fd, Pid);
dprintf("filedesc corrupted at %p for pid %d", p->p_fd, Pid);
return;
}
/*
@ -357,9 +332,8 @@ dofiles(kp)
if (filed.fd_nfiles > NDFILE) {
if (!KVM_READ(filed.fd_ofiles, ofiles,
(filed.fd_lastfile+1) * FPSIZE)) {
dprintf(stderr,
"can't read file structures at %lx for pid %d\n",
(long)filed.fd_ofiles, Pid);
dprintf("can't read file structures at %p for pid %d",
filed.fd_ofiles, Pid);
return;
}
} else
@ -369,9 +343,8 @@ dofiles(kp)
if (ofiles[i] == NULL)
continue;
if (!KVM_READ(ofiles[i], &file, sizeof (struct file))) {
dprintf(stderr,
"can't read file %d at %lx for pid %d\n",
i, (long)ofiles[i], Pid);
dprintf("can't read file %d at %p for pid %d",
i, ofiles[i], Pid);
continue;
}
if (file.f_type == DTYPE_VNODE)
@ -381,8 +354,7 @@ dofiles(kp)
socktrans((struct socket *)file.f_data, i);
}
else {
dprintf(stderr,
"unknown file type %d for file %d of pid %d\n",
dprintf("unknown file type %d for file %d of pid %d",
file.f_type, i, Pid);
}
}
@ -396,13 +368,12 @@ vtrans(vp, i, flag)
{
struct vnode vn;
struct filestat fst;
char mode[15];
char mode[15], rw[3];
char *badtype = NULL, *filename;
filename = badtype = NULL;
if (!KVM_READ(vp, &vn, sizeof (struct vnode))) {
dprintf(stderr, "can't read vnode at %lx for pid %d\n",
(long)vp, Pid);
dprintf("can't read vnode at %p for pid %d", vp, Pid);
return;
}
if (vn.v_type == VNON || vn.v_tag == VT_NON)
@ -427,6 +398,10 @@ vtrans(vp, i, flag)
if (!ext2fs_filestat(&vn, &fst))
badtype = "error";
break;
case VT_ISOFS:
if (!isofs_filestat(&vn, &fst))
badtype = "error";
break;
default: {
static char unknown[10];
(void)snprintf(badtype = unknown, sizeof unknown,
@ -478,13 +453,14 @@ vtrans(vp, i, flag)
break;
}
default:
printf(" %6ld", (long)fst.size);
printf(" %6qd", (long long)fst.size);
}
putchar(' ');
rw[0] = '\0';
if (flag & FREAD)
putchar('r');
strcat(rw, "r");
if (flag & FWRITE)
putchar('w');
strcat(rw, "w");
printf(" %-2s", rw);
if (filename && !fsflg)
printf(" %s", filename);
putchar('\n');
@ -498,14 +474,13 @@ ufs_filestat(vp, fsp)
struct inode inode;
if (!KVM_READ(VTOI(vp), &inode, sizeof (inode))) {
dprintf(stderr, "can't read inode at %lx for pid %d\n",
(long)VTOI(vp), Pid);
dprintf("can't read inode at %p for pid %d", VTOI(vp), Pid);
return 0;
}
fsp->fsid = inode.i_dev & 0xffff;
fsp->fileid = (long)inode.i_number;
fsp->mode = (mode_t)inode.i_ffs_mode;
fsp->size = (u_long)inode.i_ffs_size;
fsp->size = inode.i_ffs_size;
fsp->rdev = inode.i_ffs_rdev;
return 1;
@ -519,14 +494,13 @@ ext2fs_filestat(vp, fsp)
struct inode inode;
if (!KVM_READ(VTOI(vp), &inode, sizeof (inode))) {
dprintf(stderr, "can't read inode at %lx for pid %d\n",
(long)VTOI(vp), Pid);
dprintf("can't read inode at %p for pid %d", VTOI(vp), Pid);
return 0;
}
fsp->fsid = inode.i_dev & 0xffff;
fsp->fileid = (long)inode.i_number;
fsp->mode = (mode_t)inode.i_e2fs_mode;
fsp->size = (u_long)inode.i_e2fs_size;
fsp->size = inode.i_e2fs_size;
fsp->rdev = 0; /* XXX */
return 1;
}
@ -541,14 +515,13 @@ nfs_filestat(vp, fsp)
mode_t mode;
if (!KVM_READ(VTONFS(vp), &nfsnode, sizeof (nfsnode))) {
dprintf(stderr, "can't read nfsnode at 0x%lx for pid %d\n",
(u_long)VTONFS(vp), Pid);
dprintf("can't read nfsnode at %p for pid %d", VTONFS(vp),
Pid);
return 0;
}
if (!KVM_READ(nfsnode.n_vattr, &va, sizeof(va))) {
dprintf(stderr,
"can't read vnode attributes at 0x%lx for pid %d\n",
(u_long)nfsnode.n_vattr, Pid);
dprintf("can't read vnode attributes at %p for pid %d",
nfsnode.n_vattr, Pid);
return 0;
}
fsp->fsid = va.va_fsid;
@ -603,7 +576,7 @@ getmnton(m)
if (m == mt->m)
return (mt->mntonname);
if (!KVM_READ(m, &mount, sizeof(struct mount))) {
warnx("can't read mount table at %lx\n", (long)m);
warnx("can't read mount table at %p", m);
return (NULL);
}
if ((mt = malloc(sizeof (struct mtab))) == NULL) {
@ -642,27 +615,25 @@ socktrans(sock, i)
/* fill in socket */
if (!KVM_READ(sock, &so, sizeof(struct socket))) {
dprintf(stderr, "can't read sock at %lx\n", (long)sock);
dprintf("can't read sock at %p", sock);
goto bad;
}
/* fill in protosw entry */
if (!KVM_READ(so.so_proto, &proto, sizeof(struct protosw))) {
dprintf(stderr, "can't read protosw at %lx", (long)so.so_proto);
dprintf("can't read protosw at %p", so.so_proto);
goto bad;
}
/* fill in domain */
if (!KVM_READ(proto.pr_domain, &dom, sizeof(struct domain))) {
dprintf(stderr, "can't read domain at %lx\n",
(long)proto.pr_domain);
dprintf("can't read domain at %p", proto.pr_domain);
goto bad;
}
if ((len = kvm_read(kd, (u_long)dom.dom_name, dname,
sizeof(dname) - 1)) != sizeof(dname) -1) {
dprintf(stderr, "can't read domain name at %lx\n",
(long)dom.dom_name);
dprintf("can't read domain name at %p", dom.dom_name);
dname[0] = '\0';
}
else
@ -676,9 +647,9 @@ socktrans(sock, i)
/*
* protocol specific formatting
*
* Try to find interesting things to print. For tcp, the interesting
* thing is the address of the tcpcb, for udp and others, just the
* inpcb (socket pcb). For unix domain, its the address of the socket
* Try to find interesting things to print. For TCP, the interesting
* thing is the address of the tcpcb, for UDP and others, just the
* inpcb (socket pcb). For UNIX domain, its the address of the socket
* pcb and the address of the connected pcb (if connected). Otherwise
* just print the protocol number and address of the socket itself.
* The idea is not to duplicate netstat, but to make available enough
@ -687,20 +658,43 @@ socktrans(sock, i)
switch(dom.dom_family) {
case AF_INET:
getinetproto(proto.pr_protocol);
if (proto.pr_protocol == IPPROTO_TCP ) {
if (so.so_pcb) {
if (kvm_read(kd, (u_long)so.so_pcb,
(char *)&inpcb, sizeof(struct inpcb))
!= sizeof(struct inpcb)) {
dprintf(stderr,
"can't read inpcb at %lx\n",
(long)so.so_pcb);
goto bad;
}
printf(" %lx", (long)inpcb.inp_ppcb);
if (proto.pr_protocol == IPPROTO_TCP) {
if (so.so_pcb == NULL)
break;
if (kvm_read(kd, (u_long)so.so_pcb, (char *)&inpcb,
sizeof(struct inpcb)) != sizeof(struct inpcb)) {
dprintf("can't read inpcb at %p", so.so_pcb);
goto bad;
}
}
else if (so.so_pcb)
printf(" %lx", (long)inpcb.inp_ppcb);
printf(" %s:%d",
inpcb.inp_laddr.s_addr == INADDR_ANY ? "*" :
inet_ntoa(inpcb.inp_laddr), ntohs(inpcb.inp_lport));
if (inpcb.inp_fport) {
printf(" <-> ");
printf("%s:%d",
inpcb.inp_faddr.s_addr == INADDR_ANY ? "*" :
inet_ntoa(inpcb.inp_faddr),
ntohs(inpcb.inp_fport));
}
} else if (proto.pr_protocol == IPPROTO_UDP) {
if (so.so_pcb == NULL)
break;
if (kvm_read(kd, (u_long)so.so_pcb, (char *)&inpcb,
sizeof(struct inpcb)) != sizeof(struct inpcb)) {
dprintf("can't read inpcb at %p", so.so_pcb);
goto bad;
}
printf(" %lx", (long)so.so_pcb);
printf(" %s:%d",
inpcb.inp_laddr.s_addr == INADDR_ANY ? "*" :
inet_ntoa(inpcb.inp_laddr), ntohs(inpcb.inp_lport));
if (inpcb.inp_fport)
printf(" <-> %s:%d",
inpcb.inp_faddr.s_addr == INADDR_ANY ? "*" :
inet_ntoa(inpcb.inp_faddr),
ntohs(inpcb.inp_fport));
} else if (so.so_pcb)
printf(" %lx", (long)so.so_pcb);
break;
case AF_LOCAL:
@ -709,8 +703,7 @@ socktrans(sock, i)
printf(" %lx", (long)so.so_pcb);
if (kvm_read(kd, (u_long)so.so_pcb, (char *)&unpcb,
sizeof(struct unpcb)) != sizeof(struct unpcb)){
dprintf(stderr, "can't read unpcb at %lx\n",
(long)so.so_pcb);
dprintf("can't read unpcb at %p", so.so_pcb);
goto bad;
}
if (unpcb.unp_conn) {

55
usr.bin/fstat/fstat.h Normal file
View File

@ -0,0 +1,55 @@
/* $NetBSD: fstat.h,v 1.1 1999/02/18 06:09:25 lukem Exp $ */
/*-
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
struct filestat {
long fsid;
long fileid;
mode_t mode;
off_t size;
dev_t rdev;
};
/*
* a kvm_read that returns true if everything is read
*/
#define KVM_READ(kaddr, paddr, len) \
(kvm_read(kd, (u_long)(kaddr), (void *)(paddr), (len)) == (len))
extern kvm_t *kd;
extern int vflg;
extern pid_t Pid;
#define dprintf if (vflg) warnx
int isofs_filestat __P((struct vnode *, struct filestat *));

97
usr.bin/fstat/isofs.c Normal file
View File

@ -0,0 +1,97 @@
/* $NetBSD: isofs.c,v 1.1 1999/02/18 06:09:25 lukem Exp $ */
/*-
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: isofs.c,v 1.1 1999/02/18 06:09:25 lukem Exp $");
#include <sys/param.h>
#include <sys/time.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/stat.h>
#include <sys/vnode.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/domain.h>
#include <sys/protosw.h>
#include <sys/unpcb.h>
#include <sys/sysctl.h>
#include <sys/filedesc.h>
#define _KERNEL
#include <sys/file.h>
#include <sys/mount.h>
#undef _KERNEL
#define NFS
#include <nfs/nfsproto.h>
#include <nfs/rpcv2.h>
#include <nfs/nfs.h>
#include <nfs/nfsnode.h>
#undef NFS
#include <isofs/cd9660/iso.h>
#include <isofs/cd9660/cd9660_extern.h>
#include <isofs/cd9660/cd9660_node.h>
#include <ctype.h>
#include <errno.h>
#include <kvm.h>
#include <limits.h>
#include <nlist.h>
#include <paths.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <err.h>
#include "fstat.h"
int
isofs_filestat(vp, fsp)
struct vnode *vp;
struct filestat *fsp;
{
struct iso_node inode;
if (!KVM_READ(VTOI(vp), &inode, sizeof (inode))) {
dprintf("can't read inode at %p for pid %d", VTOI(vp), Pid);
return 0;
}
fsp->fsid = inode.i_dev & 0xffff;
fsp->fileid = (long)inode.i_number;
fsp->mode = inode.inode.iso_mode;
fsp->size = inode.i_size;
fsp->rdev = inode.i_dev;
return 1;
}