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 <stdlib.h> /* for getopt(3) */
37 #include <sys/types.h>
38 #include <sys/mnttab.h>
39 #include <sys/mount.h>
44 static int roflag
= 0;
49 static char optbuf
[MAX_MNTOPT_STR
] = { '\0', };
50 static int optsize
= 0;
52 static char fstype
[] = FSTYPE
;
54 static char typename
[NAME_MAX
], *myname
;
56 static void do_mount(char *, char *, int);
57 static void rpterr(char *, char *);
58 static void usage(void);
61 main(int argc
, char **argv
)
63 char *special
, *mountp
;
67 (void) setlocale(LC_ALL
, "");
69 #if !defined(TEXT_DOMAIN)
70 #define TEXT_DOMAIN "SYS_TEST"
72 (void) textdomain(TEXT_DOMAIN
);
74 myname
= strrchr(argv
[0], '/');
80 (void) snprintf(typename
, sizeof (typename
), "%s %s", fstype
, myname
);
83 /* check for proper arguments */
85 while ((c
= getopt(argc
, argv
, "mo:rOq")) != EOF
) {
91 if (strlcpy(optbuf
, optarg
, sizeof (optbuf
)) >=
93 (void) fprintf(stderr
,
94 gettext("%s: Invalid argument: %s\n"),
98 optsize
= strlen(optbuf
);
114 if ((argc
- optind
) != 2)
117 special
= argv
[optind
++];
118 mountp
= argv
[optind
++];
126 m
.mnt_mntopts
= optbuf
;
127 if (hasmntopt(&m
, "m"))
131 flags
|= (Oflag
? MS_OVERLAY
: 0);
132 flags
|= (mflag
? MS_NOMNTTAB
: 0);
137 * Only the low-order bit of "roflag" is used by the system
138 * calls (to denote read-only or read-write).
140 do_mount(special
, mountp
, flags
);
146 rpterr(char *bs
, char *mp
)
150 (void) fprintf(stderr
,
151 gettext("%s: insufficient privileges\n"), myname
);
154 (void) fprintf(stderr
,
155 gettext("%s: %s no such device\n"), myname
, bs
);
158 (void) fprintf(stderr
,
159 gettext("%s: %s not a directory\n\t"
160 "or a component of %s is not a directory\n"),
164 (void) fprintf(stderr
,
165 gettext("%s: %s or %s, no such file or directory\n"),
169 (void) fprintf(stderr
,
170 gettext("%s: %s is not an udfs file system.\n"),
174 (void) fprintf(stderr
,
175 gettext("%s: %s is already mounted or %s is busy\n"),
179 (void) fprintf(stderr
,
180 gettext("%s: %s not a block device\n"), myname
, bs
);
183 (void) fprintf(stderr
,
184 gettext("%s: %s write-protected\n"),
188 (void) fprintf(stderr
,
189 gettext("%s: %s is corrupted. needs checking\n"),
194 (void) fprintf(stderr
,
195 gettext("%s: cannot mount %s\n"), myname
, bs
);
201 do_mount(char *special
, char *mountp
, int flag
)
205 if ((savedoptbuf
= strdup(optbuf
)) == NULL
) {
206 (void) fprintf(stderr
, gettext("%s: out of memory\n"),
210 if (mount(special
, mountp
, flag
| MS_DATA
| MS_OPTIONSTR
,
211 fstype
, NULL
, 0, optbuf
, MAX_MNTOPT_STR
) == -1) {
212 rpterr(special
, mountp
);
215 if (optsize
&& !qflag
)
216 cmp_requested_to_actual_options(savedoptbuf
, optbuf
,
224 (void) fprintf(stdout
, gettext("udfs usage:\n"
225 "mount [-F udfs] [generic options] "
226 "[-o suboptions] {special | mount_point}\n"));
227 (void) fprintf(stdout
, gettext("\tsuboptions are: \n"
228 "\t ro,rw,nosuid,remount,m\n"));
229 (void) fprintf(stdout
, gettext(
230 "\t only one of ro, rw can be "
231 "used at the same time\n"));
232 (void) fprintf(stdout
, gettext(
233 "\t remount can be used only with rw\n"));