17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5ff2aee48Scth * Common Development and Distribution License (the "License"). 6ff2aee48Scth * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*7e3e5701SJan Parcel * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 277c478bd9Sstevel@tonic-gate * WARNING: 287c478bd9Sstevel@tonic-gate * The interfaces defined in this header file are for Sun private use only. 297c478bd9Sstevel@tonic-gate * The contents of this file are subject to change without notice in 307c478bd9Sstevel@tonic-gate * future releases. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifndef _DEVICE_INFO_H 347c478bd9Sstevel@tonic-gate #define _DEVICE_INFO_H 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 377c478bd9Sstevel@tonic-gate extern "C" { 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* error return values */ 417c478bd9Sstevel@tonic-gate #define DEVFS_ERR -1 /* operation not successful */ 427c478bd9Sstevel@tonic-gate #define DEVFS_INVAL -2 /* invalid argument */ 437c478bd9Sstevel@tonic-gate #define DEVFS_NOMEM -3 /* out of memory */ 447c478bd9Sstevel@tonic-gate #define DEVFS_PERM -4 /* permission denied - not root */ 457c478bd9Sstevel@tonic-gate #define DEVFS_NOTSUP -5 /* operation not supported */ 467c478bd9Sstevel@tonic-gate #define DEVFS_LIMIT -6 /* exceeded maximum size of property value */ 477c478bd9Sstevel@tonic-gate #define DEVFS_NOTFOUND -7 /* request not found */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * for devfs_set_boot_dev() 517c478bd9Sstevel@tonic-gate * default behavior is to translate the input logical device name 527c478bd9Sstevel@tonic-gate * to most compact prom name(i.e. a prom alias, if one exists) 537c478bd9Sstevel@tonic-gate * as possible. And to prepend the new entry to the existing 547c478bd9Sstevel@tonic-gate * list. 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* perform no translation on the input device path */ 587c478bd9Sstevel@tonic-gate #define BOOTDEV_LITERAL 0x1 597c478bd9Sstevel@tonic-gate /* convert the input device path only a prom device path; not an alias */ 607c478bd9Sstevel@tonic-gate #define BOOTDEV_PROMDEV 0x2 617c478bd9Sstevel@tonic-gate /* overwrite the existing entry in boot-device - default is to prepend */ 627c478bd9Sstevel@tonic-gate #define BOOTDEV_OVERWRITE 0x4 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * for devfs_get_prom_names() 667c478bd9Sstevel@tonic-gate * returns a list of prom names for a given logical device name. 677c478bd9Sstevel@tonic-gate * the list is sorted first in order of exact aliases, inexact alias 687c478bd9Sstevel@tonic-gate * matches (where an option override was needed), and finally the 697c478bd9Sstevel@tonic-gate * equivalent prom device path. Each sublist is sorted in collating 707c478bd9Sstevel@tonic-gate * order. 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate #define BOOTDEV_NO_PROM_PATH 0x1 737c478bd9Sstevel@tonic-gate #define BOOTDEV_NO_INEXACT_ALIAS 0x2 747c478bd9Sstevel@tonic-gate #define BOOTDEV_NO_EXACT_ALIAS 0x4 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate /* for devfs_get_boot_dev() */ 777c478bd9Sstevel@tonic-gate struct boot_dev { 787c478bd9Sstevel@tonic-gate char *bootdev_element; /* an entry from the boot-device variable */ 797c478bd9Sstevel@tonic-gate char **bootdev_trans; /* 0 or more logical dev translations */ 807c478bd9Sstevel@tonic-gate }; 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* for devfs_get_all_prom_names() */ 837c478bd9Sstevel@tonic-gate struct devfs_prom_path { 847c478bd9Sstevel@tonic-gate char *obp_path; 857c478bd9Sstevel@tonic-gate char **alias_list; 867c478bd9Sstevel@tonic-gate struct devfs_prom_path *next; 877c478bd9Sstevel@tonic-gate }; 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* prototypes */ 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* return the driver for a given device path */ 927c478bd9Sstevel@tonic-gate extern int devfs_path_to_drv(char *devfs_path, char *drv_buf); 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* convert a logical or physical device name to the equivalent prom path */ 957c478bd9Sstevel@tonic-gate extern int devfs_dev_to_prom_name(char *, char *); 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* return the driver name after resolving any aliases */ 987c478bd9Sstevel@tonic-gate extern char *devfs_resolve_aliases(char *drv); 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* set the boot-device configuration variable */ 1017c478bd9Sstevel@tonic-gate extern int devfs_bootdev_set_list(const char *, const uint_t); 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* is the boot-device variable modifiable on this platform? */ 1047c478bd9Sstevel@tonic-gate extern int devfs_bootdev_modifiable(void); 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * retrieve the boot-device config variable and corresponding logical 1087c478bd9Sstevel@tonic-gate * device names 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate extern int devfs_bootdev_get_list(const char *, struct boot_dev ***); 1117c478bd9Sstevel@tonic-gate /* 1127c478bd9Sstevel@tonic-gate * free a list of bootdev structs 1137c478bd9Sstevel@tonic-gate */ 1147c478bd9Sstevel@tonic-gate extern void devfs_bootdev_free_list(struct boot_dev **); 1157c478bd9Sstevel@tonic-gate /* 1167c478bd9Sstevel@tonic-gate * given a logical device name, return a list of equivalent 1177c478bd9Sstevel@tonic-gate * prom names (aliases and device paths) 1187c478bd9Sstevel@tonic-gate */ 1197c478bd9Sstevel@tonic-gate extern int devfs_get_prom_names(const char *, uint_t, char ***); 1207c478bd9Sstevel@tonic-gate /* 1217c478bd9Sstevel@tonic-gate * like devfs_get_prom_names(), but deals with 1 to many mappings 1227c478bd9Sstevel@tonic-gate * introduced by mpxio devices 1237c478bd9Sstevel@tonic-gate */ 1247c478bd9Sstevel@tonic-gate extern int devfs_get_all_prom_names(const char *, uint_t, 1257c478bd9Sstevel@tonic-gate struct devfs_prom_path **); 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * free a list of devfs_prom_path structures 1287c478bd9Sstevel@tonic-gate */ 1297c478bd9Sstevel@tonic-gate extern void devfs_free_all_prom_names(struct devfs_prom_path *); 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* 132*7e3e5701SJan Parcel * Interpret a /dev link to its /devices path (does not require path to 133*7e3e5701SJan Parcel * still exist, as long as the links exist) 134*7e3e5701SJan Parcel */ 135*7e3e5701SJan Parcel extern int devfs_resolve_link(char *, char **); 136*7e3e5701SJan Parcel 137*7e3e5701SJan Parcel /* 1387c478bd9Sstevel@tonic-gate * map a device name from install OS environment to target OS environment or 1397c478bd9Sstevel@tonic-gate * vice-versa. 1407c478bd9Sstevel@tonic-gate */ 1417c478bd9Sstevel@tonic-gate extern int devfs_target2install(const char *, const char *, char *, size_t); 1427c478bd9Sstevel@tonic-gate extern int devfs_install2target(const char *, const char *, char *, size_t); 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate /* 1457c478bd9Sstevel@tonic-gate * Minor perm parsing library support for devfsadm, add_drv etc. 1467c478bd9Sstevel@tonic-gate */ 1477c478bd9Sstevel@tonic-gate #define MINOR_PERM_FILE "/etc/minor_perm" 1487c478bd9Sstevel@tonic-gate #define MAX_MINOR_PERM_LINE 256 1497c478bd9Sstevel@tonic-gate #define DEFAULT_DEV_USER "root" 1507c478bd9Sstevel@tonic-gate #define DEFAULT_DEV_GROUP "sys" 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * Possible errors the callers of devfs_read_minor_perm() need 1547c478bd9Sstevel@tonic-gate * to be prepared to deal with via callback. 1557c478bd9Sstevel@tonic-gate */ 1567c478bd9Sstevel@tonic-gate typedef enum { 1577c478bd9Sstevel@tonic-gate MP_FOPEN_ERR, 1587c478bd9Sstevel@tonic-gate MP_FCLOSE_ERR, 1597c478bd9Sstevel@tonic-gate MP_IGNORING_LINE_ERR, 1607c478bd9Sstevel@tonic-gate MP_ALLOC_ERR, 1617c478bd9Sstevel@tonic-gate MP_NVLIST_ERR, 1627c478bd9Sstevel@tonic-gate MP_CANT_FIND_USER_ERR, 1637c478bd9Sstevel@tonic-gate MP_CANT_FIND_GROUP_ERR 1647c478bd9Sstevel@tonic-gate } minorperm_err_t; 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate /* 1687c478bd9Sstevel@tonic-gate * Create/free mperm list of minor perm entries 1697c478bd9Sstevel@tonic-gate */ 1707c478bd9Sstevel@tonic-gate extern struct mperm *devfs_read_minor_perm(void (*)(minorperm_err_t, int)); 1717c478bd9Sstevel@tonic-gate extern void devfs_free_minor_perm(struct mperm *); 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate /* 1747c478bd9Sstevel@tonic-gate * Load all minor perm entries, and add/remove minor perm entry 1757c478bd9Sstevel@tonic-gate */ 1767c478bd9Sstevel@tonic-gate extern int devfs_load_minor_perm(struct mperm *, 1777c478bd9Sstevel@tonic-gate void (*)(minorperm_err_t, int)); 1787c478bd9Sstevel@tonic-gate extern int devfs_add_minor_perm(char *, void (*)(minorperm_err_t, int)); 1797c478bd9Sstevel@tonic-gate extern int devfs_rm_minor_perm(char *, void (*)(minorperm_err_t, int)); 1807c478bd9Sstevel@tonic-gate 181ff2aee48Scth /* devfsadm dca_flags values: some are used by libdevinfo devlink_create() */ 182ff2aee48Scth #define DCA_CREATE_LINK 0x000000001 183ff2aee48Scth #define DCA_FREE_LIST 0x000000002 184ff2aee48Scth #define DCA_LOAD_DRV 0x000000004 185ff2aee48Scth #define DCA_CHECK_TYPE 0x000000010 1860dc974a9SCathy Zhou /* UNUSED was DCA_NOTIFY_RCM 0x000000020 (can be recycled) */ 187ff2aee48Scth #define DCA_FLUSH_PATHINST 0x000000040 188ff2aee48Scth #define DCA_HOT_PLUG 0x000000080 189ff2aee48Scth #define DCA_DEVLINK_SYNC 0x000000100 190ff2aee48Scth #define DCA_DEVLINK_CACHE 0x000000200 191ff2aee48Scth 1927c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1937c478bd9Sstevel@tonic-gate } 1947c478bd9Sstevel@tonic-gate #endif 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate #endif /* _DEVICE_INFO_H */ 197