/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <locale.h>
extern int optind;
extern char *optarg;
static int readflag;
static int overlay;
static int remount;
static char *special;
static char *mountpt;
static char *myopts[] = {
#define SUBOPT_READONLY 0
"ro",
"rw",
"attrdir",
"remount",
};
static void
usage(void)
{
"%s usage:\n%s [-F %s] [-r] [-o specific_options]"
" {special | mount_point}\n%s [-F %s] [-r] [-o specific_options]"
exit(1);
}
static int
do_mount(void)
{
if (readflag == READFLAG_RO)
if (overlay)
flags |= MS_OVERLAY;
if (remount)
flags |= MS_REMOUNT;
switch (errno) {
case EPERM:
typename);
break;
case ENXIO:
break;
case ENOTDIR:
"not a directory\n"
"\tor a component of %s is not a directory\n"),
break;
case ENOENT:
"file or directory\n"),
break;
case EINVAL:
break;
case EBUSY:
"is already mounted, %s is busy,\n"
"\tor allowable number of mount points exceeded\n"),
break;
case ENOTBLK:
break;
case EROFS:
break;
case ENOSPC:
"is not okay\n"
break;
default:
break;
}
return (-1);
}
return (0);
}
/*
* Wrapper around strdup().
*/
static char *
{
char *str;
}
return (str);
}
/*
* Wrapper around stat().
*/
static int
{
int ret;
if (ret < 0) {
}
return (ret);
}
/*
* Wraper around realpath()
*/
static char *
{
char *ret;
}
return (ret);
}
static int
{
char *value;
while (*subopts != '\0') {
case SUBOPT_READONLY:
if (readflag == READFLAG_RW) {
"read-only and read-write options "
"specified\n"), typename);
return (-1);
}
break;
case SUBOPT_READWRITE:
if (readflag == READFLAG_RO) {
"read-only and read-write options "
"specified\n"), typename);
return (-1);
}
break;
case SUBOPT_ATTRIBDIR:
"attribute directory\n"), typename);
return (-1);
} else {
return (-1);
return (-1);
}
break;
case SUBOPT_REMOUNT:
remount = 1;
break;
default:
return (-1);
}
}
return (0);
}
int
{
int cc;
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
myname++;
else
switch (cc) {
case 'r':
if (readflag == READFLAG_RW) {
"read-only and read-write options "
"specified\n"), typename);
return (1);
}
break;
case 'O':
overlay = 1;
break;
case 'o':
if (parse_subopts(optarg))
return (1);
break;
default:
usage();
break;
}
}
/*
* There must be at least 2 more arguments, the
* special file and the directory.
*/
usage();
return (1);
if (mountpt) {
return (1);
return (1);
}
}
if (mountargs.sdev_attrdir) {
&st) < 0)
return (1);
return (1);
}
}
/* Special checks if /dev is the mount point */
/* Remount of /dev requires an attribute directory */
"directory\n"), typename);
return (1);
}
/* Perform the mount */
if (do_mount())
return (1);
return (0);
}