From owner-svn-src-projects@FreeBSD.ORG Sun Jul 26 08:47:01 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 10BCD106566B; Sun, 26 Jul 2009 08:47:01 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F14BD8FC16; Sun, 26 Jul 2009 08:47:00 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n6Q8l0qY064693; Sun, 26 Jul 2009 08:47:00 GMT (envelope-from stas@svn.freebsd.org) Received: (from stas@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n6Q8l0Dp064688; Sun, 26 Jul 2009 08:47:00 GMT (envelope-from stas@svn.freebsd.org) Message-Id: <200907260847.n6Q8l0Dp064688@svn.freebsd.org> From: Stanislav Sedov Date: Sun, 26 Jul 2009 08:47:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195887 - projects/libprocstat/usr.bin/fstat X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Jul 2009 08:47:01 -0000 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 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 + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#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 + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#define _KERNEL +#include +#undef _KERNEL + +#include +#include +#include +#include + +#include +#include + +#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 + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#define _KERNEL +#include +#undef _KERNEL + +#include +#include +#include +#include + +#include +#include + +#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 + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#define _KERNEL +#include +#undef _KERNEL + +#include +#include +#include +#include + +#include + +#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); +}