4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
33 * Cache FS admin utility. Used to glean information out of the
34 * rootfs, frontfs, and backfs variables in the kernel.
49 #include <sys/param.h>
50 #include <sys/types.h>
51 #include <sys/filio.h>
53 #include <sys/statvfs.h>
54 #include <sys/fs/cachefs_fs.h>
55 #include <sys/fs/cachefs_dir.h>
58 static void pr_err(char *fmt
, ...);
59 static void usage(char *);
66 * Main routine for the cfsfstype program.
68 * argc number of command line arguments
69 * argv command line arguments
71 * Returns 0 for failure, > 0 for an error.
76 main(int argc
, char **argv
)
83 /* verify root running command */
85 pr_err(gettext("must be run by root"));
89 (void) setlocale(LC_ALL
, "");
90 #if !defined(TEXT_DOMAIN)
91 #define TEXT_DOMAIN "SYS_TEST"
93 (void) textdomain(TEXT_DOMAIN
);
95 /* parse the command line arguments */
96 while ((c
= getopt(argc
, argv
, "n")) != EOF
) {
104 usage(gettext("illegal option"));
111 usage(gettext("too many file names specified"));
115 /* if just path is specified, just statvfs it */
118 usage(gettext("no file name"));
121 if (statvfs64(*argv
, &svb
) < 0) {
122 pr_err(gettext("Cannot open %s: %s"), *argv
,
126 (void) printf("%s\n", svb
.f_basetype
);
130 fd
= open("/", O_RDONLY
);
132 perror(gettext("Open of root directory"));
138 fd
= open(*argv
, O_RDONLY
);
140 perror(gettext("open of specified directory"));
145 if (ioctl(fd
, _FIOSTOPCACHE
)) {
146 perror(gettext("Convert ioctl fault"));
157 * Prints a usage message for this utility.
159 * msgp message to include with the usage message
168 fprintf(stderr
, gettext("cfsfstype: %s\n"), msgp
);
169 fprintf(stderr
, gettext("usage: cfsfstype file\n"));
177 * Prints an error message to stderr.
179 * fmt printf style format
180 * ... arguments for fmt
187 pr_err(char *fmt
, ...)
192 (void) fprintf(stderr
, gettext("cfsfstype: "));
193 (void) vfprintf(stderr
, fmt
, ap
);
194 (void) fprintf(stderr
, "\n");