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.
28 #define MNTTYPE_LOFS "lofs"
34 #include <sys/fstyp.h>
36 #include <sys/mntent.h>
37 #include <sys/mnttab.h>
38 #include <sys/mount.h>
39 #include <sys/signal.h>
45 * /sbin/mount and the fs-local method understand this exit code to
46 * mean that all the mount failures were related to lofs mounts. Since
47 * this program only attempts to mount lofs file systems, when it fails
48 * it returns this exit status.
52 static void usage(void);
54 static char optbuf
[MAX_MNTOPT_STR
] = { '\0', };
55 static int optsize
= 0;
57 static char fstype
[] = MNTTYPE_LOFS
;
60 * usage: mount [-Ormq] [-o options] special mountp
62 * This mount program is exec'ed by /usr/sbin/mount if '-F lofs' is
66 main(int argc
, char *argv
[])
69 char *special
; /* Entity being mounted */
70 char *mountp
; /* Entity being mounted on */
78 myname
= strrchr(argv
[0], '/');
79 myname
= myname
? myname
+1 : argv
[0];
80 (void) snprintf(typename
, sizeof (typename
), "%s %s", fstype
, myname
);
83 while ((c
= getopt(argc
, argv
, "o:rmOq")) != EOF
) {
90 if (strlcpy(optbuf
, optarg
, sizeof (optbuf
)) >=
92 (void) fprintf(stderr
,
93 gettext("%s: Invalid argument: %s\n"),
97 optsize
= strlen(optbuf
);
107 flags
|= MS_NOMNTTAB
;
118 if ((argc
- optind
!= 2) || errflag
) {
121 special
= argv
[argc
- 2];
122 mountp
= argv
[argc
- 1];
124 if ((savedoptbuf
= strdup(optbuf
)) == NULL
) {
125 (void) fprintf(stderr
, gettext("%s: out of memory\n"),
129 if (mount(special
, mountp
, flags
| MS_OPTIONSTR
, fstype
, NULL
, 0,
130 optbuf
, MAX_MNTOPT_STR
)) {
131 (void) fprintf(stderr
, "mount: ");
135 if (optsize
&& !qflg
)
136 cmp_requested_to_actual_options(savedoptbuf
, optbuf
,
144 (void) fprintf(stderr
,
145 "Usage: mount [-Ormq] [-o options] special mountpoint\n");