share.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* generic interface to share
*
* usage: share [-F fstype] [-o fs_options] [-d desc] [ args ]
*
* <cmd> is the basename of the command.
*
*/
#include <unistd.h>
#include <utmpx.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>
#define MAXFIELD 5
#define BUFSIZE 65536
/* cmd name, -o, opts, -d, desc, (char *)0 */
/* terminator */
static char *cmd; /* basename of this command */
static char *getfs();
static void get_data(char *s);
void perror();
int argc;
char **argv;
{
static int invalid();
extern char *optarg;
extern int optind;
int c, err = 0;
char **nargv; /* new argv list */
int nargc = 0; /* new argc */
int optnum;
static char usage[] =
"usage: %s [-F fstype] [-o fs_options ]"
" [-d description] [pathname [resourcename]]\n";
if (cmd)
++cmd;
else
switch (c) {
case 'F':
break;
case 'd': /* description */
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 (opts) {
}
if (desc) {
}
if (showall) { /* share with no args -- show all dfs's */
}
exit(0);
}
if (fsname) { /* generate fs specific command name */
"%s: invalid file system name\n", cmd);
exit(1);
}
/* list shared resources for share -F fstype */
exit(0);
}
else
else {
exit(1);
}
/*
* if sharetab is older than boot time then remove it.
* This will happen only for the first time share is
* called after boot.
*/
return (1);
/*NOTREACHED*/
}
/*
* invalid(name, f) - return non-zero if name is not in
* the list of fs names in file f
*/
static int
char *name; /* file system name */
FILE *f; /* file of list of systems */
{
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! */
}
static void
char *fsname;
{
exit(1);
}
else
(void) printf(" \"\" ");
(void) printf("\n");
}
}
}
}
static char empty[] = "";
static void
get_data(s)
char *s;
{
register int fieldc = 0;
/*
* This function parses an advertise entry from
* fieldv[0] : pathname
* fieldv[1] : resource
* fieldv[2] : fstype
* fieldv[3] : options
* fieldv[4] : description
*/
while (isspace(*s))
s++;
break;
}
while (*s && !isspace(*s)) ++s;
if (*s)
*s++ = '\0';
}
while (fieldc < 5)
}