From owner-svn-src-all@FreeBSD.ORG Sun Jun 16 07:18:08 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 41FB8980; Sun, 16 Jun 2013 07:18:08 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 32A0E1D2E; Sun, 16 Jun 2013 07:18:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5G7I8n0016708; Sun, 16 Jun 2013 07:18:08 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5G7I714016705; Sun, 16 Jun 2013 07:18:07 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201306160718.r5G7I714016705@svn.freebsd.org> From: Hiroki Sato Date: Sun, 16 Jun 2013 07:18:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251802 - stable/9/usr.bin/lsvfs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Jun 2013 07:18:08 -0000 Author: hrs Date: Sun Jun 16 07:18:07 2013 New Revision: 251802 URL: http://svnweb.freebsd.org/changeset/base/251802 Log: MFC r251580: - Add file system type number (vfc_typenum) in the list. This is useful for debugging when changing vfs.typenumhash configuration. - Refactor fmt_flags(). Modified: stable/9/usr.bin/lsvfs/lsvfs.1 stable/9/usr.bin/lsvfs/lsvfs.c Directory Properties: stable/9/usr.bin/lsvfs/ (props changed) Modified: stable/9/usr.bin/lsvfs/lsvfs.1 ============================================================================== --- stable/9/usr.bin/lsvfs/lsvfs.1 Sun Jun 16 07:16:44 2013 (r251801) +++ stable/9/usr.bin/lsvfs/lsvfs.1 Sun Jun 16 07:18:07 2013 (r251802) @@ -2,7 +2,7 @@ .\" Garrett A. Wollman, September 1994 .\" This file is in the public domain. .\" -.Dd March 16, 1995 +.Dd June 9, 2013 .Dt LSVFS 1 .Os .Sh NAME @@ -36,6 +36,8 @@ and the .Fl t option to .Xr mount 8 +.It Num +the filesystem type number. .It Refs the number of references to this VFS; i.e., the number of currently mounted file systems of this type @@ -44,6 +46,7 @@ flag bits. .El .Sh SEE ALSO .Xr mount 2 , +.Xr getvfsbyname 3 , .Xr mount 8 .Sh HISTORY A Modified: stable/9/usr.bin/lsvfs/lsvfs.c ============================================================================== --- stable/9/usr.bin/lsvfs/lsvfs.c Sun Jun 16 07:16:44 2013 (r251801) +++ stable/9/usr.bin/lsvfs/lsvfs.c Sun Jun 16 07:18:07 2013 (r251802) @@ -17,9 +17,24 @@ __FBSDID("$FreeBSD$"); #include #include -#define FMT "%-32.32s %5d %s\n" -#define HDRFMT "%-32.32s %5.5s %s\n" -#define DASHES "-------------------------------- ----- ---------------\n" +#define FMT "%-32.32s 0x%08x %5d %s\n" +#define HDRFMT "%-32.32s %10s %5.5s %s\n" +#define DASHES "-------------------------------- " \ + "---------- ----- ---------------\n" + +static struct flaglist { + int flag; + const char str[32]; /* must be longer than the longest one. */ +} fl[] = { + { .flag = VFCF_STATIC, .str = "static", }, + { .flag = VFCF_NETWORK, .str = "network", }, + { .flag = VFCF_READONLY, .str = "read-only", }, + { .flag = VFCF_SYNTHETIC, .str = "synthetic", }, + { .flag = VFCF_LOOPBACK, .str = "loopback", }, + { .flag = VFCF_UNICODE, .str = "unicode", }, + { .flag = VFCF_JAIL, .str = "jail", }, + { .flag = VFCF_DELEGADMIN, .str = "delegated-administration", }, +}; static const char *fmt_flags(int); @@ -31,13 +46,14 @@ main(int argc, char **argv) size_t buflen; argc--, argv++; - printf(HDRFMT, "Filesystem", "Refs", "Flags"); + printf(HDRFMT, "Filesystem", "Num", "Refs", "Flags"); fputs(DASHES, stdout); if(argc) { for(; argc; argc--, argv++) { if (getvfsbyname(*argv, &vfc) == 0) { - printf(FMT, vfc.vfc_name, vfc.vfc_refcount, fmt_flags(vfc.vfc_flags)); + printf(FMT, vfc.vfc_name, vfc.vfc_typenum, vfc.vfc_refcount, + fmt_flags(vfc.vfc_flags)); } else { warnx("VFS %s unknown or not loaded", *argv); rv++; @@ -54,8 +70,8 @@ main(int argc, char **argv) cnt = buflen / sizeof(struct xvfsconf); for (i = 0; i < cnt; i++) { - printf(FMT, xvfsp[i].vfc_name, xvfsp[i].vfc_refcount, - fmt_flags(xvfsp[i].vfc_flags)); + printf(FMT, xvfsp[i].vfc_name, xvfsp[i].vfc_typenum, + xvfsp[i].vfc_refcount, fmt_flags(xvfsp[i].vfc_flags)); } free(xvfsp); } @@ -66,34 +82,16 @@ main(int argc, char **argv) static const char * fmt_flags(int flags) { - /* - * NB: if you add new flags, don't forget to add them here vvvvvv too. - */ - static char buf[sizeof - "static, network, read-only, synthetic, loopback, unicode, jail"]; - size_t len; - - buf[0] = '\0'; - - if(flags & VFCF_STATIC) - strlcat(buf, "static, ", sizeof(buf)); - if(flags & VFCF_NETWORK) - strlcat(buf, "network, ", sizeof(buf)); - if(flags & VFCF_READONLY) - strlcat(buf, "read-only, ", sizeof(buf)); - if(flags & VFCF_SYNTHETIC) - strlcat(buf, "synthetic, ", sizeof(buf)); - if(flags & VFCF_LOOPBACK) - strlcat(buf, "loopback, ", sizeof(buf)); - if(flags & VFCF_UNICODE) - strlcat(buf, "unicode, ", sizeof(buf)); - if(flags & VFCF_JAIL) - strlcat(buf, "jail, ", sizeof(buf)); - if(flags & VFCF_DELEGADMIN) - strlcat(buf, "delegated-administration, ", sizeof(buf)); - len = strlen(buf); - if (len > 2 && buf[len - 2] == ',') - buf[len - 2] = '\0'; + static char buf[sizeof(struct flaglist) * sizeof(fl)]; + int i; - return buf; + buf[0] = '\0'; + for (i = 0; i < (int)nitems(fl); i++) + if (flags & fl[i].flag) { + strlcat(buf, fl[i].str, sizeof(buf)); + strlcat(buf, ", ", sizeof(buf)); + } + if (buf[0] != '\0') + buf[strlen(buf) - 2] = '\0'; + return (buf); }