ff.c revision 081901271249c8ffce8241a6035a9f13fb1c0aa9
/*
* 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 <string.h>
#include <errno.h>
#define FSTYPE_MAX 8
#define FULLPATH_MAX 64
#define ARGV_MAX 1024
extern char *default_fstype();
char *cbasename; /* name of command */
char full_path[FULLPATH_MAX];
int newargc = 2;
struct commands {
char *c_basename;
char *c_optstr;
char *c_usgstr;
} cmd_data[] = {
"ff", "F:o:p:a:m:c:n:i:?IlsuV",
"[-F FSType] [-V] [current_options] [-o specific_options] special ...",
"ncheck", "F:o:?i:asV",
"[-F FSType] [-V] [current_options] [-o specific_options] [special ...]",
NULL, "F:o:?V",
"[-F FSType] [-V] [current_options] [-o specific_options] special ..."
};
static void exec_specific(void);
static void lookup(void);
int
{
char *ptr;
int i;
int verbose = 0; /* set if -V is specified */
int F_flg = 0;
int usgflag = 0;
int fs_flag = 0;
int arg; /* argument from getopt() */
extern char *optarg; /* getopt specific */
extern int optind;
extern int opterr;
while (*ptr) {
if (*ptr++ == '/')
}
/*
* If there are no arguments and command is ncheck then the generic
* reads the VFSTAB and executes the specific module of
* each entry which has a numeric fsckpass field.
*/
/* open VFSTAB */
exit(2);
}
}
}
exit(0);
}
"%s [-F FSType] [-V] [current_options] [-o specific_options] special ...\n",
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 */
break;
case '?': /* print usage message */
usgflag = 1;
break;
default:
if (optarg)
break;
}
}
if (F_flg > 1) {
}
exit(2);
}
/* all commands except ncheck must exit now */
exit(0);
}
}
exit(0);
}
if (usgflag)
/* open VFSTAB */
exit(2);
}
continue;
continue;
fs_flag++;
if (verbose) {
for (i = 2; newargv[i]; i++)
continue;
}
}
/*
* if (! fs_flag) {
* if (sysfs(GETFSIND, fstype) == (-1)) {
* fprintf(stderr,
* "%s: FSType %s not installed in the kernel\n",
* cbasename, fstype);
* exit(1);
* }
* }
*/
exit(0);
}
/* All other arguments must be specials */
/* perform a lookup if fstype is not specified */
exit(0);
}
if (usgflag)
lookup();
if (verbose) {
for (i = 2; newargv[i]; i++)
printf("\n");
continue;
}
if (!F_flg)
}
return (0);
}
/* see if all numbers */
int
{
return (0);
yp++;
if (*yp)
return (0);
return (1);
}
static void
{
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:
exit(1);
break;
case VFS_TOOFEW:
exit(1);
break;
case VFS_TOOMANY:
exit(1);
break;
}
}
static void
exec_specific(void)
{
case 0:
newargv[0] = "sh";
}
exit(1);
}
"%s: FSType %s not installed in the kernel\n",
exit(1);
}
exit(1);
case -1:
exit(2);
default:
/*
* if cannot exec specific, or fstype is not installed, exit
* after first 'exec_specific' to avoid printing duplicate
* error messages
*/
if (ret > 0) {
}
}
}
}