- Commit work from libprocstat project. These patches add support for runtime

file and processes information retrieval from the running kernel via sysctl
  in the form of new library, libprocstat.  The library also supports KVM backend
  for analyzing memory crash dumps.  Both procstat(1) and fstat(1) utilities have
  been modified to take advantage of the library (as the bonus point the fstat(1)
  utility no longer need superuser privileges to operate), and the procstat(1)
  utility is now able to display information from memory dumps as well.

  The newly introduced fuser(1) utility also uses this library and able to operate
  via sysctl and kvm backends.

  The library is by no means complete (e.g. KVM backend is missing vnode name
  resolution routines, and there're no manpages for the library itself) so I
  plan to improve it further.  I'm commiting it so it will get wider exposure
  and review.

  We won't be able to MFC this work as it relies on changes in HEAD, which
  was introduced some time ago, that break kernel ABI.  OTOH we may be able
  to merge the library with KVM backend if we really need it there.

Discussed with:	rwatson
This commit is contained in:
Stanislav Sedov
2011-05-12 10:11:39 +00:00
parent 4b5404a9de
commit 0daf62d9f5
42 changed files with 3946 additions and 1265 deletions
+36
View File
@@ -0,0 +1,36 @@
# $FreeBSD$
.include <bsd.own.mk>
LIB= procstat
SRCS= cd9660.c \
common_kvm.c \
libprocstat.c \
msdosfs.c \
ntfs.c \
nwfs.c \
smbfs.c \
udf.c
INCS= libprocstat.h
CFLAGS+= -I. -I${.CURDIR} -D_KVM_VNODE
SHLIB_MAJOR= 1
WITHOUT_MAN= yes
# XXX This is a hack.
.if ${MK_CDDL} != "no"
CFLAGS+= -DZFS
OBJS+= zfs/zfs.o
SOBJS+= zfs/zfs.So
POBJS+= zfs/zfs.po
SUBDIR= zfs
zfs/zfs.o: .PHONY
@cd ${.CURDIR}/zfs && ${MAKE} zfs.o
zfs/zfs.So: .PHONY
@cd ${.CURDIR}/zfs && ${MAKE} zfs.So
zfs/zfs.po: .PHONY
@cd ${.CURDIR}/zfs && ${MAKE} zfs.po
.endif
.include <bsd.lib.mk>
+90
View File
@@ -0,0 +1,90 @@
/*
* Copyright (c) 2000 Peter Edwards
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by Peter Edwards
*
* 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.
*/
/*
* XXX -
* This had to be separated from fstat.c because cd9660s has namespace
* conflicts with UFS.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/vnode.h>
#include <sys/mount.h>
#include <netinet/in.h>
#include <err.h>
#include <isofs/cd9660/cd9660_node.h>
#define _KERNEL
#include <isofs/cd9660/iso.h>
#undef _KERNEL
#include <kvm.h>
#include <stdio.h>
#include "libprocstat.h"
#include "common_kvm.h"
int
isofs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
struct iso_node isonode;
struct iso_mnt mnt;
if (!kvm_read_all(kd, (unsigned long)VTOI(vp), &isonode,
sizeof(isonode))) {
warnx("can't read iso_node at %p",
(void *)VTOI(vp));
return (1);
}
if (!kvm_read_all(kd, (unsigned long)isonode.i_mnt, &mnt,
sizeof(mnt))) {
warnx("can't read iso_mnt at %p",
(void *)VTOI(vp));
return (1);
}
vn->vn_fsid = dev2udev(kd, mnt.im_dev);
vn->vn_mode = (mode_t)isonode.inode.iso_mode;
vn->vn_fileid = (long)isonode.i_number;
vn->vn_size = (u_long)isonode.i_size;
return (0);
}
+207
View File
@@ -0,0 +1,207 @@
/*-
* Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org>
* 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>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/user.h>
#include <sys/stat.h>
#include <sys/vnode.h>
#include <sys/conf.h>
#define _KERNEL
#include <sys/pipe.h>
#include <sys/mount.h>
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
#include <fs/devfs/devfs.h>
#include <fs/devfs/devfs_int.h>
#undef _KERNEL
#include <nfs/nfsproto.h>
#include <nfsclient/nfs.h>
#include <nfsclient/nfsnode.h>
#include <assert.h>
#include <err.h>
#include <kvm.h>
#include <stddef.h>
#include <string.h>
#include <libprocstat.h>
#include "common_kvm.h"
int
kvm_read_all(kvm_t *kd, unsigned long addr, void *buf, size_t nbytes)
{
ssize_t error;
if (nbytes >= SSIZE_MAX)
return (0);
error = kvm_read(kd, addr, buf, nbytes);
return (error == (ssize_t)(nbytes));
}
int
kdevtoname(kvm_t *kd, struct cdev *dev, char *buf)
{
struct cdev si;
assert(buf);
if (!kvm_read_all(kd, (unsigned long)dev, &si, sizeof(si)))
return (1);
strlcpy(buf, si.__si_namebuf, SPECNAMELEN + 1);
return (0);
}
int
ufs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
struct inode inode;
if (!kvm_read_all(kd, (unsigned long)VTOI(vp), &inode, sizeof(inode))) {
warnx("can't read inode at %p", (void *)VTOI(vp));
return (1);
}
/*
* The st_dev from stat(2) is a dev_t. These kernel structures
* contain cdev pointers. We need to convert to dev_t to make
* comparisons
*/
vn->vn_fsid = dev2udev(kd, inode.i_dev);
vn->vn_fileid = (long)inode.i_number;
vn->vn_mode = (mode_t)inode.i_mode;
vn->vn_size = (u_long)inode.i_size;
return (0);
}
int
devfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
struct devfs_dirent devfs_dirent;
struct mount mount;
if (!kvm_read_all(kd, (unsigned long)getvnodedata(vp), &devfs_dirent,
sizeof(devfs_dirent))) {
warnx("can't read devfs_dirent at %p",
(void *)vp->v_data);
return (1);
}
if (!kvm_read_all(kd, (unsigned long)getvnodemount(vp), &mount,
sizeof(mount))) {
warnx("can't read mount at %p",
(void *)getvnodemount(vp));
return (1);
}
vn->vn_fsid = mount.mnt_stat.f_fsid.val[0];
vn->vn_fileid = devfs_dirent.de_inode;
vn->vn_mode = (devfs_dirent.de_mode & ~S_IFMT) | S_IFCHR;
vn->vn_size = 0;
return (0);
}
int
nfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
struct nfsnode nfsnode;
mode_t mode;
if (!kvm_read_all(kd, (unsigned long)VTONFS(vp), &nfsnode,
sizeof(nfsnode))) {
warnx("can't read nfsnode at %p",
(void *)VTONFS(vp));
return (1);
}
vn->vn_fsid = nfsnode.n_vattr.va_fsid;
vn->vn_fileid = nfsnode.n_vattr.va_fileid;
vn->vn_size = nfsnode.n_size;
mode = (mode_t)nfsnode.n_vattr.va_mode;
switch (vp->v_type) {
case VREG:
mode |= S_IFREG;
break;
case VDIR:
mode |= S_IFDIR;
break;
case VBLK:
mode |= S_IFBLK;
break;
case VCHR:
mode |= S_IFCHR;
break;
case VLNK:
mode |= S_IFLNK;
break;
case VSOCK:
mode |= S_IFSOCK;
break;
case VFIFO:
mode |= S_IFIFO;
break;
default:
break;
};
vn->vn_mode = mode;
return (0);
}
/*
* Read the cdev structure in the kernel in order to work out the
* associated dev_t
*/
dev_t
dev2udev(kvm_t *kd, struct cdev *dev)
{
struct cdev_priv priv;
assert(kd);
if (kvm_read_all(kd, (unsigned long)cdev2priv(dev), &priv,
sizeof(priv))) {
return ((dev_t)priv.cdp_inode);
} else {
warnx("can't convert cdev *%p to a dev_t\n", dev);
return (-1);
}
}
void *
getvnodedata(struct vnode *vp)
{
return (vp->v_data);
}
struct mount *
getvnodemount(struct vnode *vp)
{
return (vp->v_mount);
}
+53
View File
@@ -0,0 +1,53 @@
/*-
* Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org>
* 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.
*
* 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.
*
* $FreeBSD$
*/
#ifndef _COMMON_KVM_H_
#define _COMMON_KVM_H_
dev_t dev2udev(kvm_t *kd, struct cdev *dev);
int kdevtoname(kvm_t *kd, struct cdev *dev, char *);
int kvm_read_all(kvm_t *kd, unsigned long addr, void *buf,
size_t nbytes);
/*
* Filesystems specific access routines.
*/
int devfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int isofs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int msdosfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int nfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int ntfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int nwfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int smbfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int udf_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int ufs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
int zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
void *getvnodedata(struct vnode *vp);
struct mount *getvnodemount(struct vnode *vp);
#endif /* _COMMON_KVM_H_ */
File diff suppressed because it is too large Load Diff
+160
View File
@@ -0,0 +1,160 @@
/*-
* Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org>
* 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.
*
* 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.
*
* $FreeBSD$
*/
#ifndef _LIBPROCSTAT_H_
#define _LIBPROCSTAT_H_
/*
* Vnode types.
*/
#define PS_FST_VTYPE_VNON 1
#define PS_FST_VTYPE_VREG 2
#define PS_FST_VTYPE_VDIR 3
#define PS_FST_VTYPE_VBLK 4
#define PS_FST_VTYPE_VCHR 5
#define PS_FST_VTYPE_VLNK 6
#define PS_FST_VTYPE_VSOCK 7
#define PS_FST_VTYPE_VFIFO 8
#define PS_FST_VTYPE_VBAD 9
#define PS_FST_VTYPE_UNKNOWN 255
/*
* Descriptor types.
*/
#define PS_FST_TYPE_VNODE 1
#define PS_FST_TYPE_FIFO 2
#define PS_FST_TYPE_SOCKET 3
#define PS_FST_TYPE_PIPE 4
#define PS_FST_TYPE_PTS 5
#define PS_FST_TYPE_KQUEUE 6
#define PS_FST_TYPE_CRYPTO 7
#define PS_FST_TYPE_MQUEUE 8
#define PS_FST_TYPE_SHM 9
#define PS_FST_TYPE_SEM 10
#define PS_FST_TYPE_UNKNOWN 11
#define PS_FST_TYPE_NONE 12
/*
* Special descriptor numbers.
*/
#define PS_FST_UFLAG_RDIR 0x0001
#define PS_FST_UFLAG_CDIR 0x0002
#define PS_FST_UFLAG_JAIL 0x0004
#define PS_FST_UFLAG_TRACE 0x0008
#define PS_FST_UFLAG_TEXT 0x0010
#define PS_FST_UFLAG_MMAP 0x0020
#define PS_FST_UFLAG_CTTY 0x0040
/*
* Descriptor flags.
*/
#define PS_FST_FFLAG_READ 0x0001
#define PS_FST_FFLAG_WRITE 0x0002
#define PS_FST_FFLAG_NONBLOCK 0x0004
#define PS_FST_FFLAG_APPEND 0x0008
#define PS_FST_FFLAG_SHLOCK 0x0010
#define PS_FST_FFLAG_EXLOCK 0x0020
#define PS_FST_FFLAG_ASYNC 0x0040
#define PS_FST_FFLAG_SYNC 0x0080
#define PS_FST_FFLAG_NOFOLLOW 0x0100
#define PS_FST_FFLAG_CREAT 0x0200
#define PS_FST_FFLAG_TRUNC 0x0400
#define PS_FST_FFLAG_EXCL 0x0800
#define PS_FST_FFLAG_DIRECT 0x1000
#define PS_FST_FFLAG_EXEC 0x2000
#define PS_FST_FFLAG_HASLOCK 0x4000
struct procstat;
struct filestat {
int fs_type; /* Descriptor type. */
int fs_flags; /* filestat specific flags. */
int fs_fflags; /* Descriptor access flags. */
int fs_uflags; /* How this file is used. */
int fs_fd; /* File descriptor number. */
int fs_ref_count; /* Reference count. */
off_t fs_offset; /* Seek location. */
void *fs_typedep; /* Type dependent data. */
char *fs_path;
STAILQ_ENTRY(filestat) next;
};
struct vnstat {
uint64_t vn_fileid;
uint64_t vn_size;
char *vn_mntdir;
uint32_t vn_dev;
uint32_t vn_fsid;
int vn_type;
uint16_t vn_mode;
char vn_devname[SPECNAMELEN + 1];
};
struct ptsstat {
uint32_t dev;
char devname[SPECNAMELEN + 1];
};
struct pipestat {
size_t buffer_cnt;
uint64_t addr;
uint64_t peer;
};
struct sockstat {
uint64_t inp_ppcb;
uint64_t so_addr;
uint64_t so_pcb;
uint64_t unp_conn;
int dom_family;
int proto;
int so_rcv_sb_state;
int so_snd_sb_state;
struct sockaddr_storage sa_local; /* Socket address. */
struct sockaddr_storage sa_peer; /* Peer address. */
int type;
char dname[32];
};
STAILQ_HEAD(filestat_list, filestat);
void procstat_close(struct procstat *procstat);
void procstat_freeprocs(struct procstat *procstat, struct kinfo_proc *p);
void procstat_freefiles(struct procstat *procstat,
struct filestat_list *head);
struct filestat_list *procstat_getfiles(struct procstat *procstat,
struct kinfo_proc *kp, int mmapped);
struct kinfo_proc *procstat_getprocs(struct procstat *procstat,
int what, int arg, unsigned int *count);
int procstat_get_pipe_info(struct procstat *procstat, struct filestat *fst,
struct pipestat *pipe, char *errbuf);
int procstat_get_pts_info(struct procstat *procstat, struct filestat *fst,
struct ptsstat *pts, char *errbuf);
int procstat_get_socket_info(struct procstat *procstat, struct filestat *fst,
struct sockstat *sock, char *errbuf);
int procstat_get_vnode_info(struct procstat *procstat, struct filestat *fst,
struct vnstat *vn, char *errbuf);
struct procstat *procstat_open_sysctl(void);
struct procstat *procstat_open_kvm(const char *nlistf, const char *memf);
#endif /* !_LIBPROCSTAT_H_ */
+39
View File
@@ -0,0 +1,39 @@
/*-
* Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org>
* 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.
*
* 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.
*
* $FreeBSD$
*/
#ifndef _LIBPROCSTAT_INTERNAL_H_
#define _LIBPROCSTAT_INTERNAL_H_
struct procstat {
int type;
kvm_t *kd;
void *vmentries;
void *files;
};
#endif /* !_LIBPROCSTAT_INTERNAL_H_ */
+153
View File
@@ -0,0 +1,153 @@
/*
* Copyright (c) 2000 Peter Edwards
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by Peter Edwards
*
* 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>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/vnode.h>
#include <netinet/in.h>
#define _KERNEL
#include <sys/mount.h>
#include <fs/msdosfs/bpb.h>
#include <fs/msdosfs/msdosfsmount.h>
#undef _KERNEL
#include <fs/msdosfs/denode.h>
#include <fs/msdosfs/direntry.h>
#include <fs/msdosfs/fat.h>
#include <err.h>
#include <kvm.h>
#include <stdio.h>
#include <stdlib.h>
/*
* XXX -
* VTODE is defined in denode.h only if _KERNEL is defined, but that leads to
* header explosion
*/
#define VTODE(vp) ((struct denode *)getvnodedata(vp))
#include "libprocstat.h"
#include "common_kvm.h"
struct dosmount {
struct dosmount *next;
struct msdosfsmount *kptr; /* Pointer in kernel space */
struct msdosfsmount data; /* User space copy of structure */
};
int
msdosfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
struct denode denode;
static struct dosmount *mounts;
struct dosmount *mnt;
u_long dirsperblk;
int fileid;
if (!kvm_read_all(kd, (unsigned long)VTODE(vp), &denode,
sizeof(denode))) {
warnx("can't read denode at %p", (void *)VTODE(vp));
return (1);
}
/*
* Find msdosfsmount structure for the vnode's filesystem. Needed
* for some filesystem parameters
*/
for (mnt = mounts; mnt; mnt = mnt->next)
if (mnt->kptr == denode.de_pmp)
break;
if (!mnt) {
if ((mnt = malloc(sizeof(struct dosmount))) == NULL) {
warn("malloc()");
return (1);
}
if (!kvm_read_all(kd, (unsigned long)denode.de_pmp,
&mnt->data, sizeof(mnt->data))) {
free(mnt);
warnx("can't read mount info at %p",
(void *)denode.de_pmp);
return (1);
}
mnt->next = mounts;
mounts = mnt;
mnt->kptr = denode.de_pmp;
}
vn->vn_fsid = dev2udev(kd, mnt->data.pm_dev);
vn->vn_mode = 0555;
vn->vn_mode |= denode.de_Attributes & ATTR_READONLY ? 0 : 0222;
vn->vn_mode &= mnt->data.pm_mask;
/* Distinguish directories and files. No "special" files in FAT. */
vn->vn_mode |= denode.de_Attributes & ATTR_DIRECTORY ? S_IFDIR : S_IFREG;
vn->vn_size = denode.de_FileSize;
/*
* XXX -
* Culled from msdosfs_vnops.c. There appears to be a problem
* here, in that a directory has the same inode number as the first
* file in the directory. stat(2) suffers from this problem also, so
* I won't try to fix it here.
*
* The following computation of the fileid must be the same as that
* used in msdosfs_readdir() to compute d_fileno. If not, pwd
* doesn't work.
*/
dirsperblk = mnt->data.pm_BytesPerSec / sizeof(struct direntry);
if (denode.de_Attributes & ATTR_DIRECTORY) {
fileid = cntobn(&mnt->data, denode.de_StartCluster)
* dirsperblk;
if (denode.de_StartCluster == MSDOSFSROOT)
fileid = 1;
} else {
fileid = cntobn(&mnt->data, denode.de_dirclust) * dirsperblk;
if (denode.de_dirclust == MSDOSFSROOT)
fileid = roottobn(&mnt->data, 0) * dirsperblk;
fileid += denode.de_diroffset / sizeof(struct direntry);
}
vn->vn_fileid = fileid;
return (0);
}
+71
View File
@@ -0,0 +1,71 @@
/*-
* Copyright (c) 2005-2009 Stanislav Sedov <stas@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/vnode.h>
#include <sys/mount.h>
#include <netinet/in.h>
#include <assert.h>
#include <err.h>
#include <kvm.h>
#include <stdlib.h>
#include <fs/ntfs/ntfs.h>
#include <fs/ntfs/ntfs_inode.h>
#include "libprocstat.h"
#include "common_kvm.h"
int
ntfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
struct fnode fnod;
struct ntnode node;
int error;
assert(kd);
assert(vn);
error = kvm_read_all(kd, (unsigned long)VTOF(vp), &fnod, sizeof(fnod));
if (error != 0) {
warnx("can't read ntfs fnode at %p", (void *)VTOF(vp));
return (1);
}
error = kvm_read_all(kd, (unsigned long)FTONT(&fnod), &node,
sizeof(node));
if (error != 0) {
warnx("can't read ntfs node at %p", (void *)FTONT(&fnod));
return (1);
}
vn->vn_fileid = node.i_number;
vn->vn_fsid = dev2udev(kd, node.i_dev);
return (0);
}
+76
View File
@@ -0,0 +1,76 @@
/*-
* Copyright (c) 2005-2009 Stanislav Sedov <stas@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/vnode.h>
#define _KERNEL
#include <sys/mount.h>
#undef _KERNEL
#include <netinet/in.h>
#include <assert.h>
#include <err.h>
#include <kvm.h>
#include <stdlib.h>
#include <fs/nwfs/nwfs.h>
#include <fs/nwfs/nwfs_node.h>
#include "libprocstat.h"
#include "common_kvm.h"
int
nwfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
struct mount mnt;
struct nwnode node;
int error;
assert(kd);
assert(vn);
error = kvm_read_all(kd, (unsigned long)VTONW(vp), &node, sizeof(node));
if (error != 0) {
warnx("can't read nwfs fnode at %p", (void *)VTONW(vp));
return (1);
}
error = kvm_read_all(kd, (unsigned long)getvnodemount(vp), &mnt,
sizeof(mnt));
if (error != 0) {
warnx("can't read mount at %p for vnode %p",
(void *)getvnodemount(vp), vp);
return (1);
}
vn->vn_fileid = node.n_fid.f_id;
if (vn->vn_fileid == 0)
vn->vn_fileid = NWFS_ROOT_INO;
vn->vn_fsid = mnt.mnt_stat.f_fsid.val[0];
return (0);
}
+77
View File
@@ -0,0 +1,77 @@
/*-
* Copyright (c) 2005-2009 Stanislav Sedov <stas@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/vnode.h>
#define _KERNEL
#include <sys/mount.h>
#undef _KERNEL
#include <netinet/in.h>
#include <assert.h>
#include <err.h>
#include <kvm.h>
#include <stdlib.h>
#include <fs/smbfs/smbfs.h>
#include <fs/smbfs/smbfs_node.h>
#include "libprocstat.h"
#include "common_kvm.h"
int
smbfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
struct smbnode node;
struct mount mnt;
int error;
assert(kd);
assert(vn);
error = kvm_read_all(kd, (unsigned long)VTOSMB(vp), &node,
sizeof(node));
if (error != 0) {
warnx("can't read smbfs fnode at %p", (void *)VTOSMB(vp));
return (1);
}
error = kvm_read_all(kd, (unsigned long)getvnodemount(vp), &mnt,
sizeof(mnt));
if (error != 0) {
warnx("can't read mount at %p for vnode %p",
(void *)getvnodemount(vp), vp);
return (1);
}
vn->vn_fileid = node.n_ino;
if (vn->vn_fileid == 0)
vn->vn_fileid = 2;
vn->vn_fsid = mnt.mnt_stat.f_fsid.val[0];
return (0);
}
+102
View File
@@ -0,0 +1,102 @@
/*-
* Copyright (c) 2005-2009 Stanislav Sedov <stas@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/vnode.h>
#include <sys/buf.h>
#define _KERNEL
#include <sys/mount.h>
#undef _KERNEL
#include <netinet/in.h>
#include <assert.h>
#include <err.h>
#include <kvm.h>
#include <stdlib.h>
#include <fs/udf/ecma167-udf.h>
#include "libprocstat.h"
#include "common_kvm.h"
/* XXX */
struct udf_mnt {
int im_flags;
struct mount *im_mountp;
struct g_consumer *im_cp;
struct bufobj *im_bo;
struct cdev *im_dev;
struct vnode *im_devvp;
int bsize;
int bshift;
int bmask;
uint32_t part_start;
uint32_t part_len;
uint64_t root_id;
struct long_ad root_icb;
int p_sectors;
int s_table_entries;
void *s_table;
void *im_d2l;
};
struct udf_node {
struct vnode *i_vnode;
struct udf_mnt *udfmp;
ino_t hash_id;
long diroff;
struct file_entry *fentry;
};
#define VTON(vp) ((struct udf_node *)((vp)->v_data))
int
udf_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
struct udf_node node;
struct udf_mnt mnt;
int error;
assert(kd);
assert(vn);
error = kvm_read_all(kd, (unsigned long)VTON(vp), &node, sizeof(node));
if (error != 0) {
warnx("can't read udf fnode at %p", (void *)VTON(vp));
return (1);
}
error = kvm_read_all(kd, (unsigned long)node.udfmp, &mnt, sizeof(mnt));
if (error != 0) {
warnx("can't read udf_mnt at %p for vnode %p",
(void *)node.udfmp, vp);
return (1);
}
vn->vn_fileid = node.hash_id;
vn->vn_fsid = dev2udev(kd, mnt.im_dev);
return (0);
}
+134
View File
@@ -0,0 +1,134 @@
/*-
* Copyright (c) 2007 Ulf Lilleengen
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* $FreeBSD$
*/
#include <sys/param.h>
#define _KERNEL
#include <sys/mount.h>
#include <sys/taskqueue.h>
#undef _KERNEL
#include <sys/sysctl.h>
#undef lbolt
#undef lbolt64
#undef gethrestime_sec
#include <sys/zfs_context.h>
#include <sys/spa.h>
#include <sys/spa_impl.h>
#include <sys/dmu.h>
#include <sys/zap.h>
#include <sys/fs/zfs.h>
#include <sys/zfs_znode.h>
#include <sys/zfs_sa.h>
#include <netinet/in.h>
#include <err.h>
#include <kvm.h>
#include <stdio.h>
#include <stdlib.h>
#define ZFS
#include "libprocstat.h"
#include "common_kvm.h"
/*
* Offset calculations that are used to get data from znode without having the
* definition.
*/
#define LOCATION_ZID (2 * sizeof(void *))
#define LOCATION_ZPHYS(zsize) ((zsize) - (2 * sizeof(void *) + sizeof(struct task)))
int
zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
znode_phys_t zphys;
struct mount mount, *mountptr;
uint64_t *zid;
void *znodeptr, *vnodeptr;
char *dataptr;
void *zphys_addr;
size_t len;
int size;
len = sizeof(size);
if (sysctlbyname("debug.sizeof.znode", &size, &len, NULL, 0) == -1) {
warnx("error getting sysctl");
return (1);
}
znodeptr = malloc(size);
if (znodeptr == NULL) {
warnx("error allocating memory for znode storage");
return (1);
}
/* Since we have problems including vnode.h, we'll use the wrappers. */
vnodeptr = getvnodedata(vp);
if (!kvm_read_all(kd, (unsigned long)vnodeptr, znodeptr,
(size_t)size)) {
warnx("can't read znode at %p", (void *)vnodeptr);
goto bad;
}
/*
* z_id field is stored in the third pointer. We therefore skip the two
* first bytes.
*
* Pointer to the z_phys structure is the next last pointer. Therefore
* go back two bytes from the end.
*/
dataptr = znodeptr;
zid = (uint64_t *)(dataptr + LOCATION_ZID);
zphys_addr = *(void **)(dataptr + LOCATION_ZPHYS(size));
if (!kvm_read_all(kd, (unsigned long)zphys_addr, &zphys,
sizeof(zphys))) {
warnx("can't read znode_phys at %p", zphys_addr);
goto bad;
}
/* Get the mount pointer, and read from the address. */
mountptr = getvnodemount(vp);
if (!kvm_read_all(kd, (unsigned long)mountptr, &mount, sizeof(mount))) {
warnx("can't read mount at %p", (void *)mountptr);
goto bad;
}
vn->vn_fsid = mount.mnt_stat.f_fsid.val[0];
vn->vn_fileid = *zid;
/*
* XXX: Shows up wrong in output, but UFS has this error too. Could
* be that we're casting mode-variables from 64-bit to 8-bit or simply
* error in the mode-to-string function.
*/
vn->vn_mode = (mode_t)zphys.zp_mode;
vn->vn_size = (u_long)zphys.zp_size;
free(znodeptr);
return (0);
bad:
free(znodeptr);
return (1);
}
+23
View File
@@ -0,0 +1,23 @@
# $FreeBSD$
.PATH: ${.CURDIR}/..
SRCS= zfs.c
OBJS= zfs.o
WARNS?= 1
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include
CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
CFLAGS+= -I${.CURDIR}/..
CFLAGS+= -DNEED_SOLARIS_BOOLEAN
all: ${OBJS}
CLEANFILES= ${OBJS}
.include <bsd.lib.mk>