[Midnightbsd-cvs] src [11491] trunk/usr.bin/lsvfs/lsvfs.c: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jul 7 13:32:00 EDT 2018


Revision: 11491
          http://svnweb.midnightbsd.org/src/?rev=11491
Author:   laffer1
Date:     2018-07-07 13:31:59 -0400 (Sat, 07 Jul 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/usr.bin/lsvfs/Makefile
    trunk/usr.bin/lsvfs/lsvfs.1
    trunk/usr.bin/lsvfs/lsvfs.c

Property Changed:
----------------
    trunk/usr.bin/lsvfs/lsvfs.1

Modified: trunk/usr.bin/lsvfs/Makefile
===================================================================
--- trunk/usr.bin/lsvfs/Makefile	2018-07-07 17:31:44 UTC (rev 11490)
+++ trunk/usr.bin/lsvfs/Makefile	2018-07-07 17:31:59 UTC (rev 11491)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/lsvfs/Makefile 201386 2010-01-02 10:27:05Z ed $
 
 PROG=	lsvfs
 

Modified: trunk/usr.bin/lsvfs/lsvfs.1
===================================================================
--- trunk/usr.bin/lsvfs/lsvfs.1	2018-07-07 17:31:44 UTC (rev 11490)
+++ trunk/usr.bin/lsvfs/lsvfs.1	2018-07-07 17:31:59 UTC (rev 11491)
@@ -1,8 +1,9 @@
 .\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/lsvfs/lsvfs.1 251580 2013-06-09 16:33:32Z hrs $
 .\" 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 +37,8 @@
 .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 +47,7 @@
 .El
 .Sh SEE ALSO
 .Xr mount 2 ,
+.Xr getvfsbyname 3 ,
 .Xr mount 8
 .Sh HISTORY
 A


Property changes on: trunk/usr.bin/lsvfs/lsvfs.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/lsvfs/lsvfs.c
===================================================================
--- trunk/usr.bin/lsvfs/lsvfs.c	2018-07-07 17:31:44 UTC (rev 11490)
+++ trunk/usr.bin/lsvfs/lsvfs.c	2018-07-07 17:31:59 UTC (rev 11491)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * lsvfs - list loaded VFSes
  * Garrett A. Wollman, September 1994
@@ -6,7 +7,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/lsvfs/lsvfs.c 251580 2013-06-09 16:33:32Z hrs $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -17,10 +18,25 @@
 #include <stdlib.h>
 #include <string.h>
 
-#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);
 
 int
@@ -31,13 +47,14 @@
   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 +71,8 @@
     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 +83,16 @@
 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;
+	static char buf[sizeof(struct flaglist) * sizeof(fl)];
+	int i;
 
-  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';
-
-  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);
 }



More information about the Midnightbsd-cvs mailing list