preenlib.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
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright (c) 1992,1996, by Sun Microsystems, Inc.
* All rights reserved.
*/
/*
* common routines for parallelization (used by both fsck and quotacheck)
*/
#include <stdio.h>
#include <fcntl.h>
#include <dlfcn.h>
#include <macros.h>
/*
* data structures for parallelization
*/
static struct driver {
char *name; /* driver name (from DKIOCINFO) */
int (*choosefunc)(); /* driver specific chooser */
void *data; /* driver private data */
};
static struct onedev {
int drvid; /* index in driver array */
};
static struct rawdev {
char *devname; /* name passed to preen_addev */
};
static int debug = 0;
/*
* defines used in building shared object names
*/
/* the directory where we find shared objects */
#define OBJECT_DIRECTORY "/usr/lib/drv"
/* a shared object name is OBJECT_PREFIX || driver_name */
#define OBJECT_PREFIX "preen_"
/* the version of the driver interface we support */
#define OBJECT_VERSION 1
/* the "build" entry point for a driver specific object is named this */
#define BUILD_ENTRY preen_build_devs
#define BUILD_NAME "preen_build_devs"
#define DRIVER_ALLOC 10
static int chooseone();
void preen_addunit(void *, char *, int (*)(), void *, uint_t);
int preen_subdev(char *, struct dk_cinfo *, void *);
static int alloc_driver(char *, int (*)(), void *);
/*
* add the given device to the list of devices to be checked
*/
preen_addev(char *devnm)
{
int fd;
extern char *strdup();
return (-1);
}
perror("DKIOCINFO");
return (-1);
}
return (-1);
}
return (-1);
}
}
return (0);
}
{
char modname[255];
void *dlhandle;
int (*fptr)();
if (debug)
return (1);
}
if (debug)
return (1);
}
return (0);
}
/*
* select a device from the "unchecked" list, and add it to the
* active list.
*/
preen_getdev(char *devnm)
{
return (0);
if (rdp) {
}
return (1);
} else {
return (2);
}
}
preen_releasedev(char *name)
{
break;
}
return (-1);
} else {
}
/*
* free(dp->devname);
* free(dp);
*/
return (0);
}
static
struct rawdev *
{
int rc = 1;
if (rc != 0)
break;
}
if (rc == 0)
break;
}
/*
* remove from list...
*/
if (rdp) {
if (last) {
} else {
}
}
return (rdp);
}
/*
* by `cookie'
* If a new `driver' structure needs to be created, associate the given
* choosing function and driver private data with it.
*/
void
void *cookie,
char *dname, /* driver name */
int (*cf)(), /* candidate choosing function */
void *datap, /* driver private data */
{
register int drvid;
/*
* locate the driver struct
*/
break;
}
}
/*
* driver struct doesn't exist yet -- create one
*/
}
/*
* see if this device already references the given driver
*/
break;
}
/*
* allocate a new `struct onedev' and chain it in
* rdp->alldevs...
*/
}
/*
* add `unit' to the unitmap in devp
*/
}
static
int
{
extern char *strdup();
(struct driver *)
(struct driver *)
exit(1);
}
ndalloc += DRIVER_ALLOC;
}
exit(1);
}
return (ndrivers++);
}
static
struct onedev *
{
exit(1);
}
return (devp);
}
static
void
{
exit(1);
}
}
}
static
{
register int i;
return (1);
}
return (0);
}
/*
* preen_getdev.
*/
static
void
{
register int i;
exit(1);
}
}
for (i = 0; i < newsize; i++)
}
/*
* make each device in the given `rawdev' un-busy.
* Called from preen_releasedev
*/
static
void
{
register int i;
}
}