Date: Sun, 26 Jul 2009 08:47:00 +0000 (UTC) From: Stanislav Sedov <stas@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r195887 - projects/libprocstat/usr.bin/fstat Message-ID: <200907260847.n6Q8l0Dp064688@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: stas Date: Sun Jul 26 08:47:00 2009 New Revision: 195887 URL: http://svn.freebsd.org/changeset/base/195887 Log: - Add ntfs, nwfs, smbfs and udf support. Obtained from: fuser Added: projects/libprocstat/usr.bin/fstat/ntfs.c projects/libprocstat/usr.bin/fstat/nwfs.c projects/libprocstat/usr.bin/fstat/smbfs.c projects/libprocstat/usr.bin/fstat/udf.c Modified: projects/libprocstat/usr.bin/fstat/Makefile projects/libprocstat/usr.bin/fstat/common_kvm.h projects/libprocstat/usr.bin/fstat/libprocstat.c Modified: projects/libprocstat/usr.bin/fstat/Makefile ============================================================================== --- projects/libprocstat/usr.bin/fstat/Makefile Sun Jul 26 08:18:40 2009 (r195886) +++ projects/libprocstat/usr.bin/fstat/Makefile Sun Jul 26 08:47:00 2009 (r195887) @@ -4,7 +4,8 @@ .include <bsd.own.mk> PROG= fstat -SRCS= cd9660.c common_kvm.c fstat.c fuser.c libprocstat.c main.c msdosfs.c +SRCS= cd9660.c common_kvm.c fstat.c fuser.c libprocstat.c main.c \ + msdosfs.c ntfs.c nwfs.c smbfs.c udf.c LINKS= ${BINDIR}/fstat ${BINDIR}/fuser DPADD= ${LIBKVM} LDADD= -lkvm -lutil Modified: projects/libprocstat/usr.bin/fstat/common_kvm.h ============================================================================== --- projects/libprocstat/usr.bin/fstat/common_kvm.h Sun Jul 26 08:18:40 2009 (r195886) +++ projects/libprocstat/usr.bin/fstat/common_kvm.h Sun Jul 26 08:47:00 2009 (r195887) @@ -41,6 +41,10 @@ int devfs_filestat(kvm_t *kd, struct vno 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); Modified: projects/libprocstat/usr.bin/fstat/libprocstat.c ============================================================================== --- projects/libprocstat/usr.bin/fstat/libprocstat.c Sun Jul 26 08:18:40 2009 (r195886) +++ projects/libprocstat/usr.bin/fstat/libprocstat.c Sun Jul 26 08:47:00 2009 (r195887) @@ -734,12 +734,10 @@ procstat_get_vnode_info_kvm(kvm_t *kd, s #ifdef ZFS FSTYPE(zfs), #endif -/* FSTYPE(ntfs), FSTYPE(nwfs), FSTYPE(smbfs), FSTYPE(udf), -*/ }; #define NTYPES (sizeof(fstypes) / sizeof(*fstypes)) struct vnode vnode; Added: projects/libprocstat/usr.bin/fstat/ntfs.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/libprocstat/usr.bin/fstat/ntfs.c Sun Jul 26 08:47:00 2009 (r195887) @@ -0,0 +1,69 @@ +/*- + * 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 <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); +} Added: projects/libprocstat/usr.bin/fstat/nwfs.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/libprocstat/usr.bin/fstat/nwfs.c Sun Jul 26 08:47:00 2009 (r195887) @@ -0,0 +1,74 @@ +/*- + * 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 <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); +} Added: projects/libprocstat/usr.bin/fstat/smbfs.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/libprocstat/usr.bin/fstat/smbfs.c Sun Jul 26 08:47:00 2009 (r195887) @@ -0,0 +1,75 @@ +/*- + * 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 <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); +} Added: projects/libprocstat/usr.bin/fstat/udf.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/libprocstat/usr.bin/fstat/udf.c Sun Jul 26 08:47:00 2009 (r195887) @@ -0,0 +1,100 @@ +/*- + * 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 <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); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907260847.n6Q8l0Dp064688>