2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A/*
2N/A * WARNING:
2N/A * The interfaces defined in this header file are for Sun private use only.
2N/A * The contents of this file are subject to change without notice in
2N/A * future releases.
2N/A */
2N/A
2N/A#ifndef _DEVICE_INFO_H
2N/A#define _DEVICE_INFO_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/* error return values */
2N/A#define DEVFS_ERR -1 /* operation not successful */
2N/A#define DEVFS_INVAL -2 /* invalid argument */
2N/A#define DEVFS_NOMEM -3 /* out of memory */
2N/A#define DEVFS_PERM -4 /* permission denied - not root */
2N/A#define DEVFS_NOTSUP -5 /* operation not supported */
2N/A#define DEVFS_LIMIT -6 /* exceeded maximum size of property value */
2N/A#define DEVFS_NOTFOUND -7 /* request not found */
2N/A
2N/A/*
2N/A * for devfs_set_boot_dev()
2N/A * default behavior is to translate the input logical device name
2N/A * to most compact prom name(i.e. a prom alias, if one exists)
2N/A * as possible. And to prepend the new entry to the existing
2N/A * list.
2N/A */
2N/A
2N/A/* perform no translation on the input device path */
2N/A#define BOOTDEV_LITERAL 0x1
2N/A/* convert the input device path only a prom device path; not an alias */
2N/A#define BOOTDEV_PROMDEV 0x2
2N/A/* overwrite the existing entry in boot-device - default is to prepend */
2N/A#define BOOTDEV_OVERWRITE 0x4
2N/A
2N/A/*
2N/A * for devfs_get_prom_names()
2N/A * returns a list of prom names for a given logical device name.
2N/A * the list is sorted first in order of exact aliases, inexact alias
2N/A * matches (where an option override was needed), and finally the
2N/A * equivalent prom device path. Each sublist is sorted in collating
2N/A * order.
2N/A */
2N/A#define BOOTDEV_NO_PROM_PATH 0x1
2N/A#define BOOTDEV_NO_INEXACT_ALIAS 0x2
2N/A#define BOOTDEV_NO_EXACT_ALIAS 0x4
2N/A
2N/A/* for devfs_get_boot_dev() */
2N/Astruct boot_dev {
2N/A char *bootdev_element; /* an entry from the boot-device variable */
2N/A char **bootdev_trans; /* 0 or more logical dev translations */
2N/A};
2N/A
2N/A/* for devfs_get_all_prom_names() */
2N/Astruct devfs_prom_path {
2N/A char *obp_path;
2N/A char **alias_list;
2N/A struct devfs_prom_path *next;
2N/A};
2N/A
2N/A/* prototypes */
2N/A
2N/A/* return the driver for a given device path */
2N/Aextern int devfs_path_to_drv(char *devfs_path, char *drv_buf);
2N/A
2N/A/* convert a logical or physical device name to the equivalent prom path */
2N/Aextern int devfs_dev_to_prom_name(char *, char *);
2N/A
2N/A/* return the driver name after resolving any aliases */
2N/Aextern char *devfs_resolve_aliases(char *drv);
2N/A
2N/A/* set the boot-device configuration variable */
2N/Aextern int devfs_bootdev_set_list(const char *, const uint_t);
2N/A
2N/A/* is the boot-device variable modifiable on this platform? */
2N/Aextern int devfs_bootdev_modifiable(void);
2N/A
2N/A/*
2N/A * retrieve the boot-device config variable and corresponding logical
2N/A * device names
2N/A */
2N/Aextern int devfs_bootdev_get_list(const char *, struct boot_dev ***);
2N/A/*
2N/A * free a list of bootdev structs
2N/A */
2N/Aextern void devfs_bootdev_free_list(struct boot_dev **);
2N/A/*
2N/A * given a logical device name, return a list of equivalent
2N/A * prom names (aliases and device paths)
2N/A */
2N/Aextern int devfs_get_prom_names(const char *, uint_t, char ***);
2N/A/*
2N/A * like devfs_get_prom_names(), but deals with 1 to many mappings
2N/A * introduced by mpxio devices
2N/A */
2N/Aextern int devfs_get_all_prom_names(const char *, uint_t,
2N/A struct devfs_prom_path **);
2N/A/*
2N/A * free a list of devfs_prom_path structures
2N/A */
2N/Aextern void devfs_free_all_prom_names(struct devfs_prom_path *);
2N/A
2N/A/*
2N/A * Interpret a /dev link to its /devices path (does not require path to
2N/A * still exist, as long as the links exist)
2N/A */
2N/Aextern int devfs_resolve_link(char *, char **);
2N/A
2N/A/*
2N/A * map a device name from install OS environment to target OS environment or
2N/A * vice-versa.
2N/A */
2N/Aextern int devfs_target2install(const char *, const char *, char *, size_t);
2N/Aextern int devfs_install2target(const char *, const char *, char *, size_t);
2N/A
2N/A/*
2N/A * Minor perm parsing library support for devfsadm, add_drv etc.
2N/A */
2N/A#define MINOR_PERM_FILE "/etc/minor_perm"
2N/A#define MAX_MINOR_PERM_LINE 256
2N/A#define DEFAULT_DEV_USER "root"
2N/A#define DEFAULT_DEV_GROUP "sys"
2N/A
2N/A/*
2N/A * Possible errors the callers of devfs_read_minor_perm() need
2N/A * to be prepared to deal with via callback.
2N/A */
2N/Atypedef enum {
2N/A MP_FOPEN_ERR,
2N/A MP_FCLOSE_ERR,
2N/A MP_IGNORING_LINE_ERR,
2N/A MP_ALLOC_ERR,
2N/A MP_NVLIST_ERR,
2N/A MP_CANT_FIND_USER_ERR,
2N/A MP_CANT_FIND_GROUP_ERR
2N/A} minorperm_err_t;
2N/A
2N/A
2N/A/*
2N/A * Create/free mperm list of minor perm entries
2N/A */
2N/Aextern struct mperm *devfs_read_minor_perm(void (*)(minorperm_err_t, int));
2N/Aextern void devfs_free_minor_perm(struct mperm *);
2N/A
2N/A/*
2N/A * Load all minor perm entries, and add/remove minor perm entry
2N/A */
2N/Aextern int devfs_load_minor_perm(struct mperm *,
2N/A void (*)(minorperm_err_t, int));
2N/Aextern int devfs_add_minor_perm(char *, void (*)(minorperm_err_t, int));
2N/Aextern int devfs_rm_minor_perm(char *, void (*)(minorperm_err_t, int));
2N/A
2N/A/* devfsadm dca_flags values: some are used by libdevinfo devlink_create() */
2N/A#define DCA_CREATE_LINK 0x000000001
2N/A#define DCA_FREE_LIST 0x000000002
2N/A#define DCA_LOAD_DRV 0x000000004
2N/A#define DCA_CHECK_TYPE 0x000000010
2N/A/* UNUSED was DCA_NOTIFY_RCM 0x000000020 (can be recycled) */
2N/A#define DCA_FLUSH_PATHINST 0x000000040
2N/A#define DCA_HOT_PLUG 0x000000080
2N/A#define DCA_DEVLINK_SYNC 0x000000100
2N/A#define DCA_DEVLINK_CACHE 0x000000200
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _DEVICE_INFO_H */