diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/devfsadm/devfsadm.c | 40 | ||||
-rw-r--r-- | usr/src/uts/common/os/sunddi.c | 7 | ||||
-rw-r--r-- | usr/src/uts/common/sys/sysevent/dev.h | 69 | ||||
-rw-r--r-- | usr/src/uts/common/sys/sysevent/eventdefs.h | 8 |
4 files changed, 116 insertions, 8 deletions
diff --git a/usr/src/cmd/devfsadm/devfsadm.c b/usr/src/cmd/devfsadm/devfsadm.c index d368e03ad2..9b719ac04c 100644 --- a/usr/src/cmd/devfsadm/devfsadm.c +++ b/usr/src/cmd/devfsadm/devfsadm.c @@ -8257,6 +8257,41 @@ lookup_network_dev_name(char *node_path, char *driver_name) return (dev_name); } +static char * +lookup_printer_dev_name(char *node_path) +{ + struct devlink_cb_arg cb_arg; + char *dev_name = NULL; + int i; + +#define DEV_PRINTERS "/dev/printers/" + + cb_arg.count = 0; + cb_arg.rv = 0; + (void) di_devlink_cache_walk(devlink_cache, NULL, node_path, + DI_PRIMARY_LINK, &cb_arg, devlink_cb); + + if (cb_arg.rv == -1 || cb_arg.count == 0) + return (NULL); + + /* first try lookup based on /dev/printers name */ + for (i = 0; i < cb_arg.count; i++) { + if (strncmp(cb_arg.dev_names[i], DEV_PRINTERS, + sizeof (DEV_PRINTERS) - 1) == 0) { + dev_name = s_strdup(cb_arg.dev_names[i]); + break; + } + } + + /* fallback to the first name */ + if ((dev_name == NULL) && (cb_arg.count > 0)) + dev_name = s_strdup(cb_arg.dev_names[0]); + + free_dev_names(&cb_arg); + + return (dev_name); +} + /* * Build an nvlist containing all attributes for devfs events. * Returns nvlist pointer on success, NULL on failure. @@ -8303,6 +8338,11 @@ build_event_attributes(char *class, char *subclass, char *node_path, dev_name_lookup_err = 1; goto out; } + } else if (strcmp(subclass, ESC_PRINTER) == 0) { + if ((dev_name = lookup_printer_dev_name(node_path)) == NULL) { + dev_name_lookup_err = 1; + goto out; + } } if (dev_name) { diff --git a/usr/src/uts/common/os/sunddi.c b/usr/src/uts/common/os/sunddi.c index 6276144582..1709760d74 100644 --- a/usr/src/uts/common/os/sunddi.c +++ b/usr/src/uts/common/os/sunddi.c @@ -5698,6 +5698,13 @@ derive_devi_class(dev_info_t *dip, char *node_type, int flag) node_type[sizeof (DDI_NT_NET) - 1] == ':')) { rv = i_ddi_set_devi_class(dip, ESC_NETWORK, flag); + + } else if (strncmp(node_type, DDI_NT_PRINTER, + sizeof (DDI_NT_PRINTER) - 1) == 0 && + (node_type[sizeof (DDI_NT_PRINTER) - 1] == '\0' || + node_type[sizeof (DDI_NT_PRINTER) - 1] == ':')) { + + rv = i_ddi_set_devi_class(dip, ESC_PRINTER, flag); } } diff --git a/usr/src/uts/common/sys/sysevent/dev.h b/usr/src/uts/common/sys/sysevent/dev.h index 19e10f7a8c..9d3107d090 100644 --- a/usr/src/uts/common/sys/sysevent/dev.h +++ b/usr/src/uts/common/sys/sysevent/dev.h @@ -2,9 +2,8 @@ * 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. + * 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 * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -101,6 +100,39 @@ extern "C" { * Attribute Value - value of the devinfo_node_property * * + * Event schema for EC_DEV_ADD/ESC_PRINTER + * + * Event Class - EC_DEV_ADD + * Event Sub-Class - ESC_PRINTER + * + * Attribute Name - EV_VERSION + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - event version number + * + * Attribute Name - DEV_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - /dev/printers name associated with the device + * if exists. + * /dev name associated with the device if it exists + * + * Attribute Name - DEV_PHYS_PATH + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - physical path of the device without the "/devices" + * prefix. + * + * Attribute Name - DEV_DRIVER_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - driver name + * + * Attribute Name - DEV_INSTANCE + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - driver instance number + * + * Attribute Name - DEV_PROP_PREFIX<devinfo_node_property> + * Attribute Type - data type of the devinfo_node_property + * Attribute Value - value of the devinfo_node_property + * + * * Event schema for EC_DEV_REMOVE/ESC_DISK * * Event Class - EC_DEV_REMOVE @@ -158,6 +190,35 @@ extern "C" { * Attribute Value - driver instance number * * + * Event schema for EC_DEV_REMOVE/ESC_PRINTER + * + * Event Class - EC_DEV_REMOVE + * Event Sub-Class - ESC_PRINTER + * + * Attribute Name - EV_VERSION + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - event version number + * + * Attribute Name - DEV_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - /dev/printers name associated with the device + * if exists. + * /dev name associated with the device if it exists + * + * Attribute Name - DEV_PHYS_PATH + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - physical path of the device without the "/devices" + * prefix. + * + * Attribute Name - DEV_DRIVER_NAME + * Attribute Type - DATA_TYPE_STRING + * Attribute Value - driver name + * + * Attribute Name - DEV_INSTANCE + * Attribute Type - DATA_TYPE_INT32 + * Attribute Value - driver instance number + * + * * Event schema for EC_DEV_BRANCH/ESC_DEV_BRANCH_ADD or ESC_DEV_BRANCH_REMOVE * * Event Class - EC_DEV_BRANCH diff --git a/usr/src/uts/common/sys/sysevent/eventdefs.h b/usr/src/uts/common/sys/sysevent/eventdefs.h index 9a912cdb3e..b74d8ac4ba 100644 --- a/usr/src/uts/common/sys/sysevent/eventdefs.h +++ b/usr/src/uts/common/sys/sysevent/eventdefs.h @@ -2,9 +2,8 @@ * 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. + * 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 * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -185,6 +184,7 @@ extern "C" { */ #define ESC_DISK "disk" /* disk device */ #define ESC_NETWORK "network" /* network interface */ +#define ESC_PRINTER "printer" /* printer device */ /* * EC_DEV_BRANCH subclass defintions - supporting attributes (name/value pairs) |