/*
*
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements.
*
*
* This distribution may include materials developed by third parties. Sun,
* Sun Microsystems, the Sun logo and Solaris are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <limits.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/systeminfo.h>
typedef struct nms {
char *dsk;
int dnum;
char *dty;
char *real;
int devtype;
} nms_t;
typedef struct list_of_disks {
char *dtype;
int dnum;
char *dsk;
} disk_list_t;
static nms_t *rummage_dev_dsk(void);
static void do_snm(char *, char *);
static int look_up_name(const char *, nms_t *);
static void make_an_entry(char *, const char *, nms_t **, int);
static char *trim(char *);
static void rummage_path_to_inst(nms_t *);
static void insert_dlist_ent(const char *, const int, const char *,
int, disk_list_t **);
static int str_is_digit(char *);
extern void *build_disk_list(void *);
extern char *lookup_ks_name(char *, void *);
#define DISK 0
/*
* Build a list of disks attached to the system. if a previous list is passed
* in, delete that list before building the new list.
*/
void *
build_disk_list(void *v)
{
nms_t *t;
disk_list_t *p;
int i;
p = (disk_list_t *)v;
if (p != (disk_list_t *)NULL) {
disk_list_t *t;
while (p) {
for (i = 0; i < NDKMAP; i++)
t = p;
p = p->next;
(void) free(t);
}
}
/*
* Build the list of devices connected to the system.
*/
list = rummage_dev_dsk();
t = list;
while (t) {
nms_t *f;
f = t;
t = t->next;
if (t != list) {
(void) free(f);
}
}
return (rv);
}
/*
* Currently it isn't necessary to look below the cntndn level....
*/
static nms_t *
rummage_dev_dsk(void)
{
int i;
for (i = 0; i < MAX_TYPES; i++) {
switch (i) {
case DISK:
break;
case TAPE:
break;
default:
break;
}
char *npt;
continue;
if (i == DISK) {
} else {
/*
* devices for a tape
*/
continue;
}
continue;
if (i == DISK) {
} else {
}
int cnt;
== S_IFLNK) {
nmbuf[0] = '\0';
} else
npt = (char *)0;
} else
if (npt)
&list, i);
}
}
}
}
return (list);
}
static int
{
int rv = 0;
else {
rv++;
break;
}
}
return (rv);
}
static void
{
*shortnm = '\0';
}
static void
{
int len;
char *nlnm;
len++;
len++;
} else
} else {
}
} else
}
}
static char *
{
char *ptr;
lname++;
fnm++;
}
*ptr = '\0';
return (fnm);
}
static void
{
if (inpt) {
if (ibuf[0] != '#') {
}
}
}
}
/*
* Process an /etc/path_to_inst line. The line is of the format:
* devicenumber and the device from this string if it is one of the ones in
*/
static int
{
char *rpt;
char *bpt;
int rv = 0;
int done;
int len;
char *v;
/*
* Skip over any stuff at the beginning of the line before a leading
* '/' If we don't find a '/', the line is malformed and we just skip
* it.
*/
while (*ib) {
if (*ib != '/')
ib++;
else
break;
}
if (!(*ib))
goto done;
/*
* Find the trailing '"' in the line. If not found, we just
* skip the line.
*/
/*
* If no match, we're not interested.
*/
if (!rpt)
goto done;
*rpt = '\0';
goto done;
/*
* Extract the device number at the end of
* the line. We expect whitespace followed by
* the beginning of the currently numeric
* device id string;
*/
rpt++;
done = 0;
while (!done) {
if (*rpt) {
if (*rpt != '\n') {
rpt++;
else
done++;
} else
done++;
} else
done++;
}
/*
* Should now be at the beginning of the
* device number. Point entry->dn at the
* string.
*/
if (*rpt) {
v = rpt;
len = 0;
while (v) {
if (*v != '\n') {
v++;
len++;
} else {
*v = '\0';
v = (char *)NULL;
}
}
if (len) {
if (*bpt != '@')
bpt--;
else
break;
}
*bpt-- = '\0';
len = 0;
if (*bpt != '/') {
bpt--;
len++;
} else
break;
}
bpt++;
len++;
rv++;
}
}
}
}
}
done:
return (rv);
}
static nms_t *
{
while (list) {
else
break;
}
return (list);
}
static void
{
while (list) {
}
}
/*
* Determine if a name is already in the list of disks. If not, insert the
* name in the list.
*/
static void
{
int i, len;
return;
while (stuff) {
else
break;
}
if (!stuff) {
int mv;
sizeof (disk_list_t));
if (entry) {
for (i = 0; i < NDKMAP; i++) {
"%ss%d\0", nm, i);
}
} else
}
/*
* Figure out where to insert the name. The list is
* ostensibly in sorted order.
*/
/*
* Look through the list. While the strcmp
* value is less than the current value,
*/
while (stuff) {
} else
break;
}
if (mv == 0) {
while (stuff) {
break;
} else
break;
}
}
/*
* We should now be ready to insert an
* entry...
*/
if (mv >= 0) {
} else {
}
} else {
/*
* insert at the end of the
* list
*/
}
} else {
}
}
}
}
char *
{
char *rv = (char *)0;
int dv;
char *device;
int len;
char *tmpnm;
char *nm;
int partition;
}
*tmpnm = '\0';
if (*dev_nm == ',') {
dev_nm++;
partition = -1;
} else
partition = -1;
len = 0;
while (*nm) {
nm++;
len++;
} else
break;
}
if (*nm) {
int mv;
while (list) {
else
break;
}
if (mv == 0) {
while (list) {
else
break;
}
if(list) {
if ((partition != -1) &&
else
}
}
}
}
return (rv);
}
static int
{
int i;
int j = 0;
}
return (1);
else
return (0);
}