diff options
author | Cameron Katri <me@cameronkatri.com> | 2021-05-09 14:20:58 -0400 |
---|---|---|
committer | Cameron Katri <me@cameronkatri.com> | 2021-05-09 14:20:58 -0400 |
commit | 5fd83771641d15c418f747bd343ba6738d3875f7 (patch) | |
tree | 5abf0f78f680d9837dbd93d4d4c3933bb7509599 /adv_cmds/lsvfs | |
download | apple_cmds-5fd83771641d15c418f747bd343ba6738d3875f7.tar.gz apple_cmds-5fd83771641d15c418f747bd343ba6738d3875f7.tar.zst apple_cmds-5fd83771641d15c418f747bd343ba6738d3875f7.zip |
Import macOS userland
adv_cmds-176
basic_cmds-55
bootstrap_cmds-116.100.1
developer_cmds-66
diskdev_cmds-667.40.1
doc_cmds-53.60.1
file_cmds-321.40.3
mail_cmds-35
misc_cmds-34
network_cmds-606.40.1
patch_cmds-17
remote_cmds-63
shell_cmds-216.60.1
system_cmds-880.60.2
text_cmds-106
Diffstat (limited to 'adv_cmds/lsvfs')
-rw-r--r-- | adv_cmds/lsvfs/lsvfs.1 | 67 | ||||
-rw-r--r-- | adv_cmds/lsvfs/lsvfs.c | 99 |
2 files changed, 166 insertions, 0 deletions
diff --git a/adv_cmds/lsvfs/lsvfs.1 b/adv_cmds/lsvfs/lsvfs.1 new file mode 100644 index 0000000..411ea17 --- /dev/null +++ b/adv_cmds/lsvfs/lsvfs.1 @@ -0,0 +1,67 @@ +.\" Copyright (c) 1998-2003 Apple Computer, Inc. All rights reserved. +.\" +.\" @APPLE_LICENSE_HEADER_START@ +.\" +.\" The contents of this file constitute Original Code as defined in and +.\" are subject to the Apple Public Source License Version 1.1 (the +.\" "License"). You may not use this file except in compliance with the +.\" License. Please obtain a copy of the License at +.\" http://www.apple.com/publicsource and read it before using this file. +.\" +.\" This Original Code and all software distributed under the License are +.\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER +.\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +.\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +.\" FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the +.\" License for the specific language governing rights and limitations +.\" under the License. +.\" +.\" @APPLE_LICENSE_HEADER_END@ +.\" +.Dd January 4, 2003 +.Dt LSVFS 1 +.Os +.Sh NAME +.Nm lsvfs +.Nd list known virtual file systems +.Sh SYNOPSIS +.Nm +.Op Ar vfsname Ar ... +.Sh DESCRIPTION +The +.Nm +command lists information about the currently loaded virtual filesystem +modules. +When +.Ar vfsname +arguments are given, +.Nm +lists information about the specified VFS modules. +Otherwise, +.Nm +lists all currently loaded modules. +The information is as follows: +.Pp +.Bl -tag -compact -width Filesystem +.It Filesystem +the name of the filesystem, as would be used in the +.Ar type +parameter to +.Xr mount 2 +and the +.Fl t +option to +.Xr mount 8 +.It Refs +the number of references to this VFS; i.e., the number of currently +mounted filesystems of this type +.It Flags +flag bits +.El +.Sh SEE ALSO +.Xr mount 2 , +.Xr mount 8 +.Sh HISTORY +The command from which this tool was derived, as well as this manual, +originally appeared in +.Fx 2.0 . diff --git a/adv_cmds/lsvfs/lsvfs.c b/adv_cmds/lsvfs/lsvfs.c new file mode 100644 index 0000000..73f4135 --- /dev/null +++ b/adv_cmds/lsvfs/lsvfs.c @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1998-2003 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#include <sys/mount.h> +#include <sys/types.h> +#include <sys/sysctl.h> + +#include <err.h> +#include <errno.h> +#include <stdio.h> +#include <string.h> + +#define FMT "%-32.32s %5d %s\n" +#define HDRFMT "%-32.32s %5.5s %s\n" +#define DASHES "-------------------------------- ----- ---------------\n" + +static const char *fmt_flags(int flags); + +int +main(int argc, char *argv[]) +{ + struct vfsconf vfc; + int mib[4], max, x; + size_t len; + + printf(HDRFMT, "Filesystem", "Refs", "Flags"); + fputs(DASHES, stdout); + + if (argc > 1) { + for (x = 1; x < argc; x++) + if (getvfsbyname(argv[x], &vfc) == 0) + printf(FMT, vfc.vfc_name, vfc.vfc_refcount, + fmt_flags(vfc.vfc_flags)); + else + warnx("VFS %s unknown or not loaded", argv[x]); + } else { + mib[0] = CTL_VFS; + mib[1] = VFS_GENERIC; + mib[2] = VFS_MAXTYPENUM; + len = sizeof(int); + if (sysctl(mib, 3, &max, &len, NULL, 0) != 0) + errx(1, "sysctl"); + mib[2] = VFS_CONF; + + len = sizeof(vfc); + for (x = 0; x < max; x++) { + mib[3] = x; + if (sysctl(mib, 4, &vfc, &len, NULL, 0) != 0) { + if (errno != ENOTSUP) + errx(1, "sysctl"); + } else { + printf(FMT, vfc.vfc_name, vfc.vfc_refcount, + fmt_flags(vfc.vfc_flags)); + } + } + } + + return 0; +} + +static const char * +fmt_flags(int flags) +{ + static char buf[sizeof "local, dovolfs"]; + int comma = 0; + + buf[0] = '\0'; + + if(flags & MNT_LOCAL) { + if(comma++) strcat(buf, ", "); + strcat(buf, "local"); + } + + if(flags & MNT_DOVOLFS) { + if(comma++) strcat(buf, ", "); + strcat(buf, "dovolfs"); + } + + return buf; +} |