/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* rmf_main.c :
* The file containing main() for rmformat. The command line
* options are parsed in this file.
*/
#include <priv_utils.h>
#include "rmformat.h"
static char *myname;
char *label;
static void usage(char *);
void check_invalid_combinations();
extern void my_perror(char *err_string);
void process_options();
int
{
char i;
char *tmp_ptr;
/*
* This program requires file_dac_read, file_dac_write,
* proc_fork, proc_exec, and sys_devices privileges.
*
* child processes require the sys_mount privilege
*/
(void) __init_suid_priv(PU_INHERITPRIVS,
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
DPRINTF1("arg %c\n", i);
switch (i) {
case 'b' :
b_flag++;
restricted to 8 characters.\n"));
exit(1);
}
break;
case 'c' :
c_flag++;
errno = 0;
usage("invalid block number");
}
break;
case 'D' :
D_flag++;
break;
case 'e' :
e_flag++;
break;
case 'F' :
F_flag++;
DPRINTF("q");
quick_format = 1;
DPRINTF("l");
long_format = 1;
DPRINTF("f");
force_format = 1;
} else {
usage("invalid argument for option -F");
}
break;
case 'H' :
H_flag++;
break;
case 'l' :
l_flag++;
break;
case 'p' :
p_flag++;
break;
case 'R' :
R_flag++;
} else {
usage("Invalid argument for -R option");
}
break;
case 's' :
s_flag++;
break;
case 'U' :
U_flag++;
break;
case 'V' :
V_flag++;
verify_write = 0;
verify_write = 1;
} else {
usage("Invalid argument for -V option");
}
break;
case 'W' :
W_flag++;
} else {
usage("Invalid argument for -W option");
}
break;
case 'w' :
w_flag++;
wp_enable++;
wp_disable++;
} else {
usage("Invalid arguments for -w option");
}
break;
default:
usage("");
break;
}
}
usage("more than one device name argument");
/* NOTREACHED */
}
} else if (optind == 1) {
/* list devices by default */
l_flag++;
gettext("No device specified.\n"));
exit(1);
#if 0
(void) printf("Using floppy device\n");
#endif /* 0 */
}
/* Remove the privileges we gave. */
return (0);
}
static void
{
}
[ -DeHpU ] [ -b label ] [ -c blockno ] [ -F quick|long|force ] \
[ -R enable|disable ] [ -s filename ] [ -V read|write ] \
[ -w enable|disable ] [ -W enable|disable ] devname \n"), myname);
myname);
exit(1);
}
void
{
/* Inherited from FLOPPY */
usage("Options -D and -H incompatible");
}
usage("Options -D and -F incompatible");
}
usage("Options -H and -F incompatible");
}
/* rmformat additions */
usage("Options -w, -W and -R incompatible");
}
usage("Options -c, -F incompatible");
}
/* l_flag is mutually exclusive of these flags */
usage("Options incompatible");
}
}
void
{
if ((medium_type != SM_FLOPPY) &&
(medium_type != SM_PCMCIA_MEM)) {
usage("-D, -H options are compatible with floppy and \
PCMCIA memory cards only.");
}
}
}