sysmsg.c revision 2bc92566ea035349acb03567b0d95e399c77c0d3
/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* System message redirection driver for Sun.
*
* Redirects system message output to the device designated as the underlying
* "hardware" console, as given by the value of sysmvp. The implementation
* assumes that sysmvp denotes a STREAMS device; the assumption is justified
* since consoles must be capable of effecting tty semantics.
*/
#include <sys/sysmsg_impl.h>
#include <sys/pathname.h>
/*
* internal functions
*/
static void bind_consadm_conf(char *);
static struct cb_ops sysm_cb_ops = {
sysmopen, /* open */
sysmclose, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
sysmread, /* read */
sysmwrite, /* write */
sysmioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
sysmpoll, /* poll */
ddi_prop_op, /* cb_prop_op */
NULL, /* streamtab */
CB_REV, /* cb_rev */
nodev, /* aread */
nodev /* awrite */
};
DEVO_REV, /* devo_rev, */
0, /* refcnt */
sysm_info, /* info */
nulldev, /* identify */
nulldev, /* probe */
sysm_attach, /* attach */
sysm_detach, /* detach */
nodev, /* reset */
&sysm_cb_ops, /* driver operations */
(struct bus_ops *)0, /* bus operations */
nulldev /* power */
};
/*
* Global variables associated with the console device:
*/
#define SYS_SYSMIN 0 /* sysmsg minor number */
/*
* Private driver state:
*/
#define MAXDEVS 5
typedef struct {
int dca_flags;
char dca_name[SYSPATHLEN];
/* list of dyn. + persist. config'ed dev's */
static kmutex_t dcvp_mutex;
/* flags for device cache */
#define SYSM_DISABLED 0x0
#define SYSM_ENABLED 0x1
/*
* Module linkage information for the kernel.
*/
&mod_driverops, /* Type of module. This one is a pseudo driver */
"System message redirection (fanout) driver %I%",
&sysm_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
&modldrv,
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}
int
{
}
/*
* DDI glue routines
*/
static int
{
int i;
switch (cmd) {
case DDI_ATTACH:
return (DDI_FAILURE);
}
for (i = 0; i < MAXDEVS; i++) {
}
return (DDI_SUCCESS);
case DDI_SUSPEND:
case DDI_PM_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
static int
{
int i;
switch (cmd) {
case DDI_DETACH:
for (i = 0; i < MAXDEVS; i++)
return (DDI_SUCCESS);
case DDI_SUSPEND:
case DDI_PM_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/* ARGSUSED */
static int
{
int rval = DDI_FAILURE;
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
rval = DDI_SUCCESS;
}
break;
case DDI_INFO_DEVT2INSTANCE:
rval = DDI_SUCCESS;
}
break;
default:
break;
}
return (rval);
}
/*
* Parse the contents of the buffer, and bind the named
* devices as auxiliary consoles using our own ioctl routine.
*
* Comments begin with '#' and are terminated only by a newline
* Device names begin with a '/', and are terminated by a newline,
* space, '#' or tab.
*/
static void
{
int eatcomments = 0;
if (eatcomments) {
if (*buf++ == '\n')
eatcomments = 0;
continue;
}
switch (*buf) {
case '/':
break;
case '#':
eatcomments = 1;
/*FALLTHROUGH*/
case ' ':
case '\t':
case '\n':
*buf = '\0';
break;
break;
default:
break;
}
buf++;
}
}
static void
bind_consadm_conf(char *path)
{
void *buf;
int err = 0;
return;
goto closevp;
}
else
}
/* ARGSUSED */
static int
{
int i;
return (ENXIO);
return (ENXIO);
}
if (!initialized) {
}
for (i = 0; i < MAXDEVS; i++) {
/*
* 4196476 - FTRUNC was causing E10K to return EINVAL
* on open
*/
/*
* Open failures on the auxiliary consoles are
* not returned because we don't care if some
* subset get an error. We know the default console
* is okay, and preserve the semantics of the
* open for the default console.
* Set NONBLOCK|NDELAY in case there's no carrier.
*/
}
}
return (0);
}
/* ARGSUSED */
static int
{
int i;
return (ENXIO);
/*
* Close the auxiliary consoles, we're not concerned with
* passing up the errors.
*/
for (i = 0; i < MAXDEVS; i++) {
}
}
return (0);
}
/* Reads occur only on the default console */
/* ARGSUSED */
static int
{
}
/* ARGSUSED */
static int
{
int i = 0;
for (i = 0; i < MAXDEVS; i++) {
NULL);
}
}
}
/* ARGSUSED */
static int
{
int rval = 0;
int error = 0;
int i;
char *infop;
char found = 0;
switch (cmd) {
case CIOCGETCONSOLE:
/* Sum over the number of enabled devices */
for (i = 0; i < MAXDEVS; i++) {
/* list is space separated, followed by NULL */
}
if (size == 0)
return (0);
break;
case CIOCSETCONSOLE:
case CIOCRMCONSOLE:
break;
case CIOCTTYCONSOLE:
{
dev_t d;
proc_t *p;
if (drv_getparm(UPROCP, &p) != 0)
return (ENODEV);
else
d = cttydev(p);
/*
* If the controlling terminal is the real
* or workstation console device, map to what the
* user thinks is the console device.
*/
if (d == rwsconsdev || d == rconsdev)
d = uconsdev;
return (EOVERFLOW);
flag))
return (EFAULT);
} else {
return (EFAULT);
}
return (0);
}
default:
/* everything else is sent to the console device */
}
return (EPERM);
else
if (error) {
switch (cmd) {
case CIOCGETCONSOLE:
/*
* If the buffer is null, then return a byte count
* to user land.
*/
goto err_exit;
default:
goto err_exit;
}
}
goto err_exit;
}
} else
goto err_exit;
}
switch (cmd) {
case CIOCGETCONSOLE:
/*
* Return the list of device names that are enabled.
*/
for (i = 0; i < MAXDEVS; i++) {
}
}
break;
case CIOCSETCONSOLE:
break;
/*
* The device does not have to be open or disabled to
* perform the set console.
*/
for (i = 0; i < MAXDEVS; i++) {
break;
found = 1;
break;
found = 1;
break;
}
}
break;
case CIOCRMCONSOLE:
for (i = 0; i < MAXDEVS; i++) {
found = 1;
break;
}
}
if (found == 0)
break;
default:
break;
}
return (rval);
}
/* As with the read, we poll only the default console */
/* ARGSUSED */
static int
{
}
/* Sanity check that the device is good */
static int
{
int rval = 0;
} else {
}
return (rval);
}