devinfo_devname.c revision facf4a8d7b59fde89a8662b4f4c73a758e6c402c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <strings.h>
#include <unistd.h>
#include <stdarg.h>
#include <fcntl.h>
#include <stdlib.h>
#include <libnvpair.h>
#include <libdevinfo.h>
#include <syslog.h>
#include <errno.h>
#include <assert.h>
#include <sys/systeminfo.h>
#define LINEMAX 1024
#define SPC " \t\n"
#define QUOTES "\'\""
/*
* This is for local file supports of DBNR configurations.
*/
static int di_devname_getmapent_files(char *, char *, nvlist_t **);
static int di_devname_get_mapinfo_files(char *, nvlist_t **);
static FILE *open_local_map(char *);
static void unquote(char *, char *);
static int msglog = 1;
typedef enum {
DBG_ERR = 1,
static int devname_debug = 1;
static void dprintf(debug_level_t, const char *, ...);
extern int isspace(int);
/* exported interfaces */
void di_devname_print_mapinfo(nvlist_t *);
int di_devname_get_mapinfo(char *, nvlist_t **);
int di_devname_get_mapent(char *, char *, nvlist_t **);
/*
* Returns 0 and the valid maplist, otherwise errno.
*/
int
{
int rval = 0;
"not exist\n", mapname);
return (ENOENT);
}
if (rval == 0) {
}
return (rval);
}
static FILE *
open_local_map(char *mapname)
{
if (*mapname != '/') {
mapname);
} else {
}
}
static void
{
if (!escaped) {
if (*ip == '\\') {
escaped = 1;
quoted ++;
continue;
} else if (*ip == '"') {
quoted ++;
continue;
}
}
escaped = 0;
}
*bp = '\0';
*qp = '\0';
if (quoted)
}
/*
* gets the qualified characters in *p into w, which has space allocated
* already
*/
static int
{
char *tmp = w;
if (wordsz <= 0) {
return (-1);
}
(*p)++;
(*pq)++;
}
while (**p &&
**pq == ' ')) {
if (--count <= 0) {
*tmp = '\0';
*tmpq = '\0';
wordsz);
return (-1);
}
*w++ = *(*p)++;
}
*w = '\0';
*wq = '\0';
return (0);
}
static int
{
int error = 0;
return (EFAULT);
}
continue;
if (word[0] == '#')
continue;
continue;
"%s\n", name);
continue;
}
goto fail1;
}
char *rest;
"%s\n", key);
break;
}
if (rest[0] == ';') {
rest++;
} else {
}
goto fail;
}
}
name);
goto fail;
}
}
done:
return (0);
fail:
return (error);
}
void
{
while (nvp) {
while (kvp) {
}
}
}
static int
{
}
static struct actions {
char *key;
int (*action)(char *, char *);
} actions[] = {
};
static int
{
int i = 0;
int error = 0;
int len = 0;
switch (cmd) {
case DEVFSADMD_NS_READDIR:
devname);
if (error) {
"failed %d\n", error);
return (error);
} else {
(*nsmapcount)++;
"mapcount %d\n", *nsmapcount);
}
break;
case DEVFSADMD_NS_LOOKUP:
break;
default:
break;
}
}
i++;
}
return (0);
}
int
{
uint32_t ns_mapcount = 0;
char *devfsadm_link = NULL;
while (entry) {
name);
while (attr) {
/* do not continue if encountered the first error */
if (error) {
}
}
}
switch (cmd) {
case DEVFSADMD_NS_READDIR:
break;
case DEVFSADMD_NS_LOOKUP:
} else {
return (1);
}
break;
default:
return (ENOTSUP);
}
return (0);
}
static nvlist_t *
{
int count = 0;
return (NULL);
if (line[0] == '#')
continue;
continue;
continue;
/* bypass the non-related entries */
continue;
/* get a matched entry */
"for %s\n", name);
goto fail1;
}
goto fail1;
char *rest;
"%s\n", key);
goto fail;
}
if (rest[0] == ';') {
rest++;
} else {
}
goto fail;
}
goto fail;
count++;
break;
}
if (count == 0)
goto fail1;
return (nvl);
fail:
return (NULL);
}
static int
{
int rval = 0;
return (1);
} else {
}
return (rval);
}
int
{
}
int
{
}
static void
{
if (devname_debug < msglevel)
return;
/* Print a distinctive label for error msgs */
}
} else {
}
}
/* ARGSUSED */
/* PRINTFLIKE2 */
static void
{
if (!devname_debug)
return;
}
/*
* Private interfaces for non-global /dev profile
*/
/*
* Allocate opaque data structure for passing profile to the kernel for
* the given mount point.
*
* Note that this interface returns an empty, initialized, profile.
* It does not return what may have been previously committed.
*/
int
{
if (nvlist_alloc(&nvl, 0, 0))
return (-1);
return (-1);
}
return (0);
}
/*
* Free space allocated by di_prof_init().
*/
void
{
}
/*
* Sends profile to the kernel.
*/
int
{
int rv;
return (-1);
return (rv);
}
/*
* Add a device or directory to profile's include list.
*
* Note that there is no arbitration between conflicting
* include and exclude profile entries, most recent
* is the winner.
*/
int
{
return (-1);
return (0);
}
/*
* Add a device or directory to profile's exclude list.
* This can effectively remove a previously committed device.
*/
int
{
return (-1);
return (0);
}
/*
* Add a symlink to profile.
*/
int
{
char *syml[2];
return (-1);
return (0);
}
/*
* Add a name mapping to profile.
*/
int
{
char *map[2];
return (-1);
return (0);
}