10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*2587Spjha * Common Development and Distribution License (the "License"). 6*2587Spjha * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate * 21*2587Spjha * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 220Sstevel@tonic-gate * Use is subject to license terms. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _DEVFSADM_IMPL_H 260Sstevel@tonic-gate #define _DEVFSADM_IMPL_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifdef __cplusplus 310Sstevel@tonic-gate extern "C" { 320Sstevel@tonic-gate #endif 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <dlfcn.h> 350Sstevel@tonic-gate #include <stdarg.h> 360Sstevel@tonic-gate #include <fcntl.h> 370Sstevel@tonic-gate #include <sys/file.h> 380Sstevel@tonic-gate #include <locale.h> 390Sstevel@tonic-gate #include <libintl.h> 400Sstevel@tonic-gate #include <ctype.h> 410Sstevel@tonic-gate #include <signal.h> 420Sstevel@tonic-gate #include <deflt.h> 430Sstevel@tonic-gate #include <ftw.h> 440Sstevel@tonic-gate #include <sys/instance.h> 450Sstevel@tonic-gate #include <sys/types.h> 460Sstevel@tonic-gate #include <dirent.h> 470Sstevel@tonic-gate #include <pwd.h> 480Sstevel@tonic-gate #include <grp.h> 490Sstevel@tonic-gate #include <stdio.h> 500Sstevel@tonic-gate #include <stdlib.h> 510Sstevel@tonic-gate #include <sys/mkdev.h> 520Sstevel@tonic-gate #include <sys/stat.h> 530Sstevel@tonic-gate #include <fcntl.h> 540Sstevel@tonic-gate #include <errno.h> 550Sstevel@tonic-gate #include <unistd.h> 560Sstevel@tonic-gate #include <sys/stat.h> 570Sstevel@tonic-gate #include <sys/int_types.h> 580Sstevel@tonic-gate #include <limits.h> 590Sstevel@tonic-gate #include <strings.h> 600Sstevel@tonic-gate #include <devfsadm.h> 610Sstevel@tonic-gate #include <libdevinfo.h> 620Sstevel@tonic-gate #include <sys/devinfo_impl.h> 630Sstevel@tonic-gate #include <sys/modctl.h> 640Sstevel@tonic-gate #include <libgen.h> 650Sstevel@tonic-gate #include <sys/hwconf.h> 660Sstevel@tonic-gate #include <sys/sunddi.h> 670Sstevel@tonic-gate #include <door.h> 680Sstevel@tonic-gate #include <syslog.h> 690Sstevel@tonic-gate #include <libsysevent.h> 700Sstevel@tonic-gate #include <thread.h> 710Sstevel@tonic-gate #include <message.h> 720Sstevel@tonic-gate #include <sys/cladm.h> 730Sstevel@tonic-gate #include <librcm.h> 740Sstevel@tonic-gate #include <sys/sysevent/eventdefs.h> 750Sstevel@tonic-gate #include <sys/sysevent/dev.h> 760Sstevel@tonic-gate #include <libzonecfg.h> 770Sstevel@tonic-gate #include <device_info.h> 780Sstevel@tonic-gate 790Sstevel@tonic-gate #undef DEBUG 800Sstevel@tonic-gate #ifndef DEBUG 810Sstevel@tonic-gate #define NDEBUG 1 820Sstevel@tonic-gate #else 830Sstevel@tonic-gate #undef NDEBUG 840Sstevel@tonic-gate #endif 850Sstevel@tonic-gate 860Sstevel@tonic-gate #include <assert.h> 870Sstevel@tonic-gate 880Sstevel@tonic-gate 890Sstevel@tonic-gate #define DEV_LOCK_FILE ".devfsadm_dev.lock" 900Sstevel@tonic-gate #define DAEMON_LOCK_FILE ".devfsadm_daemon.lock" 910Sstevel@tonic-gate 920Sstevel@tonic-gate #define DEV "/dev" 930Sstevel@tonic-gate #define DEV_LEN 4 940Sstevel@tonic-gate #define DEVICES "/devices" 950Sstevel@tonic-gate #define DEVICES_LEN 8 960Sstevel@tonic-gate #define MODULE_DIRS "/usr/lib/devfsadm/linkmod" 970Sstevel@tonic-gate #define ALIASFILE "/etc/driver_aliases" 980Sstevel@tonic-gate #define NAME_TO_MAJOR "/etc/name_to_major" 990Sstevel@tonic-gate #define RECONFIG_BOOT "_INIT_RECONFIG" 1000Sstevel@tonic-gate #define PID_STR_LEN 10 1010Sstevel@tonic-gate #define EXTRA_PRIVS "/etc/security/extra_privs" 1020Sstevel@tonic-gate #define DEV_POLICY "/etc/security/device_policy" 1030Sstevel@tonic-gate #define LDEV_FILE "/etc/logindevperm" 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate #define DEVFSADM_DEFAULT_FILE "/etc/default/devfsadm" 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate #define MINOR_FINI_TIMEOUT_DEFAULT 2 1080Sstevel@tonic-gate #define FORCE_CALL_MINOR_FINI 10 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate #define SYNCH_DOOR_PERMS (S_IRUSR | S_IWUSR) 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate #define ZONE_DOOR_PERMS (S_IRUSR | S_IWUSR) 1140Sstevel@tonic-gate #define ZONE_REG_DOOR ".zone_reg_door" 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate enum zreg_op { 1170Sstevel@tonic-gate ZONE_REG = 1, 1180Sstevel@tonic-gate ZONE_UNREG = 2 1190Sstevel@tonic-gate }; 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate enum zreg_err { 1220Sstevel@tonic-gate ZONE_SUCCESS = 0, 1230Sstevel@tonic-gate ZONE_ERR_NOZONE = 1, 1240Sstevel@tonic-gate ZONE_ERR_DOOR = 2, 1250Sstevel@tonic-gate ZONE_ERR_REPOSITORY = 3, 1260Sstevel@tonic-gate ZONE_ERR_NOLIB = 4 1270Sstevel@tonic-gate }; 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate struct zreg { 1300Sstevel@tonic-gate char zreg_zonename[ZONENAME_MAX]; 1310Sstevel@tonic-gate enum zreg_op zreg_op; 1320Sstevel@tonic-gate enum zreg_err zreg_error; 1330Sstevel@tonic-gate int zreg_errno; 1340Sstevel@tonic-gate }; 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate #define DRVCONFIG "drvconfig" 1370Sstevel@tonic-gate #define DEVFSADM "devfsadm" 1380Sstevel@tonic-gate #define DEVFSADMD "devfsadmd" 1390Sstevel@tonic-gate #define DEVLINKS "devlinks" 1400Sstevel@tonic-gate #define TAPES "tapes" 1410Sstevel@tonic-gate #define AUDLINKS "audlinks" 1420Sstevel@tonic-gate #define PORTS "ports" 1430Sstevel@tonic-gate #define DISKS "disks" 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate #define MAX_IDLE_DELAY 5 1460Sstevel@tonic-gate #define MAX_DELAY 30 1470Sstevel@tonic-gate #define NAME 0x01 1480Sstevel@tonic-gate #define ADDR 0x03 1490Sstevel@tonic-gate #define MINOR 0x04 1500Sstevel@tonic-gate #define COUNTER 0x05 1510Sstevel@tonic-gate #define CONSTANT 0x06 1520Sstevel@tonic-gate #define TYPE 0x07 1530Sstevel@tonic-gate #define TYPE_S "type" 1540Sstevel@tonic-gate #define ADDR_S "addr" 1550Sstevel@tonic-gate #define ADDR_S_LEN 4 1560Sstevel@tonic-gate #define MINOR_S "minor" 1570Sstevel@tonic-gate #define MINOR_S_LEN 5 1580Sstevel@tonic-gate #define NAME_S "name" 1590Sstevel@tonic-gate #define TAB '\t' 1600Sstevel@tonic-gate #define NEWLINE '\n' 1610Sstevel@tonic-gate #define MAX_DEVLINK_LINE 4028 1620Sstevel@tonic-gate #define INTEGER 0 1630Sstevel@tonic-gate #define LETTER 1 1640Sstevel@tonic-gate #define MAX_PERM_LINE 256 1650Sstevel@tonic-gate #define MAX_LDEV_LINE 256 1660Sstevel@tonic-gate #define LDEV_DELIMS " \t\n" 1670Sstevel@tonic-gate #define LDEV_DRVLIST_DELIMS "=" 1680Sstevel@tonic-gate #define LDEV_DRV_DELIMS ", \t\n" 1690Sstevel@tonic-gate #define LDEV_DEV_DELIM ":" 1700Sstevel@tonic-gate #define LDEV_DRVLIST_NAME "driver" 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate #define TYPE_LINK 0x00 1730Sstevel@tonic-gate #define TYPE_DEVICES 0x01 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate #define CREATE_LINK 0x01 1760Sstevel@tonic-gate #define READ_LINK 0x02 1770Sstevel@tonic-gate #define CREATE_NODE 0x01 1780Sstevel@tonic-gate #define READ_NODE 0x02 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate #define DCA_CREATE_LINK 0x01 1810Sstevel@tonic-gate #define DCA_FREE_LIST 0x02 1820Sstevel@tonic-gate #define DCA_LOAD_DRV 0x04 1830Sstevel@tonic-gate #define DCA_CHECK_TYPE 0x10 1840Sstevel@tonic-gate #define DCA_NOTIFY_RCM 0x20 1850Sstevel@tonic-gate #define DCA_FLUSH_PATHINST 0x40 1860Sstevel@tonic-gate #define DCA_HOT_PLUG 0x80 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate #define CACHE_STATE 0x0 1890Sstevel@tonic-gate #define SYNC_STATE 0x1 1900Sstevel@tonic-gate 1910Sstevel@tonic-gate #define MODULE_ACTIVE 0x01 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate #define MAX_SLEEP 120 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate #define DEVLINKTAB_FILE "/etc/devlink.tab" 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate #define MODULE_SUFFIX ".so" 1980Sstevel@tonic-gate #define MINOR_INIT "minor_init" 1990Sstevel@tonic-gate #define MINOR_FINI "minor_fini" 2000Sstevel@tonic-gate #define _DEVFSADM_CREATE_REG "_devfsadm_create_reg" 2010Sstevel@tonic-gate #define _DEVFSADM_REMOVE_REG "_devfsadm_remove_reg" 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate #define NUM_EV_STR 4 2040Sstevel@tonic-gate #define EV_TYPE 0 2050Sstevel@tonic-gate #define EV_CLASS 1 2060Sstevel@tonic-gate #define EV_PATH_NAME 2 2070Sstevel@tonic-gate #define EV_MINOR_NAME 3 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate /* add new debug level and meanings here */ 2100Sstevel@tonic-gate #define DEVLINK_MID "devfsadm:devlink" 2110Sstevel@tonic-gate #define MODLOAD_MID "devfsadm:modload" 2120Sstevel@tonic-gate #define INITFINI_MID "devfsadm:initfini" 2130Sstevel@tonic-gate #define EVENT_MID "devfsadm:event" 2140Sstevel@tonic-gate #define REMOVE_MID "devfsadm:remove" 2150Sstevel@tonic-gate #define LOCK_MID "devfsadm:lock" 2160Sstevel@tonic-gate #define PATH2INST_MID "devfsadm:path2inst" 2170Sstevel@tonic-gate #define CACHE_MID "devfsadm:cache" 2180Sstevel@tonic-gate #define BUILDCACHE_MID "devfsadm:buildcache" 2190Sstevel@tonic-gate #define RECURSEDEV_MID "devfsadm:recursedev" 2200Sstevel@tonic-gate #define INSTSYNC_MID "devfsadm:instsync" 2210Sstevel@tonic-gate #define FILES_MID "devfsadm:files" 2220Sstevel@tonic-gate #define ENUM_MID "devfsadm:enum" 2230Sstevel@tonic-gate #define LINKCACHE_MID "devfsadm:linkcache" 2240Sstevel@tonic-gate #define ADDREMCACHE_MID "devfsadm:addremcache" 2250Sstevel@tonic-gate #define MALLOC_MID "devfsadm:malloc" 2260Sstevel@tonic-gate #define ZONE_MID "devfsadm:zone" 2270Sstevel@tonic-gate #define ALL_MID "all" 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate #define DEVFSADM_DEBUG_ON (verbose == NULL) ? FALSE : TRUE 2300Sstevel@tonic-gate 2310Sstevel@tonic-gate typedef struct recurse_dev { 2320Sstevel@tonic-gate void (*fcn)(char *, void *); 2330Sstevel@tonic-gate void *data; 2340Sstevel@tonic-gate } recurse_dev_t; 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate typedef struct link { 2370Sstevel@tonic-gate char *devlink; /* without ".../dev/" prefix */ 2380Sstevel@tonic-gate char *contents; /* without "../devices" prefix */ 2390Sstevel@tonic-gate struct link *next; 2400Sstevel@tonic-gate } link_t; 2410Sstevel@tonic-gate 2420Sstevel@tonic-gate typedef struct linkhead { 2430Sstevel@tonic-gate regex_t dir_re_compiled; 2440Sstevel@tonic-gate char *dir_re; 2450Sstevel@tonic-gate link_t *link; 2460Sstevel@tonic-gate link_t *nextlink; 2470Sstevel@tonic-gate struct linkhead *nexthead; 2480Sstevel@tonic-gate } linkhead_t; 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate typedef struct link_list { 2510Sstevel@tonic-gate int type; 2520Sstevel@tonic-gate char *constant; 2530Sstevel@tonic-gate int arg; 2540Sstevel@tonic-gate struct link_list *next; 2550Sstevel@tonic-gate } link_list_t; 2560Sstevel@tonic-gate 2570Sstevel@tonic-gate typedef struct selector_list { 2580Sstevel@tonic-gate int key; 2590Sstevel@tonic-gate char *val; 2600Sstevel@tonic-gate int arg; 2610Sstevel@tonic-gate struct selector_list *next; 2620Sstevel@tonic-gate } selector_list_t; 2630Sstevel@tonic-gate 2640Sstevel@tonic-gate typedef struct devlinktab_list { 2650Sstevel@tonic-gate int line_number; 2660Sstevel@tonic-gate char *selector_pattern; 2670Sstevel@tonic-gate char *p_link_pattern; 2680Sstevel@tonic-gate char *s_link_pattern; 2690Sstevel@tonic-gate selector_list_t *selector; 2700Sstevel@tonic-gate link_list_t *p_link; 2710Sstevel@tonic-gate link_list_t *s_link; 2720Sstevel@tonic-gate struct devlinktab_list *next; 2730Sstevel@tonic-gate } devlinktab_list_t; 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate typedef struct module { 2760Sstevel@tonic-gate char *name; 2770Sstevel@tonic-gate void *dlhandle; 2780Sstevel@tonic-gate int (*minor_init)(); 2790Sstevel@tonic-gate int (*minor_fini)(); 2800Sstevel@tonic-gate int flags; 2810Sstevel@tonic-gate struct module *next; 2820Sstevel@tonic-gate } module_t; 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate typedef struct create_list { 2850Sstevel@tonic-gate devfsadm_create_t *create; 2860Sstevel@tonic-gate module_t *modptr; 2870Sstevel@tonic-gate regex_t node_type_comp; 2880Sstevel@tonic-gate regex_t drv_name_comp; 2890Sstevel@tonic-gate struct create_list *next; 2900Sstevel@tonic-gate } create_list_t; 2910Sstevel@tonic-gate 2920Sstevel@tonic-gate struct minor { 2930Sstevel@tonic-gate di_node_t node; 2940Sstevel@tonic-gate di_minor_t minor; 2950Sstevel@tonic-gate struct minor *next; 2960Sstevel@tonic-gate }; 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate struct mlist { 2990Sstevel@tonic-gate struct minor *head; 3000Sstevel@tonic-gate struct minor *tail; 3010Sstevel@tonic-gate }; 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate typedef struct remove_list { 3040Sstevel@tonic-gate devfsadm_remove_t *remove; 3050Sstevel@tonic-gate module_t *modptr; 3060Sstevel@tonic-gate struct remove_list *next; 3070Sstevel@tonic-gate } remove_list_t; 3080Sstevel@tonic-gate 3090Sstevel@tonic-gate typedef struct cleanup_data { 3100Sstevel@tonic-gate int flags; 3110Sstevel@tonic-gate char *phypath; 3120Sstevel@tonic-gate remove_list_t *rm; 3130Sstevel@tonic-gate } cleanup_data_t; 3140Sstevel@tonic-gate 3150Sstevel@tonic-gate typedef struct n2m { 3160Sstevel@tonic-gate major_t major; 3170Sstevel@tonic-gate char *driver; 3180Sstevel@tonic-gate struct n2m *next; 3190Sstevel@tonic-gate } n2m_t; 3200Sstevel@tonic-gate 3210Sstevel@tonic-gate /* structures for devfsadm_enumerate() */ 3220Sstevel@tonic-gate typedef struct numeral { 3230Sstevel@tonic-gate char *id; 3240Sstevel@tonic-gate char *full_path; 3250Sstevel@tonic-gate int rule_index; 3260Sstevel@tonic-gate char *cmp_str; 3270Sstevel@tonic-gate struct numeral *next; 3280Sstevel@tonic-gate } numeral_t; 3290Sstevel@tonic-gate 3300Sstevel@tonic-gate typedef struct numeral_set { 3310Sstevel@tonic-gate int re_count; 3320Sstevel@tonic-gate char **re; 3330Sstevel@tonic-gate numeral_t *headnumeral; 3340Sstevel@tonic-gate struct numeral_set *next; 3350Sstevel@tonic-gate } numeral_set_t; 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate typedef struct temp { 3380Sstevel@tonic-gate int integer; 3390Sstevel@tonic-gate struct temp *next; 3400Sstevel@tonic-gate } temp_t; 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate typedef struct driver_alias { 3430Sstevel@tonic-gate char *driver_name; 3440Sstevel@tonic-gate char *alias_name; 3450Sstevel@tonic-gate struct driver_alias *next; 3460Sstevel@tonic-gate } driver_alias_t; 3470Sstevel@tonic-gate 3480Sstevel@tonic-gate struct driver_list { 3490Sstevel@tonic-gate char driver_name[MAXNAMELEN]; 3500Sstevel@tonic-gate struct driver_list *next; 3510Sstevel@tonic-gate }; 3520Sstevel@tonic-gate 3530Sstevel@tonic-gate struct login_dev { 3540Sstevel@tonic-gate char *ldev_console; 3550Sstevel@tonic-gate int ldev_perms; 3560Sstevel@tonic-gate char *ldev_device; 3570Sstevel@tonic-gate regex_t ldev_device_regex; 3580Sstevel@tonic-gate struct driver_list *ldev_driver_list; 3590Sstevel@tonic-gate struct login_dev *ldev_next; 3600Sstevel@tonic-gate }; 3610Sstevel@tonic-gate 3620Sstevel@tonic-gate #define MAX_DEV_NAME_COUNT 100 3630Sstevel@tonic-gate struct devlink_cb_arg { 3640Sstevel@tonic-gate char *dev_names[MAX_DEV_NAME_COUNT]; 3650Sstevel@tonic-gate char *link_contents[MAX_DEV_NAME_COUNT]; 3660Sstevel@tonic-gate int count; 3670Sstevel@tonic-gate int rv; 3680Sstevel@tonic-gate }; 3690Sstevel@tonic-gate 3700Sstevel@tonic-gate struct dca_impl { 3710Sstevel@tonic-gate char *dci_root; 3720Sstevel@tonic-gate char *dci_minor; 3730Sstevel@tonic-gate char *dci_driver; 3740Sstevel@tonic-gate void *dci_arg; 3750Sstevel@tonic-gate int dci_error; 3760Sstevel@tonic-gate int dci_flags; 3770Sstevel@tonic-gate }; 3780Sstevel@tonic-gate 3790Sstevel@tonic-gate struct zone_devinfo { 3800Sstevel@tonic-gate struct zone_devinfo *zone_next; 3810Sstevel@tonic-gate char *zone_path; 3820Sstevel@tonic-gate char *zone_name; 3830Sstevel@tonic-gate zone_dochandle_t zone_dochdl; 3840Sstevel@tonic-gate }; 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate /* RCM related */ 3870Sstevel@tonic-gate struct rcm_eventq { 3880Sstevel@tonic-gate nvlist_t *nvl; 3890Sstevel@tonic-gate struct rcm_eventq *next; 3900Sstevel@tonic-gate }; 3910Sstevel@tonic-gate 3920Sstevel@tonic-gate static int devfsadm_enumerate_int_start(char *devfs_path, 3930Sstevel@tonic-gate int index, char **buf, devfsadm_enumerate_t rules[], 3940Sstevel@tonic-gate int nrules, char *start); 3950Sstevel@tonic-gate static void startup_cache_sync_thread(void); 3960Sstevel@tonic-gate static void set_root_devices_dev_dir(char *dir, int zone_mode); 3970Sstevel@tonic-gate static void pre_and_post_cleanup(int flags); 3980Sstevel@tonic-gate static void hot_cleanup(char *, char *, char *, char *, int); 3990Sstevel@tonic-gate static void devfsadm_exit(int status); 4000Sstevel@tonic-gate static void rm_link_from_cache(char *devlink); 4010Sstevel@tonic-gate static void rm_all_links_from_cache(); 4020Sstevel@tonic-gate static void add_link_to_cache(char *devlink, char *physpath); 4030Sstevel@tonic-gate static linkhead_t *get_cached_links(char *dir_re); 4040Sstevel@tonic-gate static void build_devlink_list(char *check_link, void *data); 4050Sstevel@tonic-gate static void instance_flush_thread(void); 406871Scasper static int s_rmdir(char *path); 4070Sstevel@tonic-gate static void rm_parent_dir_if_empty(char *path); 4080Sstevel@tonic-gate static void free_link_list(link_list_t *head); 4090Sstevel@tonic-gate static void free_selector_list(selector_list_t *head); 4100Sstevel@tonic-gate void devfsadm_err_print(char *message, ...); 4110Sstevel@tonic-gate void defvsadm_print(int level, char *message, ...); 4120Sstevel@tonic-gate static int call_minor_init(module_t *module); 4130Sstevel@tonic-gate static void load_module(char *module, char *cdir); 4140Sstevel@tonic-gate static void invalidate_enumerate_cache(void); 4150Sstevel@tonic-gate static pid_t enter_dev_lock(void); 4160Sstevel@tonic-gate static void exit_dev_lock(void); 4170Sstevel@tonic-gate static pid_t enter_daemon_lock(void); 4180Sstevel@tonic-gate static void exit_daemon_lock(void); 4190Sstevel@tonic-gate static int process_devlink_compat(di_minor_t minor, di_node_t node); 4200Sstevel@tonic-gate static int alias(char *, char *); 4210Sstevel@tonic-gate static int devfsadm_copy(void); 4220Sstevel@tonic-gate static void flush_path_to_inst(void); 4230Sstevel@tonic-gate static void detachfromtty(void); 4240Sstevel@tonic-gate static void minor_process(di_node_t node, di_minor_t minor, 4250Sstevel@tonic-gate struct mlist *dep); 4260Sstevel@tonic-gate static void read_minor_perm_file(void); 4270Sstevel@tonic-gate static void read_driver_aliases_file(void); 4280Sstevel@tonic-gate static void load_modules(void); 4290Sstevel@tonic-gate static void unload_modules(void); 4300Sstevel@tonic-gate static void *s_malloc(const size_t size); 4310Sstevel@tonic-gate static void *s_zalloc(const size_t size); 4320Sstevel@tonic-gate static void devfs_instance_mod(void); 4330Sstevel@tonic-gate static void add_minor_pathname(char *, char *, char *); 4340Sstevel@tonic-gate static int check_minor_type(di_node_t node, di_minor_t minor, void *arg); 4350Sstevel@tonic-gate static void cache_deferred_minor(struct mlist *dep, di_node_t node, 4360Sstevel@tonic-gate di_minor_t minor); 4370Sstevel@tonic-gate static int compare_field(char *full_name, char *field_item, int field); 4380Sstevel@tonic-gate static int component_cat(char *link, char *name, int field); 4390Sstevel@tonic-gate static void recurse_dev_re(char *current_dir, char *path_re, recurse_dev_t *rd); 4400Sstevel@tonic-gate static void matching_dev(char *devpath, void *data); 4410Sstevel@tonic-gate static int resolve_link(char *devpath, char **content_p, int *type_p, 4420Sstevel@tonic-gate char **devfs_path, int dangle); 4430Sstevel@tonic-gate static int clean_ok(devfsadm_remove_t *remove); 4440Sstevel@tonic-gate static int translate_major(dev_t old_dev, dev_t *new_dev); 4450Sstevel@tonic-gate static int get_major_no(char *driver, major_t *major); 4460Sstevel@tonic-gate static int load_n2m_table(char *filename); 4470Sstevel@tonic-gate static int get_stat_info(char *, struct stat *); 4480Sstevel@tonic-gate static char *new_id(numeral_t *, int, char *); 4490Sstevel@tonic-gate static int find_enum_id(devfsadm_enumerate_t rules[], int nrules, 4500Sstevel@tonic-gate char *devfs_path, int index, char *min, int type, char **buf, int multiple); 4510Sstevel@tonic-gate static void daemon_update(void); 4520Sstevel@tonic-gate static void usage(void); 4530Sstevel@tonic-gate static int getnexttoken(char *next, char **nextp, char **tokenpp, char *tchar); 4540Sstevel@tonic-gate static int class_ok(char *class); 4550Sstevel@tonic-gate static int create_link_common(char *devlink, char *contents, int *exists); 4560Sstevel@tonic-gate static char *dequote(char *src); 4570Sstevel@tonic-gate static void parse_args(int argc, char *argv[]); 4580Sstevel@tonic-gate static void process_devinfo_tree(void); 4590Sstevel@tonic-gate static void call_minor_fini_thread(void *arg); 4600Sstevel@tonic-gate static void *s_realloc(void *ptr, const size_t size); 4610Sstevel@tonic-gate static void read_devlinktab_file(void); 4620Sstevel@tonic-gate static selector_list_t *create_selector_list(char *selector); 4630Sstevel@tonic-gate static int parse_selector(char **selector, char **key, char **val); 4640Sstevel@tonic-gate int devfsadm_noupdate(void); 4650Sstevel@tonic-gate const char *devfsadm_root_path(void); 4660Sstevel@tonic-gate static link_list_t *create_link_list(char *link); 4670Sstevel@tonic-gate static void s_unlink(const char *file); 4680Sstevel@tonic-gate static void s_closedir(DIR *dirp); 4690Sstevel@tonic-gate static void s_mkdirp(const char *path, const mode_t mode); 4700Sstevel@tonic-gate static int is_minor_node(char *contents, char **mn_root); 4710Sstevel@tonic-gate static int construct_devlink(char *link, link_list_t *link_build, 4720Sstevel@tonic-gate char *contents, di_minor_t minor, 4730Sstevel@tonic-gate di_node_t node, char *pattern); 4740Sstevel@tonic-gate static int split_devlinktab_entry(char *entry, char **selector, char **p_link, 4750Sstevel@tonic-gate char **s_link); 4760Sstevel@tonic-gate static int devlink_matches(devlinktab_list_t *entry, di_minor_t minor, 4770Sstevel@tonic-gate di_node_t node); 4780Sstevel@tonic-gate static int build_links(devlinktab_list_t *entry, di_minor_t minor, 4790Sstevel@tonic-gate di_node_t node); 4800Sstevel@tonic-gate static numeral_set_t *get_enum_cache(devfsadm_enumerate_t rules[], 4810Sstevel@tonic-gate int nrules); 4820Sstevel@tonic-gate static void enumerate_recurse(char *current_dir, char *path_left, 4830Sstevel@tonic-gate numeral_set_t *setp, devfsadm_enumerate_t rules[], int index); 4840Sstevel@tonic-gate 4850Sstevel@tonic-gate static int match_path_component(char *file_re, char *file, char **id, 4860Sstevel@tonic-gate int subexp); 4870Sstevel@tonic-gate static void create_cached_numeral(char *path, numeral_set_t *setp, 4880Sstevel@tonic-gate char *numeral_id, devfsadm_enumerate_t rules[], int index); 4890Sstevel@tonic-gate static int devfsadm_copy_file(const char *file, const struct stat *stat, 4900Sstevel@tonic-gate int flags, struct FTW *ftw); 4910Sstevel@tonic-gate static void getattr(char *devname, char *aminor, int spectype, dev_t dev, 4920Sstevel@tonic-gate mode_t *mode, uid_t *uid, gid_t *gid); 4930Sstevel@tonic-gate static int minor_matches_rule(di_node_t node, di_minor_t minor, 4940Sstevel@tonic-gate create_list_t *create); 4950Sstevel@tonic-gate static void add_verbose_id(char *mid); 4960Sstevel@tonic-gate static char *get_component(char *str, const char *comp_num); 4970Sstevel@tonic-gate static char *alloc_cmp_str(const char *devfs_path, devfsadm_enumerate_t *dep); 4980Sstevel@tonic-gate static int lookup_enum_cache(numeral_set_t *set, char *cmp_str, 4990Sstevel@tonic-gate devfsadm_enumerate_t rules[], int index, numeral_t **matchnpp); 5000Sstevel@tonic-gate static void sync_handler(void *cookie, char *ap, size_t asize, 5010Sstevel@tonic-gate door_desc_t *dp, uint_t ndesc); 5020Sstevel@tonic-gate static void zlist_insert(struct zone_devinfo *newzone); 5030Sstevel@tonic-gate static void delete_zone(struct zone_devinfo *z); 5040Sstevel@tonic-gate static struct zone_devinfo *zlist_remove(char *zone_name); 5050Sstevel@tonic-gate static void zlist_deleteall_unlocked(void); 5060Sstevel@tonic-gate static void call_zone_register(char *zone_name, int regop); 5070Sstevel@tonic-gate static int register_all_zones(void); 5080Sstevel@tonic-gate static void zone_reg_handler(void *cookie, char *ap, size_t asize, 5090Sstevel@tonic-gate door_desc_t *dp, uint_t ndesc); 5100Sstevel@tonic-gate static int zone_pathcheck(char *checkpath); 5110Sstevel@tonic-gate static void process_deferred_links(struct dca_impl *dcip, int flag); 5120Sstevel@tonic-gate static void event_handler(sysevent_t *ev); 5130Sstevel@tonic-gate static int rcm_init(void); 5140Sstevel@tonic-gate static int notify_rcm(di_node_t node, char *minor_name); 5150Sstevel@tonic-gate static void dca_impl_init(char *root, char *minor, struct dca_impl *dcip); 5160Sstevel@tonic-gate static void lock_dev(void); 5170Sstevel@tonic-gate static void unlock_dev(int flag); 518*2587Spjha static int devlink_cb(di_devlink_t dl, void *arg); 519*2587Spjha static void free_dev_names(struct devlink_cb_arg *x); 5200Sstevel@tonic-gate 5210Sstevel@tonic-gate int load_devpolicy(void); 5220Sstevel@tonic-gate static void load_dev_acl(void); 5230Sstevel@tonic-gate static void load_minor_perm_file(void); 5240Sstevel@tonic-gate 5250Sstevel@tonic-gate static int (*librcm_alloc_handle)(char *, uint_t, void *, rcm_handle_t **); 5260Sstevel@tonic-gate static void (*librcm_free_handle)(rcm_handle_t *); 5270Sstevel@tonic-gate static int (*librcm_notify_event)(rcm_handle_t *, char *, uint_t, nvlist_t *, 5280Sstevel@tonic-gate rcm_info_t *); 5290Sstevel@tonic-gate static nvlist_t *build_event_attributes(char *, char *, char *, 5300Sstevel@tonic-gate di_node_t, char *, int); 5310Sstevel@tonic-gate static void log_event(char *, char *, nvlist_t *); 5320Sstevel@tonic-gate static void build_and_log_event(char *, char *, char *, di_node_t); 5330Sstevel@tonic-gate 5340Sstevel@tonic-gate static void read_logindevperm_file(void); 5350Sstevel@tonic-gate static void set_logindev_perms(char *devlink); 5360Sstevel@tonic-gate 5370Sstevel@tonic-gate static void reset_node_permissions(di_node_t, di_minor_t); 5380Sstevel@tonic-gate 5390Sstevel@tonic-gate 5400Sstevel@tonic-gate /* convenient short hands */ 5410Sstevel@tonic-gate #define vprint devfsadm_print 5420Sstevel@tonic-gate #define err_print devfsadm_errprint 5430Sstevel@tonic-gate #define TRUE 1 5440Sstevel@tonic-gate #define FALSE 0 5450Sstevel@tonic-gate 5460Sstevel@tonic-gate #ifdef __cplusplus 5470Sstevel@tonic-gate } 5480Sstevel@tonic-gate #endif 5490Sstevel@tonic-gate 5500Sstevel@tonic-gate #endif /* _DEVFSADM_IMPL_H */ 551