diff options
Diffstat (limited to 'usr/src/cmd')
| -rw-r--r-- | usr/src/cmd/mdb/common/modules/genunix/devinfo.c | 36 | ||||
| -rw-r--r-- | usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c | 7 | ||||
| -rw-r--r-- | usr/src/cmd/mdb/i86pc/modules/uppc/uppc.c | 2 | ||||
| -rw-r--r-- | usr/src/cmd/modload/add_drv.c | 15 | ||||
| -rw-r--r-- | usr/src/cmd/modload/addrem.h | 12 | ||||
| -rw-r--r-- | usr/src/cmd/modload/drvsubr.c | 117 | ||||
| -rw-r--r-- | usr/src/cmd/modload/errmsg.h | 9 | ||||
| -rw-r--r-- | usr/src/cmd/modload/rem_drv.c | 9 | ||||
| -rw-r--r-- | usr/src/cmd/modload/update_drv.c | 20 |
9 files changed, 167 insertions, 60 deletions
diff --git a/usr/src/cmd/mdb/common/modules/genunix/devinfo.c b/usr/src/cmd/mdb/common/modules/genunix/devinfo.c index adab304cdb..296fa0c414 100644 --- a/usr/src/cmd/mdb/common/modules/genunix/devinfo.c +++ b/usr/src/cmd/mdb/common/modules/genunix/devinfo.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1072,7 +1072,7 @@ devinfo(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { char tmpstr[MODMAXNAMELEN]; char nodename[MODMAXNAMELEN]; - char bindname[MODMAXNAMELEN]; + char bindname[MAXPATHLEN]; int size, length; struct dev_info devi; devinfo_node_t din; @@ -1082,6 +1082,7 @@ devinfo(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { "DEVICE_OFFLINE", DEVI_DEVICE_OFFLINE, DEVI_DEVICE_OFFLINE }, { "DEVICE_DOWN", DEVI_DEVICE_DOWN, DEVI_DEVICE_DOWN }, { "DEVICE_DEGRADED", DEVI_DEVICE_DEGRADED, DEVI_DEVICE_DEGRADED }, + { "DEVICE_REMOVED", DEVI_DEVICE_REMOVED, DEVI_DEVICE_REMOVED }, { "BUS_QUIESCED", DEVI_BUS_QUIESCED, DEVI_BUS_QUIESCED }, { "BUS_DOWN", DEVI_BUS_DOWN, DEVI_BUS_DOWN }, { "NDI_CONFIG", DEVI_NDI_CONFIG, DEVI_NDI_CONFIG }, @@ -1096,6 +1097,7 @@ devinfo(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { "S_REPORT", DEVI_S_REPORT, DEVI_S_REPORT }, { "S_EVADD", DEVI_S_EVADD, DEVI_S_EVADD }, { "S_EVREMOVE", DEVI_S_EVREMOVE, DEVI_S_EVREMOVE }, + { "S_NEED_RESET", DEVI_S_NEED_RESET, DEVI_S_NEED_RESET }, { NULL, 0, 0 } }; @@ -1105,6 +1107,13 @@ devinfo(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { "ATTACHED_CHILDREN", DEVI_ATTACHED_CHILDREN, DEVI_ATTACHED_CHILDREN}, { "BRANCH_HELD", DEVI_BRANCH_HELD, DEVI_BRANCH_HELD }, + { "NO_BIND", DEVI_NO_BIND, DEVI_NO_BIND }, + { "DEVI_REGISTERED_DEVID", + DEVI_REGISTERED_DEVID, DEVI_REGISTERED_DEVID }, + { "PHCI_SIGNALS_VHCI", + DEVI_PHCI_SIGNALS_VHCI, + DEVI_PHCI_SIGNALS_VHCI }, + { "REBIND", DEVI_REBIND, DEVI_REBIND }, { NULL, 0, 0 } }; @@ -1716,9 +1725,8 @@ binding_hash_entry(uintptr_t addr, uint_t flags, int argc, { struct bind bind; /* Arbitrary lengths based on output format below */ - char name[25] = "???"; - char bind_name[32] = "<null>"; - + char name[MAXPATHLEN] = "???"; + char bind_name[MAXPATHLEN] = "<null>"; if ((flags & DCMD_ADDRSPEC) == NULL) return (DCMD_USAGE); @@ -1733,18 +1741,22 @@ binding_hash_entry(uintptr_t addr, uint_t flags, int argc, } if (DCMD_HDRSPEC(flags)) { - mdb_printf("%<u>%-32s %-5s %-?s%</u>\n", - "NAME", "MAJOR", "NEXT"); + mdb_printf("%<u>%?s% %-5s %s%</u>\n", + "NEXT", "MAJOR", "NAME(S)"); } if (mdb_readstr(name, sizeof (name), (uintptr_t)bind.b_name) == -1) mdb_warn("failed to read 'name'"); - /* There may be no binding name for a driver, so this may fail */ - (void) mdb_readstr(bind_name, sizeof (bind_name), - (uintptr_t)bind.b_bind_name); - - mdb_printf("%-32s %3d %?p\n", name, bind.b_num, bind.b_next); + /* There may be bind_name, so this may fail */ + if (mdb_readstr(bind_name, sizeof (bind_name), + (uintptr_t)bind.b_bind_name) == -1) { + mdb_printf("%?p %5d %s\n", + bind.b_next, bind.b_num, name); + } else { + mdb_printf("%?p %5d %s %s\n", + bind.b_next, bind.b_num, name, bind_name); + } return (DCMD_OK); } diff --git a/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c b/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c index 869c58c6e0..3d7537a1d6 100644 --- a/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c +++ b/usr/src/cmd/mdb/common/modules/mdb_ks/mdb_ks.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -863,8 +863,7 @@ find_mbind(const char *name, uintptr_t *hashtab) int hashndx; uintptr_t mb; struct bind mb_local; - char node_name[MODMAXNAMELEN + 1]; - + char node_name[MAXPATHLEN + 1]; hashndx = nm_hash(name); mb = hashtab[hashndx]; @@ -944,7 +943,7 @@ int mdb_devinfo2driver(uintptr_t dip_addr, char *drivername, size_t namebufsize) { struct dev_info devinfo; - char bind_name[MODMAXNAMELEN + 1]; + char bind_name[MAXPATHLEN + 1]; major_t major; const char *namestr; diff --git a/usr/src/cmd/mdb/i86pc/modules/uppc/uppc.c b/usr/src/cmd/mdb/i86pc/modules/uppc/uppc.c index fee48b58f5..0bd87f8a65 100644 --- a/usr/src/cmd/mdb/i86pc/modules/uppc/uppc.c +++ b/usr/src/cmd/mdb/i86pc/modules/uppc/uppc.c @@ -33,7 +33,7 @@ static uint16_t shared_tbl[MAX_ISA_IRQ + 1]; static char * interrupt_print_bus(uintptr_t dip_addr) { - char bind_name[MODMAXNAMELEN + 1]; + char bind_name[MAXPATHLEN + 1]; struct dev_info dev_info; if (mdb_vread(&dev_info, sizeof (dev_info), dip_addr) == -1) { diff --git a/usr/src/cmd/modload/add_drv.c b/usr/src/cmd/modload/add_drv.c index d40eec2902..62da6d8796 100644 --- a/usr/src/cmd/modload/add_drv.c +++ b/usr/src/cmd/modload/add_drv.c @@ -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 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -525,7 +524,7 @@ update_driver_classes( { /* make call to update the classes file */ return (append_to_file(driver_name, classes, driver_classes, - ' ', "\t")); + ' ', "\t", 0)); } static int @@ -533,7 +532,8 @@ update_minor_perm( char *driver_name, char *perm_list) { - return (append_to_file(driver_name, perm_list, minor_perm, ',', ":")); + return (append_to_file(driver_name, perm_list, minor_perm, + ',', ":", 0)); } @@ -567,7 +567,8 @@ update_extra_privs( char *driver_name, char *privlist) { - return (append_to_file(driver_name, privlist, extra_privs, ',', ":")); + return (append_to_file(driver_name, privlist, extra_privs, + ',', ":", 0)); } /* diff --git a/usr/src/cmd/modload/addrem.h b/usr/src/cmd/modload/addrem.h index e4b70bea10..c1763c760d 100644 --- a/usr/src/cmd/modload/addrem.h +++ b/usr/src/cmd/modload/addrem.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 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -125,9 +124,9 @@ extern int check_name_to_major(int); extern void enter_lock(void); extern void err_exit(void); extern void exit_unlock(void); -extern char *get_entry(char *, char *, char); +extern char *get_entry(char *, char *, char, int); extern int build_filenames(char *); -extern int append_to_file(char *, char *, char *, char, char *); +extern int append_to_file(char *, char *, char *, char, char *, int); extern int get_major_no(char *, char *); extern int get_driver_name(int, char *, char *); extern int delete_entry(char *, char *, char *, char *); @@ -139,6 +138,7 @@ extern int update_name_to_major(char *, major_t *, int); extern int do_the_update(char *, char *); extern int fill_n2m_array(char *, char **, int *); extern int aliases_unique(char *); +extern int aliases_paths_exist(char *); extern int update_driver_aliases(char *, char *); extern int unique_driver_name(char *, char *, int *); extern int unique_drv_alias(char *); diff --git a/usr/src/cmd/modload/drvsubr.c b/usr/src/cmd/modload/drvsubr.c index f1fb38add3..37daeaf6f7 100644 --- a/usr/src/cmd/modload/drvsubr.c +++ b/usr/src/cmd/modload/drvsubr.c @@ -106,7 +106,8 @@ append_to_file( char *entry_list, char *filename, char list_separator, - char *entry_separator) + char *entry_separator, + int quoted) { int i, len; int fpint; @@ -153,12 +154,16 @@ append_to_file( line[i] = 0; current_head = get_entry(previous_head, one_entry, - list_separator); + list_separator, quoted); previous_head = current_head; (void) strcpy(line, driver_name); (void) strcat(line, entry_separator); + if (quoted) + (void) strcat(line, "\""); (void) strcat(line, one_entry); + if (quoted) + (void) strcat(line, "\""); (void) strcat(line, "\n"); if ((fputs(line, fp)) == EOF) { @@ -615,16 +620,20 @@ get_name_to_major_entry(int *major_no, char *driver_name, char *file_name) } /* - * given pointer to member n in space separated list, return pointer - * to member n+1, return member n + * Given pointer to begining of member 'n' in a space (or separator) + * separated list, return pointer to member 'n+1', and establish member 'n' + * in *current_entry. If unquote, then we skip a leading quote and treat + * the trailing quote as a separator (and skip). */ char * get_entry( char *prev_member, char *current_entry, - char separator) + char separator, + int unquote) { - char *ptr; + char *ptr; + int quoted = 0; ptr = prev_member; @@ -632,14 +641,25 @@ get_entry( while (*ptr == '\t' || *ptr == ' ') ptr++; - /* read thru the current entry */ - while (*ptr != separator && *ptr != '\0') { + /* if unquote skip leading quote */ + if (unquote && *ptr == '"') { + quoted++; + ptr++; + } + + /* read thru the current entry looking for end, separator, or unquote */ + while (*ptr && + (*ptr != separator) && + ((separator != ' ') || (*ptr != '\t')) && + (!quoted || (*ptr != '"'))) { *current_entry++ = *ptr++; } *current_entry = '\0'; - if ((separator == ',') && (*ptr == separator)) - ptr++; /* skip over comma */ + if (separator && (*ptr == separator)) + ptr++; /* skip over separator */ + if (quoted && (*ptr == '"')) + ptr++; /* skip over trailing quote */ /* skip white space */ while (*ptr == '\t' || *ptr == ' ') { @@ -1003,7 +1023,7 @@ config_driver( return (ERROR); } current = get_entry(previous, - cmdline[n++], ' '); + cmdline[n++], ' ', 0); previous = current; } while (*current != '\0'); @@ -1395,7 +1415,7 @@ check_perm_opts(char *perm_list) for (i = 0; i <= len; i++) one_entry[i] = 0; - current_head = get_entry(previous_head, one_entry, ','); + current_head = get_entry(previous_head, one_entry, ',', 0); previous_head = current_head; scan_stat = sscanf(one_entry, "%s%s%s%s%s", minor, perm, own, @@ -1453,7 +1473,7 @@ aliases_unique(char *aliases) for (i = 0; i <= len; i++) one_entry[i] = 0; - current_head = get_entry(previous_head, one_entry, ' '); + current_head = get_entry(previous_head, one_entry, ' ', 1); previous_head = current_head; if ((unique_driver_name(one_entry, name_to_major, @@ -1490,14 +1510,66 @@ aliases_unique(char *aliases) } +/* + * check each alias : + * if path-oriented alias, path exists + */ +int +aliases_paths_exist(char *aliases) +{ + char *current_head; + char *previous_head; + char *one_entry; + int i, len; + char path[MAXPATHLEN]; + struct stat buf; + + len = strlen(aliases); + + one_entry = calloc(len + 1, 1); + if (one_entry == NULL) { + (void) fprintf(stderr, gettext(ERR_NO_MEM)); + return (ERROR); + } + + previous_head = aliases; + + do { + for (i = 0; i <= len; i++) + one_entry[i] = 0; + + current_head = get_entry(previous_head, one_entry, ' ', 1); + previous_head = current_head; + + /* if the alias is a path, ensure that the path exists */ + if (*one_entry != '/') + continue; + (void) snprintf(path, sizeof (path), "/devices/%s", one_entry); + if (stat(path, &buf) == 0) + continue; + + /* no device at specified path-oriented alias path */ + (void) fprintf(stderr, gettext(ERR_PATH_ORIENTED_ALIAS), + one_entry); + free(one_entry); + return (ERROR); + + } while (*current_head != '\0'); + + free(one_entry); + + return (NOERR); +} + + int update_driver_aliases( char *driver_name, char *aliases) { /* make call to update the aliases file */ - return (append_to_file(driver_name, aliases, driver_aliases, ' ', " ")); - + return (append_to_file(driver_name, aliases, driver_aliases, + ' ', " ", 1)); } @@ -1508,6 +1580,7 @@ unique_drv_alias(char *drv_alias) char drv[FILENAME_MAX + 1]; char line[MAX_N2M_ALIAS_LINE + 1], *cp; char alias[FILENAME_MAX + 1]; + char *a; int status = NOERR; fp = fopen(driver_aliases, "r"); @@ -1526,8 +1599,16 @@ unique_drv_alias(char *drv_alias) (void) fprintf(stderr, gettext(ERR_BAD_LINE), driver_aliases, line); + /* unquote for compare */ + if ((*alias == '"') && + (*(alias + strlen(alias) - 1) == '"')) { + a = &alias[1]; + alias[strlen(alias) - 1] = '\0'; + } else + a = alias; + if ((strcmp(drv_alias, drv) == 0) || - (strcmp(drv_alias, alias) == 0)) { + (strcmp(drv_alias, a) == 0)) { (void) fprintf(stderr, gettext(ERR_ALIAS_IN_USE), drv_alias); @@ -1656,7 +1737,7 @@ update_name_to_major(char *driver_name, major_t *major_num, int server) "%d", is_unique); if (append_to_file(driver_name, major, - name_to_major, ' ', " ") == ERROR) { + name_to_major, ' ', " ", 0) == ERROR) { (void) fprintf(stderr, gettext(ERR_NO_UPDATE), name_to_major); @@ -1857,7 +1938,7 @@ int do_the_update(char *driver_name, char *major_number) { return (append_to_file(driver_name, major_number, name_to_major, - ' ', " ")); + ' ', " ", 0)); } /* diff --git a/usr/src/cmd/modload/errmsg.h b/usr/src/cmd/modload/errmsg.h index 6412f4d24b..a29f866cd9 100644 --- a/usr/src/cmd/modload/errmsg.h +++ b/usr/src/cmd/modload/errmsg.h @@ -56,8 +56,10 @@ extern "C" { #define ERR_INSTALL_FAIL "Error: Could not install driver (%s).\n" #define ERR_DRVNAME_TOO_LONG "Error: driver name must not exceed (%d)" \ " characters; driver name too long (%s)\n" -#define ERR_ALIAS_IN_NAM_MAJ "Alias (%s) already in use as driver name.\n" -#define ERR_ALIAS_IN_USE "(%s) already in use as a driver or alias.\n" +#define ERR_ALIAS_IN_NAM_MAJ \ +"Alias (\"%s\") already in use as driver name.\n" +#define ERR_ALIAS_IN_USE \ +"(\"%s\") already in use as a driver or alias.\n" #define ERR_CANT_ACCESS_FILE "Cannot access file (%s).\n" #define ERR_BAD_PATH "Bad syntax for pathname : (%s)\n" #define ERR_FORK_FAIL "Fork failed; cannot exec : %s\n" @@ -171,6 +173,9 @@ Use octal escape sequence \"\\040\".\n" #define ERR_REMDRV_CLEANUP \ "post-rem_drv devfs cleanup for driver %s failed (%d)\n" +#define ERR_PATH_ORIENTED_ALIAS \ + "no device at specified path-oriented alias \"%s\"\n" + #ifdef __cplusplus } #endif diff --git a/usr/src/cmd/modload/rem_drv.c b/usr/src/cmd/modload/rem_drv.c index 189cc5e9d9..761c52b60c 100644 --- a/usr/src/cmd/modload/rem_drv.c +++ b/usr/src/cmd/modload/rem_drv.c @@ -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 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -169,7 +168,7 @@ main(int argc, char *argv[]) (void) sprintf(maj_num, "%d", found); if (append_to_file(driver_name, maj_num, - rem_name_to_major, ' ', " ") == ERROR) { + rem_name_to_major, ' ', " ", 0) == ERROR) { (void) fprintf(stderr, gettext(ERR_NO_UPDATE), rem_name_to_major); err_exit(); diff --git a/usr/src/cmd/modload/update_drv.c b/usr/src/cmd/modload/update_drv.c index 6b49f43a5f..8efbc6d7e9 100644 --- a/usr/src/cmd/modload/update_drv.c +++ b/usr/src/cmd/modload/update_drv.c @@ -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 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -270,7 +269,7 @@ main(int argc, char *argv[]) if (priv != NULL) { (void) append_to_file(driver_name, priv, extra_privs, - ',', ":"); + ',', ":", 0); cleanup_flag |= CLEAN_DRV_PRIV; } @@ -306,6 +305,17 @@ main(int argc, char *argv[]) return (error); } + /* + * unless force_flag is specified check that + * path-oriented aliases we are adding exist + */ + if ((force_flag == 0) && + ((error = aliases_paths_exist(aliases)) == ERROR)) { + exit_unlock(); + + return (error); + } + /* update the file */ if ((error = update_driver_aliases(driver_name, aliases)) == ERROR) { |
