4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright (c) 2014 Joyent, Inc. All rights reserved.
33 #include <sys/fstyp.h>
35 #include <sys/mntent.h>
36 #include <sys/mnttab.h>
37 #include <sys/mount.h>
38 #include <sys/signal.h>
42 #define MNTTYPE_BOOTFS "bootfs"
44 static char optbuf
[MAX_MNTOPT_STR
] = { '\0', };
45 static int optsize
= 0;
50 (void) fprintf(stderr
,
51 "Usage: mount [-Ormq] [-o options] special mountpoint\n");
56 * usage: mount [-Ormq] [-o options] special mountp
58 * This mount program is exec'ed by /usr/sbin/mount if '-F bootfs' is
62 main(int argc
, char *argv
[])
65 char *special
; /* Entity being mounted */
66 char *mountp
; /* Entity being mounted on */
74 myname
= strrchr(argv
[0], '/');
75 myname
= myname
? myname
+1 : argv
[0];
76 (void) snprintf(typename
, sizeof (typename
), "%s %s", MNTTYPE_BOOTFS
,
80 while ((c
= getopt(argc
, argv
, "o:rmOq")) != EOF
) {
87 if (strlcpy(optbuf
, optarg
, sizeof (optbuf
)) >=
89 (void) fprintf(stderr
,
90 gettext("%s: Invalid argument: %s\n"),
94 optsize
= strlen(optbuf
);
104 flags
|= MS_NOMNTTAB
;
115 if ((argc
- optind
!= 2) || errflag
) {
118 special
= argv
[argc
- 2];
119 mountp
= argv
[argc
- 1];
121 if ((savedoptbuf
= strdup(optbuf
)) == NULL
) {
122 (void) fprintf(stderr
, gettext("%s: out of memory\n"),
127 if (mount(special
, mountp
, flags
| MS_OPTIONSTR
, MNTTYPE_BOOTFS
, NULL
,
128 0, optbuf
, MAX_MNTOPT_STR
)) {
129 (void) fprintf(stderr
, "mount: ");
133 if (optsize
&& !qflg
) {
134 cmp_requested_to_actual_options(savedoptbuf
, optbuf
,