1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _CMD_MODLOAD_ADDREM_H 28*7c478bd9Sstevel@tonic-gate #define _CMD_MODLOAD_ADDREM_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 33*7c478bd9Sstevel@tonic-gate #include <device_info.h> 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 36*7c478bd9Sstevel@tonic-gate extern "C" { 37*7c478bd9Sstevel@tonic-gate #endif 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate /* defines for add_drv.c, update_drv.c, and rem_drv.c */ 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate #define SUCCESS 0 42*7c478bd9Sstevel@tonic-gate #define FAILURE -1 43*7c478bd9Sstevel@tonic-gate #define NOERR 0 44*7c478bd9Sstevel@tonic-gate #define ERROR -1 45*7c478bd9Sstevel@tonic-gate #define UNIQUE -2 46*7c478bd9Sstevel@tonic-gate #define NOT_UNIQUE -3 47*7c478bd9Sstevel@tonic-gate #define NONE_FOUND -4 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate #define MAX_CMD_LINE 256 50*7c478bd9Sstevel@tonic-gate #define MAX_N2M_ALIAS_LINE FILENAME_MAX + FILENAME_MAX + 1 51*7c478bd9Sstevel@tonic-gate #define MAXLEN_NAM_TO_MAJ_ENT FILENAME_MAX + MAX_STR_MAJOR + 1 52*7c478bd9Sstevel@tonic-gate #define OPT_LEN 128 53*7c478bd9Sstevel@tonic-gate #define CADDR_HEX_STR 16 54*7c478bd9Sstevel@tonic-gate #define UINT_STR 10 55*7c478bd9Sstevel@tonic-gate #define MODLINE_ENT_MAX (4 * UINT_STR) + CADDR_HEX_STR + MODMAXNAMELEN 56*7c478bd9Sstevel@tonic-gate #define MAX_STR_MAJOR UINT_STR 57*7c478bd9Sstevel@tonic-gate #define STR_LONG 10 58*7c478bd9Sstevel@tonic-gate #define PERM_STR 4 59*7c478bd9Sstevel@tonic-gate #define MAX_PERM_ENTRY (2 * STR_LONG) + PERM_STR + (2 * FILENAME_MAX) + 1 60*7c478bd9Sstevel@tonic-gate #define MAX_DBFILE_ENTRY MAX_PERM_ENTRY 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate #define CLEAN_MINOR_PERM 0x00000001 63*7c478bd9Sstevel@tonic-gate #define CLEAN_DRV_ALIAS 0x00000002 64*7c478bd9Sstevel@tonic-gate #define CLEAN_NAM_MAJ 0x00000004 65*7c478bd9Sstevel@tonic-gate #define CLEAN_DRV_CLASSES 0x00000010 66*7c478bd9Sstevel@tonic-gate #define CLEAN_DEV_POLICY 0x00000020 67*7c478bd9Sstevel@tonic-gate #define CLEAN_DRV_PRIV 0x00000040 68*7c478bd9Sstevel@tonic-gate #define CLEAN_ALL (CLEAN_MINOR_PERM | CLEAN_DRV_ALIAS | \ 69*7c478bd9Sstevel@tonic-gate CLEAN_NAM_MAJ | CLEAN_DRV_CLASSES | \ 70*7c478bd9Sstevel@tonic-gate CLEAN_DEV_POLICY | CLEAN_DRV_PRIV) 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate /* add_drv/rem_drv database files */ 73*7c478bd9Sstevel@tonic-gate #define DRIVER_ALIAS "/etc/driver_aliases" 74*7c478bd9Sstevel@tonic-gate #define DRIVER_CLASSES "/etc/driver_classes" 75*7c478bd9Sstevel@tonic-gate #define MINOR_PERM "/etc/minor_perm" 76*7c478bd9Sstevel@tonic-gate #define NAM_TO_MAJ "/etc/name_to_major" 77*7c478bd9Sstevel@tonic-gate #define REM_NAM_TO_MAJ "/etc/rem_name_to_major" 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate #define ADD_REM_LOCK "/tmp/AdDrEm.lck" 80*7c478bd9Sstevel@tonic-gate #define TMPHOLD "/etc/TmPhOlD" 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate #if defined(__x86) 83*7c478bd9Sstevel@tonic-gate #define DRVDIR64 "amd64" 84*7c478bd9Sstevel@tonic-gate #elif defined(__sparc) 85*7c478bd9Sstevel@tonic-gate #define DRVDIR64 "sparcv9" 86*7c478bd9Sstevel@tonic-gate #endif 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate /* pointers to add_drv/rem_drv database files */ 89*7c478bd9Sstevel@tonic-gate char *driver_aliases; 90*7c478bd9Sstevel@tonic-gate char *driver_classes; 91*7c478bd9Sstevel@tonic-gate char *minor_perm; 92*7c478bd9Sstevel@tonic-gate char *name_to_major; 93*7c478bd9Sstevel@tonic-gate char *rem_name_to_major; 94*7c478bd9Sstevel@tonic-gate char *device_policy; 95*7c478bd9Sstevel@tonic-gate char *extra_privs; 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate /* devfs root string */ 98*7c478bd9Sstevel@tonic-gate char *devfs_root; 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate /* module path searching structure */ 101*7c478bd9Sstevel@tonic-gate struct drvmod_dir { 102*7c478bd9Sstevel@tonic-gate char direc[FILENAME_MAX + 1]; 103*7c478bd9Sstevel@tonic-gate struct drvmod_dir *next; 104*7c478bd9Sstevel@tonic-gate }; 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate struct drvmod_dir *moddir; 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate /* names of things: directories, commands, files */ 109*7c478bd9Sstevel@tonic-gate #define KERNEL_DRV "/kernel/drv" 110*7c478bd9Sstevel@tonic-gate #define USR_KERNEL_DRV "/usr/kernel/drv" 111*7c478bd9Sstevel@tonic-gate #define DRVCONFIG_PATH "/usr/sbin/drvconfig" 112*7c478bd9Sstevel@tonic-gate #define DRVCONFIG "drvconfig" 113*7c478bd9Sstevel@tonic-gate #define DEVFSADM_PATH "/usr/sbin/devfsadm" 114*7c478bd9Sstevel@tonic-gate #define DEVFSADM "devfsadm" 115*7c478bd9Sstevel@tonic-gate #define DEVFS_ROOT "/devices" 116*7c478bd9Sstevel@tonic-gate #define RECONFIGURE "/reconfigure" 117*7c478bd9Sstevel@tonic-gate #define MODUNLOAD_PATH "/usr/sbin/modunload" 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate extern void log_minorperm_error(minorperm_err_t, int); 120*7c478bd9Sstevel@tonic-gate extern void remove_entry(int, char *); 121*7c478bd9Sstevel@tonic-gate extern char *get_next_entry(char *, char *); 122*7c478bd9Sstevel@tonic-gate extern char *get_perm_entry(char *, char *); 123*7c478bd9Sstevel@tonic-gate extern int check_perms_aliases(int, int); 124*7c478bd9Sstevel@tonic-gate extern int check_name_to_major(int); 125*7c478bd9Sstevel@tonic-gate extern void enter_lock(void); 126*7c478bd9Sstevel@tonic-gate extern void err_exit(void); 127*7c478bd9Sstevel@tonic-gate extern void exit_unlock(void); 128*7c478bd9Sstevel@tonic-gate extern char *get_entry(char *, char *, char); 129*7c478bd9Sstevel@tonic-gate extern int build_filenames(char *); 130*7c478bd9Sstevel@tonic-gate extern int append_to_file(char *, char *, char *, char, char *); 131*7c478bd9Sstevel@tonic-gate extern int get_major_no(char *, char *); 132*7c478bd9Sstevel@tonic-gate extern int get_driver_name(int, char *, char *); 133*7c478bd9Sstevel@tonic-gate extern int delete_entry(char *, char *, char *, char *); 134*7c478bd9Sstevel@tonic-gate extern int check_space_within_quote(char *); 135*7c478bd9Sstevel@tonic-gate extern void list_entry(char *, char *, char *); 136*7c478bd9Sstevel@tonic-gate extern int update_minor_entry(char *, char *); 137*7c478bd9Sstevel@tonic-gate extern int check_perm_opts(char *); 138*7c478bd9Sstevel@tonic-gate extern int update_name_to_major(char *, major_t *, int); 139*7c478bd9Sstevel@tonic-gate extern int do_the_update(char *, char *); 140*7c478bd9Sstevel@tonic-gate extern int fill_n2m_array(char *, char **, int *); 141*7c478bd9Sstevel@tonic-gate extern int aliases_unique(char *); 142*7c478bd9Sstevel@tonic-gate extern int update_driver_aliases(char *, char *); 143*7c478bd9Sstevel@tonic-gate extern int unique_driver_name(char *, char *, int *); 144*7c478bd9Sstevel@tonic-gate extern int unique_drv_alias(char *); 145*7c478bd9Sstevel@tonic-gate extern int get_max_major(char *); 146*7c478bd9Sstevel@tonic-gate extern void get_modid(char *, int *); 147*7c478bd9Sstevel@tonic-gate extern int config_driver(char *, major_t, char *, char *, int, int); 148*7c478bd9Sstevel@tonic-gate extern void load_driver(char *, int); 149*7c478bd9Sstevel@tonic-gate extern int create_reconfig(char *); 150*7c478bd9Sstevel@tonic-gate extern void cleanup_moddir(void); 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate /* drvsubr.c */ 153*7c478bd9Sstevel@tonic-gate #define XEND ".XXXXXX" 154*7c478bd9Sstevel@tonic-gate #define MAXMODPATHS 1024 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate /* module path list separators */ 157*7c478bd9Sstevel@tonic-gate #define MOD_SEP " :" 158*7c478bd9Sstevel@tonic-gate #define DIR_SEP "/" 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 161*7c478bd9Sstevel@tonic-gate } 162*7c478bd9Sstevel@tonic-gate #endif 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate #endif /* _CMD_MODLOAD_ADDREM_H */ 165