rmm_config.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) 1995 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <libintl.h>
#include <rmmount.h>
#include <libgen.h>
#include <regex.h>
#include "rmm_int.h"
static void conf_ident(int, char **, u_int);
static void conf_action(int, char **, u_int);
static void conf_mount(int, char **, u_int);
static void conf_share(int, char **, u_int);
#define IDENT_MEDARG 3
#define FS_IDENT_PATH "/usr/lib/fs"
static struct cmds {
char *name;
} cmd_list[] = {
{ "ident", conf_ident },
{ "action", conf_action },
{ "fsck", conf_fsck },
{ "mount", conf_mount },
{ "share", conf_share },
{ 0, 0}
};
/*
* filesystem types recognized on the "mount" config line
*/
struct fs_names {
char *fn_name;
};
{ "ufs", MA_UFS },
{ "hsfs", MA_HSFS },
{ "pcfs", MA_PCFS },
{ "dos", MA_PCFS },
{ "udfs", MA_UDFS },
{ 0, 0}
};
static int cmd_arg_index[3] = {0, 0, 0};
void
{
extern void makeargv(int *, char **, char *);
char *wholeline = 0;
int ac;
int found;
gettext("%s(%ld) error: open of \"%s\"; %s\n"),
exit(1);
}
lineno++;
/* skip comment lines (starting with #) and blanks */
continue;
}
continue;
} else {
len -= 2;
continue;
}
} else {
/* just a one liner */
} else {
}
}
/* make a nice argc, argv thing for the commands */
found = 0;
found++;
}
}
if (!found) {
"%s(%ld) warning: \"%s\" line %d: unknown directive \"%s\"\n"),
}
}
linelen = 0;
}
}
/*
* argv[0] = "action"
* argv[1] = <optional_flag>
* argv[next] = <media>
* argv[next] = <dso>
* [argv[next] = <action_arg[N]>]
*/
static void
{
int nextarg;
static int ali;
int i;
int j;
if (argc < 3) {
"%s(%ld) warning: \"%s\" line %d: insufficient args\n"),
return;
}
if (action_list == NULL) {
sizeof (struct action_list *));
ali = 0;
}
if (ali == MAX_ACTIONS) {
"%s(%ld) warning: \"%s\" line %d: maximum actions (%d) exceeded\n"),
return;
}
sizeof (struct action_list));
nextarg = 1;
/*
* or in the bits for the flags.
*/
nextarg++;
}
/*
* Here, we just remember the name. We won't actually
* load in the dso until we're sure that we need to
* call the function.
*/
}
ali++; /* next one... */
}
/*
* argv[0] = "ident"
* argv[1] = <fstype>
* argv[2] = <dsoname>
* argv[3] = <media>
* [argv[n] = <media>]
*/
static void
{
static int ili;
int i;
int j;
if (argc < 3) {
"%s(%ld) warning: \"%s\" line %d: insufficient args\n"),
return;
}
if (ident_list == NULL) {
sizeof (struct ident_list *));
ili = 0;
}
if (ili == MAX_IDENTS) {
"%s(%ld) warning: \"%s\" line %d: %s maximum idents (%d) exceeded\n"),
return;
}
sizeof (struct ident_list));
sizeof (char *));
for (i = IDENT_MEDARG, j = 0; i < argc; i++, j++) {
}
ili++;
}
/*
* allocate mount args
* symname - string containing media or file system regular expression
* ln - line number from config file, used for error messages
*/
static struct mount_args *
{
char *re_symname;
struct mount_args *ma,
***argvp;
int *argcp;
int i;
switch (key & MA_CMD_MASK) {
case MA_FSCK:
break;
case MA_MOUNT:
break;
case MA_SHARE:
break;
default:
"%s(%ld) warning: \"%s\" line %d: unknown command\n"),
return (NULL);
}
sizeof (struct mount_args *));
*argcp = 0;
}
if (*argcp == MAX_MOUNTS) {
"%s(%ld) warning: \"%s\" line %d: maximum mounts (%d) exceeded\n"),
return (NULL);
}
/*
* See if we already have args for this symbolic name.
*/
break;
}
}
/*
* if we don't already have a mount_args then allocate one
*/
if (i == *argcp) {
#ifdef DEBUG_MA
dprintf("alloc_ma: no existing mount args -- creating one\n");
#endif
sizeof (struct mount_args))) == NULL) {
"%s(%ld) error: can't allocate memory (error %d)\n"),
return (NULL);
}
/* convert to a useful regular expression */
/* can't convert to compiled regex?? */
"%s(%ld) warning: \"%s\" line %d: unknown regular expression: \"%s\"\n"),
} else {
*argcp += 1;
#ifdef DEBUG_MA
"alloc_ma: added regexp \"%s\" to mount args\n",
#endif
}
}
return (ma);
}
/*
* argv[0] = "fsck" the "fsck" keyword
* argv[1] = <symdev> name to match on
* argv[...] = <fs_type> 0 or more filesystem types
* argv[next] = "-o" the "-o" keystring
* argv[next...] = <option> 1 or more options
*/
static void
{
int i; /* arg index */
int opt_ind; /* argv index */
char *optptr; /* ptr to option */
int fs_found_cnt; /* how many FSs found */
/* first-level check */
if (argc < 4) {
"%s(%ld) warning: \"%s\" line %d: insufficient args\n"),
return;
}
/* check for zero or more filesystem types */
/* no FS type(s) specified -- just like "all" */
} else {
/* scan for which FS(s) specified */
for (i = 2; i < argc; i++) {
break; /* no more FSs specified */
}
fs_found_cnt = 0;
/* found a match */
fs_found_cnt++;
}
}
/* was this "fs" found in our list ?? */
if (fs_found_cnt == 0) {
"%s(%ld) warning: \"%s\" line %d: filesystem type \"%s\" not recognized\n"),
argv[i]);
}
}
/* ensure at least one FS type is specified */
"%s(%ld) warning: \"%s\" line %d: no known filesystem type(s) specified\n"),
return;
}
opt_ind = i; /* options start here */
}
/* ensure we have a mount_args structure for this name */
return;
}
/*
* The option "list" is comma separated and without spaces.
* It should appear as a single "argument" in the argv vector.
*/
gettext("%s(%ld) warning: \"%s\" line %d: "
"bad options specification\n"),
return;
}
/* skip past the "-o" */
opt_ind++;
}
/*
* argv[0] = "mount" the "mount" keyword
* argv[1] = <symdev> name to match on
* argv[...] = <fs_type> 0 or more filesystem types
* argv[next] = "-o" the "-o" keystring
* argv[next...] = <option> 1 or more options
*/
static void
{
int i; /* arg index */
int opt_ind; /* argv index */
char *optptr; /* ptr to option */
int fs_found_cnt; /* how many FSs found */
int len; /* length of option string */
/* first-level check */
if (argc < 4) {
"%s(%ld) warning: \"%s\" line %d: insufficient args\n"),
return;
}
/* check for zero or more filesystem types */
/* no FS type(s) specified -- just like "all" */
} else {
/* scan for which FS(s) specified */
for (i = 2; i < argc; i++) {
break; /* no more FSs specified */
}
fs_found_cnt = 0;
/* found a match */
fs_found_cnt++;
}
}
/* was this "fs" found in our list ?? */
if (fs_found_cnt == 0) {
"%s(%ld) warning: \"%s\" line %d: filesystem type \"%s\" not recognized\n"),
argv[i]);
}
}
/* ensure at least one FS type is specified */
"%s(%ld) warning: \"%s\" line %d: filesystem type(s) specified unknown\n"),
return;
}
opt_ind = i; /* options start here */
}
/* ensure we have a mount_args structure for this name */
return;
}
/*
* The option "list" should be a comma separated and without
* spaces, but, for backward compatibility, we will allow spaces
* as separators.
*/
gettext("%s(%ld) warning: \"%s\" line %d: "
"bad options specification\n"),
return;
}
/*
* Allocate memory in ma->ma_options for the option
* string on the "mount" options line in the config file.
*/
/*
* skip past the "-o"
*/
opt_ind++;
/*
* Add an extra character for the comma between
* mount options, and one for the null string terminator
*/
}
/*
* Do minimal parsing of the option list (would prefer to do
* none) to locate any "ro" or "rw" flags. This information
* is necessary so that the apporiate mode can be propagated
* to the share command. The flags are stripped from the
* option line and re-added later prior to the actual mount.
*/
}
}
}
}
/*
* argv[0] = "share" the "share" keyword
* argv[1] = <symdev> name to match on
* argv[next...] = <option> 1 or more options
*/
static void
{
int i;
struct mount_args *ma;
if (argc < 2) {
"%s(%ld) warning: \"%s\" line %d: insufficient args\n"),
return;
}
return;
}
/*
* start the buffer off right.
*/
for (i = 2; i < argc; i++) {
}
}
/*
* return whether or not the supplied filesystem type is supported in
* the supplied mount arg struct
*/
{
int i;
}
}
}
#ifdef DEBUG
#endif
return (res);
}