/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <bsm/devalloc.h>
extern char *_strdup_null(char *);
static struct _dabuff {
char *_DEVALLOC;
} *__dabuff;
static devalloc_t *da_interpret(char *);
int da_matchname(devalloc_t *, char *);
int da_matchtype(devalloc_t *, char *);
static int system_labeled = 0;
/*
* trim_white -
* trims off leading and trailing white space from input string.
* The leading white space is skipped by moving the pointer forward.
* The trailing white space is removed by nulling the white space
* characters.
* returns pointer to non-white string, else returns NULL if input string
* is null or if the resulting string has zero length.
*/
char *
{
char *tptr;
return (NULL);
ptr++;
--tptr;
*tptr = '\0';
if (*ptr == '\0')
return (NULL);
return (ptr);
}
/*
* pack_white -
* trims off multiple occurrences of white space from input string.
* returns the number of spaces retained
*/
int
{
int cnt = 0;
return (0);
tptr++;
for (;;) {
tptr++;
}
tptr++;
if (*tptr == '\0')
break;
*ptr++ = ' ';
cnt++;
}
*ptr = '\0';
return (cnt);
}
/*
* getdadmline -
* reads one device_alloc/device_maps line from stream into buff of len
* bytes. Continued lines from stream are concatenated into one line in
* buff. Comments are removed from buff.
* returns the number of characters in buff, else returns 0 if no
* characters are read or an error occurred.
*/
int
{
int tmpcnt;
int charcnt = 0;
int fileerr = 0;
int contline = 0;
char *cp;
char *ccp;
do {
do {
contline = 0;
fileerr = 1;
break;
}
ccp--;
contline = 1;
}
else
contline = 0;
}
return (0);
else
return (charcnt);
}
/*
* _daalloc -
* allocates common buffers and structures.
* returns pointer to the new structure, else returns NULL on error.
*/
static struct _dabuff *
_daalloc(void)
{
(unsigned)sizeof (*__dabuff));
return (NULL);
}
return (__dabuff);
}
/*
* getdadmfield -
* gets individual fields separated by skip in ptr.
*/
char *
{
char *pend;
/* check for a continuing search */
/* check for source end */
return (NULL);
/* find terminator */
/* terminate and set continuation pointer */
*pend++ = '\0';
} else
/*
* trim off any surrounding white space, return what's left
*/
return (trim_white(ptr));
}
/*
* setdaent -
* rewinds the device_allocate file to the begining.
*/
void
setdaent(void)
{
return;
else
}
/*
* enddaent -
* closes device_allocate file.
*/
void
enddaent(void)
{
return;
}
}
/*
* setdafile -
* changes the default device_allocate file to the one specified.
* It does not close the previous file. If this is desired, enddaent
* should be called prior to setdafile.
*/
void
{
return;
}
}
void
{
return;
}
/*
* getdaon -
* checks if device_allocate has string DEVICE_ALLOCATION=ON or
* DEVICE_ALLOCATION=OFF string in it.
* returns 1 if the string is DEVICE_ALLOCATION=ON, 0 if it is
* DEVICE_ALLOCATION=OFF, -1 if neither string present.
*/
int
getdaon()
{
setdaent();
enddaent();
return (is_on);
}
is_on = 1;
break;
is_on = 0;
break;
}
}
enddaent();
return (is_on);
}
/*
* getdaent -
* When first called, returns a pointer to the first devalloc_t
* structure in device_allocate; thereafter, it returns a pointer to the
* next devalloc_t structure in the file. Thus, successive calls can be
* used to search the entire file.
* call to getdaent should be bracketed by setdaent and enddaent.
* returns NULL on error.
*/
getdaent(void)
{
return (NULL);
continue;
continue;
return (da);
}
return (NULL);
}
/*
* getdanam
* searches from the beginning of device_allocate for the device specified
* by its name.
* call to getdanam should be bracketed by setdaent and enddaent.
* returns pointer to devalloc_t for the device if it is found, else
* returns NULL if device not found or in case of error.
*/
{
return (NULL);
continue;
continue;
enddaent();
return (da);
}
}
return (NULL);
}
/*
* getdatype -
* searches from the beginning of device_allocate for the device specified
* by its type.
* call to getdatype should be bracketed by setdaent and enddaent.
* returns pointer to devalloc_t for the device if it is found, else
* returns NULL if device not found or in case of error.
*/
{
return (NULL);
continue;
continue;
return (da);
}
return (NULL);
}
/*
* da_matchname -
* checks if the specified devalloc_t is for the device specified.
* returns 1 if it is, else returns 0.
*/
int
{
return (0);
}
/*
* da_matchtype -
* checks if the specified devalloc_t is for the device type specified.
* returns 1 if match found, else, returns 0.
*/
int
{
return (0);
}
/*
* da_match -
* calls da_matchname or da_matchdev as appropriate.
*/
int
{
return (0);
}
/*
* da_interpret -
* parses val and initializes pointers in devalloc_t.
* returns pointer to parsed devalloc_t entry, else returns NULL on error.
*/
static devalloc_t *
{
char *opts;
int i;
return (NULL);
return (NULL);
}
/* remove any extraneous whitespace in the options */
}
}
if (system_labeled) {
/* if label range is not defined, use the default range. */
int i = 0, nlen = 0;
} else {
nlen++;
nlen++;
}
/*
* label range provided; we don't need to construct
* default range.
*/
goto out;
}
}
i++;
}
}
}
out:
return (&interpdevalloc);
}