2 * lsvfs - list loaded VFSes
3 * Garrett A. Wollman, September 1994
4 * This file is in the public domain.
6 * $FreeBSD: src/usr.bin/lsvfs/lsvfs.c,v 1.13.2.1 2001/07/30 09:59:16 dd Exp $
10 #include <sys/mount.h>
16 #define FMT "%-32.32s 0x%08x %5d %s\n"
17 #define HDRFMT "%-32.32s %10s %5.5s %s\n"
18 #define DASHES "-------------------------------- " \
19 "---------- ----- ---------------\n"
21 static struct flaglist {
23 const char str[32]; /* must be longer than the longest one. */
25 { .flag = VFCF_STATIC, .str = "static", },
26 { .flag = VFCF_NETWORK, .str = "network", },
27 { .flag = VFCF_READONLY, .str = "read-only", },
28 { .flag = VFCF_SYNTHETIC, .str = "synthetic", },
29 { .flag = VFCF_LOOPBACK, .str = "loopback", },
30 { .flag = VFCF_UNICODE, .str = "unicode", },
33 static const char *fmt_flags(int);
36 main(int argc, char **argv)
40 struct ovfsconf *ovfcp;
45 printf(HDRFMT, "Filesystem", "Num", "Refs", "Flags");
46 fputs(DASHES, stdout);
49 for(; argc; argc--, argv++) {
50 if (getvfsbyname(*argv, &vfc) == 0) {
51 printf(FMT, vfc.vfc_name, vfc.vfc_typenum,
53 fmt_flags(vfc.vfc_flags));
55 warnx("VFS %s unknown or not loaded", *argv);
60 while ((ovfcp = getvfsent()) != NULL) {
61 if (getvfsbyname(ovfcp->vfc_name, &vfc) == 0) {
62 printf(FMT, vfc.vfc_name, vfc.vfc_typenum,
64 fmt_flags(vfc.vfc_flags));
66 warnx("VFS %s unknown or not loaded", *argv);
79 static char buf[sizeof(struct flaglist) * sizeof(fl)];
83 for (i = 0; i < nitems(fl); i++)
84 if (flags & fl[i].flag) {
85 strlcat(buf, fl[i].str, sizeof(buf));
86 strlcat(buf, ", ", sizeof(buf));
89 buf[strlen(buf) - 2] = '\0';