sad.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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* STREAMS Administrative Driver
*
* Currently only handles autopush and module name verification.
*/
#include <sys/priv_names.h>
static void apush_ioctl(), apush_iocdata();
static void vml_ioctl(), vml_iocdata();
static int valid_major(major_t);
static struct module_info sad_minfo = {
};
};
};
};
/*
* Module linkage information for the kernel.
*/
&mod_driverops, /* Type of module. This one is a pseudo driver */
"STREAMS Administrative Driver 'sad' %I%",
&sad_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}
int
{
}
static int
{
if (cmd != DDI_ATTACH)
return (DDI_FAILURE);
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/* ARGSUSED */
static int
{
int error;
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
error = DDI_FAILURE;
} else {
error = DDI_SUCCESS;
}
break;
case DDI_INFO_DEVT2INSTANCE:
*result = (void *)0;
error = DDI_SUCCESS;
break;
default:
error = DDI_FAILURE;
}
return (error);
}
/*
* sadinit() -
* Initialize autopush freelist.
*/
void
sadinit()
{
int i;
/*
* build the autopush freelist.
*/
for (i = 1; i < nautopush; i++) {
}
}
/*
* sadopen() -
* Allocate a sad device. Only one
* open at a time allowed per device.
*/
/* ARGSUSED */
static int
int flag, /* file open flags */
int sflag, /* stream open flags */
{
int i;
if (sflag) /* no longer called from clone driver */
return (EINVAL);
/*
* Both USRMIN and ADMMIN are clone interfaces.
*/
for (i = 0; i < sadcnt; i++)
break;
if (i >= sadcnt) /* no such device */
return (ENXIO);
case USRMIN: /* mere mortal */
break;
case ADMMIN: /* privileged user */
break;
default:
return (EINVAL);
}
/*
* NOTE: should the ADMMIN or USRMIN minors change
* then so should the offset of 2 below
* Both USRMIN and ADMMIN are clone interfaces and
* therefore their minor numbers (0 and 1) are reserved.
*/
return (0);
}
/*
* sadclose() -
* Clean up the data structures.
*/
/* ARGSUSED */
static int
int flag, /* file open flags */
{
return (0);
}
/*
* sadwput() -
* Write side put procedure.
*/
static int
{
case M_FLUSH:
} else
break;
case M_IOCTL:
break;
case SAD_VML:
break;
default:
break;
}
break;
case M_IOCDATA:
break;
case SAD_VML:
break;
default:
"sadwput: invalid ioc_cmd in case M_IOCDATA: %d",
break;
}
break;
default:
break;
} /* switch (db_type) */
return (0);
}
/*
* apush_ioctl() -
* Handle the M_IOCTL messages associated with
* the autopush feature.
*/
static void
{
return;
}
return;
}
break;
}
/* FALLTHRU */
else
break;
default:
ASSERT(0);
break;
} /* switch (ioc_cmd) */
}
/*
* apush_iocdata() -
* Handle the M_IOCDATA messages associated with
* the autopush feature.
*/
static void
{
int i, ret;
return;
}
/* sap needed only if mp->b_cont is set */
switch ((long)csp->cp_private) {
case GETSTRUCT:
case SAP_ONE:
case SAP_RANGE:
case SAP_ALL:
/* invalid number of modules to push */
break;
}
break;
}
/* bad range */
break;
}
/*
* Validate that the specified list of
* modules exist.
*/
FMODSW_LOAD) == NULL) {
return;
}
}
/* already configured */
break;
}
/* no autopush structures */
break;
}
else
break;
case SAP_CLEAR:
break;
}
/* not configured */
break;
}
/* starting minors do not match */
break;
}
/* SAP_ALL must have minor == 0 */
break;
}
break;
default:
break;
} /* switch (sap_cmd) */
break;
default:
"apush_iocdata: cp_private bad in SAD_SAP: %p",
(void *)csp->cp_private);
break;
} /* switch (cp_private) */
break;
switch ((long)csp->cp_private) {
case GETSTRUCT: {
break;
}
/* not configured */
break;
}
for (; i < MAXAPUSH; i++)
else
NULL);
break;
}
case GETRESULT:
break;
default:
"apush_iocdata: cp_private bad case SAD_GAP: %p",
(void *)csp->cp_private);
break;
} /* switch (cp_private) */
break;
default: /* can't happen */
ASSERT(0);
break;
} /* switch (cp_cmd) */
}
/*
* ap_alloc() -
* Allocate an autopush structure.
*/
static struct autopush *
ap_alloc(void)
{
return (NULL);
return (ap);
}
/*
* ap_free() -
* Give an autopush structure back to the freelist.
*/
void
{
}
/*
* ap_hadd() -
* Add an autopush structure to the hash list.
*/
static void
{
}
/*
* ap_hrmv() -
* Remove an autopush structure from the hash list.
*/
static void
{
while (hap) {
if (prevp)
else
return;
} /* if */
} /* while */
}
/*
* ap_hfind() -
* Look for an autopush structure in the hash list
* based on major, minor, lastminor, and command.
*/
static struct autopush *
{
while (ap) {
break;
case SAP_ALL:
break;
case SAP_ONE:
break;
break;
continue;
case SAP_RANGE:
break;
break;
continue;
default:
ASSERT(0);
break;
}
break;
}
}
return (ap);
}
/*
* vml_ioctl() -
* Handle the M_IOCTL message associated with a request
* to validate a module list.
*/
static void
{
return;
}
}
/*
* vml_iocdata() -
* Handle the M_IOCDATA messages associated with
* a request to validate a module list.
*/
static void
{
long i;
int nmods;
return;
}
switch ((long)csp->cp_private) {
case GETSTRUCT:
if (nmods <= 0) {
break;
}
break;
case GETLIST:
return;
}
}
break;
default:
(void *)csp->cp_private);
break;
} /* switch (cp_private) */
}
/*
* Validate a major number and also verify if
* it is a STREAMS device.
* Return values: 0 if a valid STREAMS dev
* error code otherwise
*/
static int
{
int ret = 0;
return (EINVAL);
/*
* attempt to load the driver 'major' and verify that
* it is a STREAMS driver.
*/
return (EINVAL);
if (!STREAMSTAB(major))
return (ret);
}