/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <limits.h>
#include <locale.h>
#include <libintl.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <libdiskmgt.h>
#include "fslib.h"
extern char *default_fstype();
void stat_snap(char *, char *, char *);
/*
* TRANSLATION_NOTE - the usage strings in the c_usgstr[] of the
* following structures should be given a translation; the call to gettext
* is in the usage() function. The strings are the ones containing
* "[-F FSType]".
*/
struct commands {
char *c_basename;
char *c_optstr;
} cmd_data[] = {
"clri", "F:o:?V",
{
"[-F FSType] [-V] special inumber ...",
},
"mkfs", "F:o:mb:?V",
{
"[-F FSType] [-V] [-m] [-o specific_options] special ",
"[operands]", NULL
},
"dcopy", "F:o:?V",
{
"[-F FSType] [-V] special inumber ...",
},
"fsdb", "F:o:z:?V",
{
"[-F FSType] [-V] [-o specific_options] special",
},
"fssnap", "F:dio:?V",
{
},
"labelit", "F:o:?nV",
{
"[-F FSType] [-V] [-o specific_options] special [operands]",
},
NULL, "F:o:?V",
{
"[-F FSType] [-V] [-o specific_options] special [operands]",
}
};
static void lookup(void);
int
{
char *ptr;
int i;
int j;
int F_flg = 0;
int mflag = 0;
int Nflag = 0;
int iflag = 0;
int usgflag = 0;
char *msg;
int error;
extern char *optarg; /* getopt specific */
extern int optind;
extern int opterr;
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
while (*ptr) {
if (*ptr++ == '/')
}
if (argc == 1) {
;
exit(2);
}
;
switch (arg) {
case 'V': /* echo complete command line */
verbose = 1;
break;
case 'F': /* FSType specified */
F_flg++;
break;
case 'o': /* FSType specific arguments */
if (!Nflag) {
}
break;
case '?': /* print usage message */
usgflag = 1;
break;
case 'm': /* FSType specific arguments */
mflag = 1;
if (optarg)
break;
case 'i': /* fssnap only */
iflag = 1;
/*FALLTHROUGH*/
default:
if (optarg)
break;
}
}
if (F_flg > 1) {
gettext("%s: more than one FSType specified\n"),
exit(2);
}
gettext("%s: FSType %s exceeds %d characters\n"),
exit(2);
}
}
/* perform a lookup if fstype is not specified */
optind++;
/* handle -i (fssnap command only) */
if (iflag) {
/*
* There is no reason to ever call a file system specific
* version since its all in kstats.
*/
if (diff > 0) /* gave more than one mountpoint or device */
exit(0);
}
exit(2);
}
lookup();
exit(2);
}
/* build the full pathname of the fstype dependent command */
if (verbose) {
for (i = 2; newargv[i]; i++)
printf("\n");
exit(0);
}
/*
* Prior to executing the command for mkfs check for device in use.
* If the mflag is set, user wants to see command that created
* an already existing filesystem. Do not check for in use in this
* case. If Nflag is set user wants to see what the parameters
* would be to create the filesystem. Do not check for in use in
* this case.
*/
error) {
if (error != 0) {
" with device in use checking: %s\n"),
} else {
exit(2);
}
}
}
/*
* Execute the FSType specific command.
*/
/* build the alternate pathname */
if (verbose) {
for (i = 2; newargv[i]; i++)
printf("\n");
exit(0);
}
}
newargv[0] = "sh";
}
exit(2);
}
gettext("%s: FSType %s not installed in the kernel\n"),
exit(2);
}
gettext("%s: Operation not applicable for FSType %s \n"),
return (2);
}
static void
{
int i;
exit(2);
}
/*
* It is called when the fstype is not specified on the command line.
*
* The following global variables are used:
* special, fstype
*/
static void
lookup(void)
{
int ret;
exit(1);
}
if (ret == -1) {
}
switch (ret) {
case -1:
break;
case 0:
break;
case VFS_TOOLONG:
gettext("%s: line in vfstab exceeds %d characters\n"),
exit(1);
break;
case VFS_TOOFEW:
gettext("%s: line in vfstab has too few entries\n"),
exit(1);
break;
}
}
void
{
int en;
char *errstr;
if (mountpoint) {
gettext("%s: %s: error %d: %s\n"),
exit(2);
}
}
}
static int
{
return (1);
}
if (!opts)
break;
if (*opts == ',')
opts ++;
if (*opts == ' ')
opts ++;
}
return (0);
}
/*
* Parses the -o [fs specific options string] to search for the UFS -N flag.
* Return the opts string pointing to the next position in the string if
* match is not found. A delimiter of , or ' ' can be used depending on the
* caller, newfs or mkfs.
*/
static int
{
char *cs;
char *tmp_str;
while (*cs++ == *s) {
if (*s++ == '\0') {
goto true;
}
}
if (*s != '\0') {
/*
* If we cannot find the delimiter it means we
* have hit the end of the string.
*/
if (!tmp_str)
return (0);
}
true:
cs--;
return (1);
}