dfshares.c revision 8c332a0dd4225c1d5b651b04a5df22040d918bf7
/*
* 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"
/*
* generic interface to dfshares, dfmounts.
*
* usage: dfshares [-F fstype] [-o fs_options] [-h] [ args ]
*
* <cmd> is the basename of the command.
*
*/
#include <ctype.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <wait.h>
#include <stdlib.h>
/*
* non-[arg...] elements in new argv list:
* cmd name, , -h, -o, opts, (char *)0 terminator
*/
#define ARGVPAD 5
int
{
int c, err = 0;
char *cmd; /* basename of this command */
char **nargv; /* new argv list */
int hflag = 0;
int nargc = 0; /* new argc */
int retval; /* exit status from exec'd commad */
static char usage[] =
"usage: %s [-F fstype] [-h] [-o fs_options ] [arg ...]\n";
if (cmd)
++cmd;
else
switch (c) {
case 'h':
break;
case 'F':
break;
case 'o': /* fs specific options */
break;
case '?':
err = 1;
break;
}
if (err) {
exit(1);
}
exit(1);
}
/* allocate a block for the new argv list */
exit(1);
}
if (hflag)
if (opts) {
}
if (showall) { /* command with no args -- show all dfs's */
case 0:
_exit(1);
/*NOTREACHED*/
default:
;
/* take exit status into account */
break;
case -1:
"%s: fork failed - try again later.\n",
cmd);
exit(1);
}
}
if (pid == 0) { /* we never got into the loop! */
"%s: no file systems in %s\n",
exit(1);
}
else
}
if (fsname) { /* generate fs specific command name */
"%s: invalid file system name\n", cmd);
exit(1);
}
else
else {
exit(1);
}
return (1);
}
/*
* invalid(name, f) - return non-zero if name is not in
* the list of fs names in file f
*/
static int
FILE *f) /* file of list of file system types */
{
char *s;
while (s = getfs(f)) /* while there's still hope ... */
return (0); /* we got it! */
return (1);
}
/*
* getfs(fp) - get the next file system name from fp
* ignoring lines starting with a #.
* All leading whitespace is discarded.
*/
static char *
{
register char *s;
while (isspace(*s)) /* leading whitespace doesn't count */
++s;
if (*s != '#') { /* not a comment */
char *t = s;
while (!isspace(*t)) /* get the token */
++t;
*t = '\0'; /* ignore rest of line */
return (s);
}
}
return (NULL); /* that's all, folks! */
}