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 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <unistd.h> /* defines F_LOCK for lockf */
33 #include <stdlib.h> /* for getopt(3) */
37 #include <sys/types.h>
39 #include <sys/mnttab.h>
40 #include <sys/mntent.h>
41 #include <sys/mount.h>
43 #include <sys/fs/hsfs_susp.h>
44 #include <sys/fs/hsfs_rrip.h>
51 static int qflg
= 0; /* quiet option - don't flag bad options */
53 static char fstype
[] = MNTTYPE_HSFS
;
55 static char typename
[NAME_MAX
], *myname
;
57 static void rpterr(char *, char *);
58 static void usage(void);
61 main(int argc
, char **argv
)
63 char *options
, *value
;
64 char *special
, *mountp
;
67 char obuff
[MAX_MNTOPT_STR
];
68 char saved_input_options
[MAX_MNTOPT_STR
];
72 int Oflg
= 0; /* Overlay mounts */
74 (void) setlocale(LC_ALL
, "");
76 #if !defined(TEXT_DOMAIN)
77 #define TEXT_DOMAIN "SYS_TEST"
79 (void) textdomain(TEXT_DOMAIN
);
81 myname
= strrchr(argv
[0], '/');
86 snprintf(typename
, sizeof (typename
), "%s %s", fstype
, myname
);
90 * Check for arguments requiring special handling. Ignore
91 * unrecognized options.
93 strcpy(obuff
, "ro"); /* default */
94 while ((c
= getopt(argc
, argv
, "rmOq")) != EOF
) {
100 /* accept for backwards compatibility */
111 if ((argc
- optind
) != 2)
114 special
= argv
[optind
++];
115 mountp
= argv
[optind
++];
118 * Force readonly. obuff is guaranteed to have something in
119 * it. We might end up with "ro,ro", but that's acceptable.
123 if ((strlen(obuff
) + strlen(MNTOPT_RO
) + 2) > MAX_MNTOPT_STR
) {
124 (void) fprintf(stderr
, gettext("%s: option set too long\n"),
130 strcat(obuff
, MNTOPT_RO
);
132 flags
|= Oflg
? MS_OVERLAY
: 0;
134 signal(SIGHUP
, SIG_IGN
);
135 signal(SIGQUIT
, SIG_IGN
);
136 signal(SIGINT
, SIG_IGN
);
139 * Save a copy of the options to compare with the options that
140 * were actually recognized and supported by the kernel.
143 (void) strcpy(saved_input_options
, obuff
);
149 if (mount(special
, mountp
, flags
| MS_OPTIONSTR
, fstype
, NULL
, 0,
150 obuff
, sizeof (obuff
)) == -1) {
151 rpterr(special
, mountp
);
156 cmp_requested_to_actual_options(saved_input_options
, obuff
,
166 rpterr(char *bs
, char *mp
)
170 (void) fprintf(stderr
, gettext("%s: insufficient privileges\n"),
174 (void) fprintf(stderr
, gettext("%s: %s no such device\n"),
178 (void) fprintf(stderr
, gettext("%s: %s not a directory\n\tor a "
179 "component of %s is not a directory\n"), myname
, mp
, bs
);
182 (void) fprintf(stderr
,
183 gettext("%s: %s or %s, no such file or directory\n"),
187 (void) fprintf(stderr
, gettext("%s: %s is not an hsfs file "
188 "system.\n"), typename
, bs
);
191 (void) fprintf(stderr
,
192 gettext("%s: %s is already mounted or %s is busy\n"),
196 (void) fprintf(stderr
,
197 gettext("%s: %s not a block device\n"), myname
, bs
);
200 (void) fprintf(stderr
, gettext("%s: %s write-protected\n"),
204 (void) fprintf(stderr
,
205 gettext("%s: %s is corrupted. needs checking\n"),
210 (void) fprintf(stderr
, gettext("%s: cannot mount %s\n"), myname
,
221 opts
= "{-r | -o ro | -o nrr | -o nosuid | -o notraildot | -o nomaplcase}";
222 (void) fprintf(stdout
,
223 gettext("hsfs usage: mount [-F hsfs] %s {special | mount_point}\n"), opts
);
224 (void) fprintf(stdout
,
225 gettext("hsfs usage: mount [-F hsfs] %s special mount_point\n"), opts
);