diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-06-25 06:21:37 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-06-25 06:21:37 +0000 |
commit | 8db52e3cc08efdf037ccb539d1761b1c1a311afc (patch) | |
tree | 421045107fb0520487a538513d6dad8f7814c13d /usr.bin | |
parent | 264047bc5c6af3c538cb0244742adaa561fdb189 (diff) |
first cut at isofs support
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/fstat/Makefile | 3 | ||||
-rw-r--r-- | usr.bin/fstat/fstat.c | 48 | ||||
-rw-r--r-- | usr.bin/fstat/fstat.h | 53 | ||||
-rw-r--r-- | usr.bin/fstat/isofs.c | 98 |
4 files changed, 190 insertions, 12 deletions
diff --git a/usr.bin/fstat/Makefile b/usr.bin/fstat/Makefile index 6137b2dea21..8c6090f327c 100644 --- a/usr.bin/fstat/Makefile +++ b/usr.bin/fstat/Makefile @@ -1,7 +1,8 @@ -# $OpenBSD: Makefile,v 1.3 1997/09/21 11:49:07 deraadt Exp $ +# $OpenBSD: Makefile,v 1.4 1998/06/25 06:21:33 deraadt Exp $ PROG= fstat DPADD= ${LIBKVM} +SRCS= fstat.c isofs.c LDADD= -lkvm BINGRP= kmem BINMODE=2555 diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 51b40c4d2b1..6026b922594 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fstat.c,v 1.13 1997/12/06 21:19:34 deraadt Exp $ */ +/* $OpenBSD: fstat.c,v 1.14 1998/06/25 06:21:34 deraadt Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -41,7 +41,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)fstat.c 8.1 (Berkeley) 6/6/93";*/ -static char *rcsid = "$OpenBSD: fstat.c,v 1.13 1997/12/06 21:19:34 deraadt Exp $"; +static char *rcsid = "$OpenBSD: fstat.c,v 1.14 1998/06/25 06:21:34 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -89,6 +89,7 @@ static char *rcsid = "$OpenBSD: fstat.c,v 1.13 1997/12/06 21:19:34 deraadt Exp $ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include "fstat.h" #define TEXT -1 #define CDIR -2 @@ -103,14 +104,6 @@ typedef struct devs { } DEVS; DEVS *devs; -struct filestat { - long fsid; - long fileid; - mode_t mode; - u_int64_t size; - dev_t rdev; -}; - 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 */ @@ -143,6 +136,8 @@ kvm_t *kd; int ufs_filestat __P((struct vnode *, struct filestat *)); int ext2fs_filestat __P((struct vnode *, struct filestat *)); +int isofs_filestat __P((struct vnode *, struct filestat *)); +int msdos_filestat __P((struct vnode *, struct filestat *)); int nfs_filestat __P((struct vnode *, struct filestat *)); void dofiles __P((struct kinfo_proc *)); void getinetproto __P((int)); @@ -267,7 +262,7 @@ main(argc, argv) } char *Uname, *Comm; -int Pid; +pid_t Pid; #define PREFIX(i) printf("%-8.8s %-10s %5d", Uname, Comm, Pid); \ switch(i) { \ @@ -408,6 +403,14 @@ vtrans(vp, i, flag) if (!ext2fs_filestat(&vn, &fst)) badtype = "error"; break; + case VT_ISOFS: + if (!isofs_filestat(&vn, &fst)) + badtype = "error"; + break; + case VT_MSDOSFS: + if (!msdos_filestat(&vn, &fst)) + badtype = "error"; + break; default: { static char unknown[30]; sprintf(badtype = unknown, "?(%x)", vn.v_tag); @@ -514,6 +517,29 @@ ext2fs_filestat(vp, fsp) } int +msdos_filestat(vp, fsp) + struct vnode *vp; + struct filestat *fsp; +{ +#if 0 + struct inode inode; + + if (!KVM_READ(VTOI(vp), &inode, sizeof (inode))) { + dprintf(stderr, "can't read inode at %p for pid %d\n", + VTOI(vp), Pid); + return 0; + } + fsp->fsid = inode.i_dev & 0xffff; + fsp->fileid = (long)inode.i_number; + fsp->mode = inode.i_e2fs_mode; + fsp->size = inode.i_e2fs_size; + fsp->rdev = 0; /* XXX */ +#endif + + return 1; +} + +int nfs_filestat(vp, fsp) struct vnode *vp; struct filestat *fsp; diff --git a/usr.bin/fstat/fstat.h b/usr.bin/fstat/fstat.h new file mode 100644 index 00000000000..e311aac1a06 --- /dev/null +++ b/usr.bin/fstat/fstat.h @@ -0,0 +1,53 @@ +/* $OpenBSD: fstat.h,v 1.1 1998/06/25 06:21:36 deraadt 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; + u_int64_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; +#define dprintf if (vflg) fprintf + diff --git a/usr.bin/fstat/isofs.c b/usr.bin/fstat/isofs.c new file mode 100644 index 00000000000..125a75d1f07 --- /dev/null +++ b/usr.bin/fstat/isofs.c @@ -0,0 +1,98 @@ +/* $OpenBSD: isofs.c,v 1.1 1998/06/25 06:21:36 deraadt 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/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 "fstat.h" + +extern pid_t Pid; + +int +isofs_filestat(vp, fsp) + struct vnode *vp; + struct filestat *fsp; +{ + struct iso_node inode; + + if (!KVM_READ(VTOI(vp), &inode, sizeof (inode))) { + dprintf(stderr, "can't read inode at %p for pid %d\n", + 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; +} |