4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
28 * The interfaces defined in this header file are for Sun private use only.
29 * The contents of this file are subject to change without notice in
33 #ifndef _DEVICE_INFO_H
34 #define _DEVICE_INFO_H
40 /* error return values */
41 #define DEVFS_ERR -1 /* operation not successful */
42 #define DEVFS_INVAL -2 /* invalid argument */
43 #define DEVFS_NOMEM -3 /* out of memory */
44 #define DEVFS_PERM -4 /* permission denied - not root */
45 #define DEVFS_NOTSUP -5 /* operation not supported */
46 #define DEVFS_LIMIT -6 /* exceeded maximum size of property value */
47 #define DEVFS_NOTFOUND -7 /* request not found */
50 * for devfs_set_boot_dev()
51 * default behavior is to translate the input logical device name
52 * to most compact prom name(i.e. a prom alias, if one exists)
53 * as possible. And to prepend the new entry to the existing
57 /* perform no translation on the input device path */
58 #define BOOTDEV_LITERAL 0x1
59 /* convert the input device path only a prom device path; not an alias */
60 #define BOOTDEV_PROMDEV 0x2
61 /* overwrite the existing entry in boot-device - default is to prepend */
62 #define BOOTDEV_OVERWRITE 0x4
65 * for devfs_get_prom_names()
66 * returns a list of prom names for a given logical device name.
67 * the list is sorted first in order of exact aliases, inexact alias
68 * matches (where an option override was needed), and finally the
69 * equivalent prom device path. Each sublist is sorted in collating
72 #define BOOTDEV_NO_PROM_PATH 0x1
73 #define BOOTDEV_NO_INEXACT_ALIAS 0x2
74 #define BOOTDEV_NO_EXACT_ALIAS 0x4
76 /* for devfs_get_boot_dev() */
78 char *bootdev_element
; /* an entry from the boot-device variable */
79 char **bootdev_trans
; /* 0 or more logical dev translations */
82 /* for devfs_get_all_prom_names() */
83 struct devfs_prom_path
{
86 struct devfs_prom_path
*next
;
91 /* return the driver for a given device path */
92 extern int devfs_path_to_drv(char *devfs_path
, char *drv_buf
);
94 /* convert a logical or physical device name to the equivalent prom path */
95 extern int devfs_dev_to_prom_name(char *, char *);
97 /* return the driver name after resolving any aliases */
98 extern char *devfs_resolve_aliases(char *drv
);
100 /* set the boot-device configuration variable */
101 extern int devfs_bootdev_set_list(const char *, const uint_t
);
103 /* is the boot-device variable modifiable on this platform? */
104 extern int devfs_bootdev_modifiable(void);
107 * retrieve the boot-device config variable and corresponding logical
110 extern int devfs_bootdev_get_list(const char *, struct boot_dev
***);
112 * free a list of bootdev structs
114 extern void devfs_bootdev_free_list(struct boot_dev
**);
116 * given a logical device name, return a list of equivalent
117 * prom names (aliases and device paths)
119 extern int devfs_get_prom_names(const char *, uint_t
, char ***);
121 * like devfs_get_prom_names(), but deals with 1 to many mappings
122 * introduced by mpxio devices
124 extern int devfs_get_all_prom_names(const char *, uint_t
,
125 struct devfs_prom_path
**);
127 * free a list of devfs_prom_path structures
129 extern void devfs_free_all_prom_names(struct devfs_prom_path
*);
132 * Interpret a /dev link to its /devices path (does not require path to
133 * still exist, as long as the links exist)
135 extern int devfs_resolve_link(char *, char **);
138 * map a device name from install OS environment to target OS environment or
141 extern int devfs_target2install(const char *, const char *, char *, size_t);
142 extern int devfs_install2target(const char *, const char *, char *, size_t);
145 * Minor perm parsing library support for devfsadm, add_drv etc.
147 #define MINOR_PERM_FILE "/etc/minor_perm"
148 #define MAX_MINOR_PERM_LINE 256
149 #define DEFAULT_DEV_USER "root"
150 #define DEFAULT_DEV_GROUP "sys"
153 * Possible errors the callers of devfs_read_minor_perm() need
154 * to be prepared to deal with via callback.
159 MP_IGNORING_LINE_ERR
,
162 MP_CANT_FIND_USER_ERR
,
163 MP_CANT_FIND_GROUP_ERR
168 * Create/free mperm list of minor perm entries
170 extern struct mperm
*devfs_read_minor_perm(void (*)(minorperm_err_t
, int));
171 extern void devfs_free_minor_perm(struct mperm
*);
174 * Load all minor perm entries, and add/remove minor perm entry
176 extern int devfs_load_minor_perm(struct mperm
*,
177 void (*)(minorperm_err_t
, int));
178 extern int devfs_add_minor_perm(char *, void (*)(minorperm_err_t
, int));
179 extern int devfs_rm_minor_perm(char *, void (*)(minorperm_err_t
, int));
181 /* devfsadm dca_flags values: some are used by libdevinfo devlink_create() */
182 #define DCA_CREATE_LINK 0x000000001
183 #define DCA_FREE_LIST 0x000000002
184 #define DCA_LOAD_DRV 0x000000004
185 #define DCA_CHECK_TYPE 0x000000010
186 /* UNUSED was DCA_NOTIFY_RCM 0x000000020 (can be recycled) */
187 #define DCA_FLUSH_PATHINST 0x000000040
188 #define DCA_HOT_PLUG 0x000000080
189 #define DCA_DEVLINK_SYNC 0x000000100
190 #define DCA_DEVLINK_CACHE 0x000000200
196 #endif /* _DEVICE_INFO_H */