device_info.h revision 7323:f8232df17d05
1193323Sed/* 2193323Sed * CDDL HEADER START 3193323Sed * 4193323Sed * The contents of this file are subject to the terms of the 5193323Sed * Common Development and Distribution License (the "License"). 6193323Sed * You may not use this file except in compliance with the License. 7193323Sed * 8193323Sed * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9193323Sed * or http://www.opensolaris.org/os/licensing. 10193323Sed * See the License for the specific language governing permissions 11193323Sed * and limitations under the License. 12193323Sed * 13193323Sed * When distributing Covered Code, include this CDDL HEADER in each 14193323Sed * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15193323Sed * If applicable, add the following below this CDDL HEADER, with the 16193323Sed * fields enclosed by brackets "[]" replaced with your own identifying 17193323Sed * information: Portions Copyright [yyyy] [name of copyright owner] 18193323Sed * 19193323Sed * CDDL HEADER END 20193323Sed */ 21193323Sed/* 22193323Sed * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23198090Srdivacky * Use is subject to license terms. 24198090Srdivacky */ 25193323Sed 26193323Sed/* 27193323Sed * WARNING: 28193323Sed * The interfaces defined in this header file are for Sun private use only. 29193323Sed * The contents of this file are subject to change without notice in 30193323Sed * future releases. 31193323Sed */ 32193323Sed 33193323Sed#ifndef _DEVICE_INFO_H 34193323Sed#define _DEVICE_INFO_H 35193323Sed 36198090Srdivacky#ifdef __cplusplus 37193323Sedextern "C" { 38193323Sed#endif 39193323Sed 40193323Sed/* error return values */ 41193323Sed#define DEVFS_ERR -1 /* operation not successful */ 42193323Sed#define DEVFS_INVAL -2 /* invalid argument */ 43193323Sed#define DEVFS_NOMEM -3 /* out of memory */ 44193323Sed#define DEVFS_PERM -4 /* permission denied - not root */ 45193323Sed#define DEVFS_NOTSUP -5 /* operation not supported */ 46198090Srdivacky#define DEVFS_LIMIT -6 /* exceeded maximum size of property value */ 47198090Srdivacky#define DEVFS_NOTFOUND -7 /* request not found */ 48193323Sed 49198090Srdivacky/* 50193323Sed * for devfs_set_boot_dev() 51193323Sed * default behavior is to translate the input logical device name 52193323Sed * to most compact prom name(i.e. a prom alias, if one exists) 53193323Sed * as possible. And to prepend the new entry to the existing 54193323Sed * list. 55193323Sed */ 56193323Sed 57193323Sed/* perform no translation on the input device path */ 58193323Sed#define BOOTDEV_LITERAL 0x1 59193323Sed/* convert the input device path only a prom device path; not an alias */ 60193323Sed#define BOOTDEV_PROMDEV 0x2 61193323Sed/* overwrite the existing entry in boot-device - default is to prepend */ 62193323Sed#define BOOTDEV_OVERWRITE 0x4 63193323Sed 64193323Sed/* 65193323Sed * for devfs_get_prom_names() 66193323Sed * returns a list of prom names for a given logical device name. 67193323Sed * the list is sorted first in order of exact aliases, inexact alias 68193323Sed * matches (where an option override was needed), and finally the 69193323Sed * equivalent prom device path. Each sublist is sorted in collating 70193323Sed * order. 71193323Sed */ 72193323Sed#define BOOTDEV_NO_PROM_PATH 0x1 73193323Sed#define BOOTDEV_NO_INEXACT_ALIAS 0x2 74193323Sed#define BOOTDEV_NO_EXACT_ALIAS 0x4 75193323Sed 76193323Sed/* for devfs_get_boot_dev() */ 77193323Sedstruct boot_dev { 78193323Sed char *bootdev_element; /* an entry from the boot-device variable */ 79193323Sed char **bootdev_trans; /* 0 or more logical dev translations */ 80193323Sed}; 81193323Sed 82193323Sed/* for devfs_get_all_prom_names() */ 83193323Sedstruct devfs_prom_path { 84193323Sed char *obp_path; 85193323Sed char **alias_list; 86193323Sed struct devfs_prom_path *next; 87193323Sed}; 88193323Sed 89193323Sed/* prototypes */ 90193323Sed 91193323Sed/* return the driver for a given device path */ 92193323Sedextern int devfs_path_to_drv(char *devfs_path, char *drv_buf); 93193323Sed 94193323Sed/* convert a logical or physical device name to the equivalent prom path */ 95193323Sedextern int devfs_dev_to_prom_name(char *, char *); 96193323Sed 97193323Sed/* return the driver name after resolving any aliases */ 98193323Sedextern char *devfs_resolve_aliases(char *drv); 99193323Sed 100193323Sed/* set the boot-device configuration variable */ 101193323Sedextern int devfs_bootdev_set_list(const char *, const uint_t); 102193323Sed 103193323Sed/* is the boot-device variable modifiable on this platform? */ 104193323Sedextern int devfs_bootdev_modifiable(void); 105193323Sed 106193323Sed/* 107193323Sed * retrieve the boot-device config variable and corresponding logical 108193323Sed * device names 109193323Sed */ 110193323Sedextern int devfs_bootdev_get_list(const char *, struct boot_dev ***); 111193323Sed/* 112193323Sed * free a list of bootdev structs 113193323Sed */ 114193323Sedextern void devfs_bootdev_free_list(struct boot_dev **); 115193323Sed/* 116193323Sed * given a logical device name, return a list of equivalent 117193323Sed * prom names (aliases and device paths) 118193323Sed */ 119193323Sedextern int devfs_get_prom_names(const char *, uint_t, char ***); 120193323Sed/* 121193323Sed * like devfs_get_prom_names(), but deals with 1 to many mappings 122193323Sed * introduced by mpxio devices 123193323Sed */ 124193323Sedextern int devfs_get_all_prom_names(const char *, uint_t, 125193323Sed struct devfs_prom_path **); 126193323Sed/* 127193323Sed * free a list of devfs_prom_path structures 128193323Sed */ 129193323Sedextern void devfs_free_all_prom_names(struct devfs_prom_path *); 130193323Sed 131193323Sed/* 132193323Sed * map a device name from install OS environment to target OS environment or 133193323Sed * vice-versa. 134193323Sed */ 135193323Sedextern int devfs_target2install(const char *, const char *, char *, size_t); 136193323Sedextern int devfs_install2target(const char *, const char *, char *, size_t); 137193323Sed 138193323Sed/* 139193323Sed * Minor perm parsing library support for devfsadm, add_drv etc. 140193323Sed */ 141193323Sed#define MINOR_PERM_FILE "/etc/minor_perm" 142193323Sed#define MAX_MINOR_PERM_LINE 256 143193323Sed#define DEFAULT_DEV_USER "root" 144193323Sed#define DEFAULT_DEV_GROUP "sys" 145193323Sed 146193323Sed/* 147193323Sed * Possible errors the callers of devfs_read_minor_perm() need 148193323Sed * to be prepared to deal with via callback. 149193323Sed */ 150193323Sedtypedef enum { 151193323Sed MP_FOPEN_ERR, 152193323Sed MP_FCLOSE_ERR, 153193323Sed MP_IGNORING_LINE_ERR, 154193323Sed MP_ALLOC_ERR, 155193323Sed MP_NVLIST_ERR, 156193323Sed MP_CANT_FIND_USER_ERR, 157193323Sed MP_CANT_FIND_GROUP_ERR 158193323Sed} minorperm_err_t; 159193323Sed 160193323Sed 161193323Sed/* 162193323Sed * Create/free mperm list of minor perm entries 163193323Sed */ 164193323Sedextern struct mperm *devfs_read_minor_perm(void (*)(minorperm_err_t, int)); 165198090Srdivackyextern void devfs_free_minor_perm(struct mperm *); 166198090Srdivacky 167198090Srdivacky/* 168198090Srdivacky * Load all minor perm entries, and add/remove minor perm entry 169193323Sed */ 170193323Sedextern int devfs_load_minor_perm(struct mperm *, 171193323Sed void (*)(minorperm_err_t, int)); 172193323Sedextern int devfs_add_minor_perm(char *, void (*)(minorperm_err_t, int)); 173193323Sedextern int devfs_rm_minor_perm(char *, void (*)(minorperm_err_t, int)); 174193323Sed 175193323Sed/* devfsadm dca_flags values: some are used by libdevinfo devlink_create() */ 176193323Sed#define DCA_CREATE_LINK 0x000000001 177193323Sed#define DCA_FREE_LIST 0x000000002 178193323Sed#define DCA_LOAD_DRV 0x000000004 179193323Sed#define DCA_CHECK_TYPE 0x000000010 180193323Sed/* UNUSED was DCA_NOTIFY_RCM 0x000000020 (can be recycled) */ 181193323Sed#define DCA_FLUSH_PATHINST 0x000000040 182193323Sed#define DCA_HOT_PLUG 0x000000080 183193323Sed#define DCA_DEVLINK_SYNC 0x000000100 184193323Sed#define DCA_DEVLINK_CACHE 0x000000200 185193323Sed 186193323Sed#ifdef __cplusplus 187193323Sed} 188193323Sed#endif 189193323Sed 190193323Sed#endif /* _DEVICE_INFO_H */ 191193323Sed