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 5f4da9be0Scth * Common Development and Distribution License (the "License"). 6f4da9be0Scth * 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*73cf56abSMita Solanky * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _CMD_MODLOAD_ADDREM_H 267c478bd9Sstevel@tonic-gate #define _CMD_MODLOAD_ADDREM_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 297c478bd9Sstevel@tonic-gate #include <device_info.h> 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* defines for add_drv.c, update_drv.c, and rem_drv.c */ 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #define SUCCESS 0 387c478bd9Sstevel@tonic-gate #define FAILURE -1 397c478bd9Sstevel@tonic-gate #define NOERR 0 407c478bd9Sstevel@tonic-gate #define ERROR -1 417c478bd9Sstevel@tonic-gate #define UNIQUE -2 427c478bd9Sstevel@tonic-gate #define NOT_UNIQUE -3 437c478bd9Sstevel@tonic-gate #define NONE_FOUND -4 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #define MAX_CMD_LINE 256 467c478bd9Sstevel@tonic-gate #define MAX_N2M_ALIAS_LINE FILENAME_MAX + FILENAME_MAX + 1 477c478bd9Sstevel@tonic-gate #define MAXLEN_NAM_TO_MAJ_ENT FILENAME_MAX + MAX_STR_MAJOR + 1 487c478bd9Sstevel@tonic-gate #define OPT_LEN 128 497c478bd9Sstevel@tonic-gate #define CADDR_HEX_STR 16 507c478bd9Sstevel@tonic-gate #define UINT_STR 10 517c478bd9Sstevel@tonic-gate #define MODLINE_ENT_MAX (4 * UINT_STR) + CADDR_HEX_STR + MODMAXNAMELEN 527c478bd9Sstevel@tonic-gate #define MAX_STR_MAJOR UINT_STR 537c478bd9Sstevel@tonic-gate #define STR_LONG 10 547c478bd9Sstevel@tonic-gate #define PERM_STR 4 557c478bd9Sstevel@tonic-gate #define MAX_PERM_ENTRY (2 * STR_LONG) + PERM_STR + (2 * FILENAME_MAX) + 1 567c478bd9Sstevel@tonic-gate #define MAX_DBFILE_ENTRY MAX_PERM_ENTRY 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate #define CLEAN_MINOR_PERM 0x00000001 597c478bd9Sstevel@tonic-gate #define CLEAN_DRV_ALIAS 0x00000002 607c478bd9Sstevel@tonic-gate #define CLEAN_NAM_MAJ 0x00000004 617c478bd9Sstevel@tonic-gate #define CLEAN_DRV_CLASSES 0x00000010 627c478bd9Sstevel@tonic-gate #define CLEAN_DEV_POLICY 0x00000020 637c478bd9Sstevel@tonic-gate #define CLEAN_DRV_PRIV 0x00000040 647c478bd9Sstevel@tonic-gate #define CLEAN_ALL (CLEAN_MINOR_PERM | CLEAN_DRV_ALIAS | \ 657c478bd9Sstevel@tonic-gate CLEAN_NAM_MAJ | CLEAN_DRV_CLASSES | \ 667c478bd9Sstevel@tonic-gate CLEAN_DEV_POLICY | CLEAN_DRV_PRIV) 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* add_drv/rem_drv database files */ 697c478bd9Sstevel@tonic-gate #define DRIVER_ALIAS "/etc/driver_aliases" 707c478bd9Sstevel@tonic-gate #define DRIVER_CLASSES "/etc/driver_classes" 717c478bd9Sstevel@tonic-gate #define MINOR_PERM "/etc/minor_perm" 727c478bd9Sstevel@tonic-gate #define NAM_TO_MAJ "/etc/name_to_major" 737c478bd9Sstevel@tonic-gate #define REM_NAM_TO_MAJ "/etc/rem_name_to_major" 747c478bd9Sstevel@tonic-gate 75*73cf56abSMita Solanky #define ADD_REM_LOCK "/var/run/AdDrEm.lck" 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate #if defined(__x86) 787c478bd9Sstevel@tonic-gate #define DRVDIR64 "amd64" 797c478bd9Sstevel@tonic-gate #elif defined(__sparc) 807c478bd9Sstevel@tonic-gate #define DRVDIR64 "sparcv9" 817c478bd9Sstevel@tonic-gate #endif 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* pointers to add_drv/rem_drv database files */ 847c478bd9Sstevel@tonic-gate char *driver_aliases; 857c478bd9Sstevel@tonic-gate char *driver_classes; 867c478bd9Sstevel@tonic-gate char *minor_perm; 877c478bd9Sstevel@tonic-gate char *name_to_major; 887c478bd9Sstevel@tonic-gate char *rem_name_to_major; 897c478bd9Sstevel@tonic-gate char *device_policy; 907c478bd9Sstevel@tonic-gate char *extra_privs; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* devfs root string */ 937c478bd9Sstevel@tonic-gate char *devfs_root; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /* module path searching structure */ 967c478bd9Sstevel@tonic-gate struct drvmod_dir { 977c478bd9Sstevel@tonic-gate char direc[FILENAME_MAX + 1]; 987c478bd9Sstevel@tonic-gate struct drvmod_dir *next; 997c478bd9Sstevel@tonic-gate }; 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate struct drvmod_dir *moddir; 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* names of things: directories, commands, files */ 1047c478bd9Sstevel@tonic-gate #define KERNEL_DRV "/kernel/drv" 1057c478bd9Sstevel@tonic-gate #define USR_KERNEL_DRV "/usr/kernel/drv" 1067c478bd9Sstevel@tonic-gate #define DRVCONFIG_PATH "/usr/sbin/drvconfig" 1077c478bd9Sstevel@tonic-gate #define DRVCONFIG "drvconfig" 1087c478bd9Sstevel@tonic-gate #define DEVFSADM_PATH "/usr/sbin/devfsadm" 1097c478bd9Sstevel@tonic-gate #define DEVFSADM "devfsadm" 1107c478bd9Sstevel@tonic-gate #define DEVFS_ROOT "/devices" 1117c478bd9Sstevel@tonic-gate #define RECONFIGURE "/reconfigure" 1127c478bd9Sstevel@tonic-gate #define MODUNLOAD_PATH "/usr/sbin/modunload" 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate extern void log_minorperm_error(minorperm_err_t, int); 1157c478bd9Sstevel@tonic-gate extern void remove_entry(int, char *); 1167c478bd9Sstevel@tonic-gate extern char *get_next_entry(char *, char *); 1177c478bd9Sstevel@tonic-gate extern char *get_perm_entry(char *, char *); 1187c478bd9Sstevel@tonic-gate extern int check_perms_aliases(int, int); 1197c478bd9Sstevel@tonic-gate extern int check_name_to_major(int); 1207c478bd9Sstevel@tonic-gate extern void enter_lock(void); 1217c478bd9Sstevel@tonic-gate extern void err_exit(void); 1227c478bd9Sstevel@tonic-gate extern void exit_unlock(void); 123f4da9be0Scth extern char *get_entry(char *, char *, char, int); 1247c478bd9Sstevel@tonic-gate extern int build_filenames(char *); 125f4da9be0Scth extern int append_to_file(char *, char *, char *, char, char *, int); 1263c0ea289SJerry Gilliam extern int append_to_minor_perm(char *, char *, char *); 1277c478bd9Sstevel@tonic-gate extern int get_major_no(char *, char *); 1287c478bd9Sstevel@tonic-gate extern int get_driver_name(int, char *, char *); 1297c478bd9Sstevel@tonic-gate extern int delete_entry(char *, char *, char *, char *); 1307c478bd9Sstevel@tonic-gate extern int check_space_within_quote(char *); 1317c478bd9Sstevel@tonic-gate extern void list_entry(char *, char *, char *); 1327c478bd9Sstevel@tonic-gate extern int update_minor_entry(char *, char *); 1337c478bd9Sstevel@tonic-gate extern int check_perm_opts(char *); 1347c478bd9Sstevel@tonic-gate extern int update_name_to_major(char *, major_t *, int); 1357c478bd9Sstevel@tonic-gate extern int do_the_update(char *, char *); 1367c478bd9Sstevel@tonic-gate extern int fill_n2m_array(char *, char **, int *); 1377c478bd9Sstevel@tonic-gate extern int aliases_unique(char *); 1382e107de7SJerry Gilliam extern int aliases_exist(char *); 139f4da9be0Scth extern int aliases_paths_exist(char *); 1407c478bd9Sstevel@tonic-gate extern int update_driver_aliases(char *, char *); 1417c478bd9Sstevel@tonic-gate extern int unique_driver_name(char *, char *, int *); 1427c478bd9Sstevel@tonic-gate extern int unique_drv_alias(char *); 1430013e2d3SJerry Gilliam extern int check_duplicate_driver_alias(char *, char *); 1440013e2d3SJerry Gilliam extern int trim_duplicate_aliases(char *, char *, char **); 1457c478bd9Sstevel@tonic-gate extern int get_max_major(char *); 1467c478bd9Sstevel@tonic-gate extern void get_modid(char *, int *); 1477c478bd9Sstevel@tonic-gate extern int config_driver(char *, major_t, char *, char *, int, int); 148c9cc1492SJerry Gilliam extern int unconfig_driver(char *, major_t, char *, int); 1497c478bd9Sstevel@tonic-gate extern void load_driver(char *, int); 1507c478bd9Sstevel@tonic-gate extern int create_reconfig(char *); 1517c478bd9Sstevel@tonic-gate extern void cleanup_moddir(void); 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate /* drvsubr.c */ 1547c478bd9Sstevel@tonic-gate #define XEND ".XXXXXX" 1557c478bd9Sstevel@tonic-gate #define MAXMODPATHS 1024 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate /* module path list separators */ 1587c478bd9Sstevel@tonic-gate #define MOD_SEP " :" 1597c478bd9Sstevel@tonic-gate #define DIR_SEP "/" 1607c478bd9Sstevel@tonic-gate 161c9cc1492SJerry Gilliam /* [un]config_driver flags */ 162c9cc1492SJerry Gilliam #define CONFIG_DRV_VERBOSE 0x01 /* verbose */ 163c9cc1492SJerry Gilliam #define CONFIG_DRV_FORCE 0x02 /* unconfig even if in use */ 164c9cc1492SJerry Gilliam #define CONFIG_DRV_UPDATE_ONLY 0x04 /* -u update only */ 165c9cc1492SJerry Gilliam 1667c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1677c478bd9Sstevel@tonic-gate } 1687c478bd9Sstevel@tonic-gate #endif 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate #endif /* _CMD_MODLOAD_ADDREM_H */ 171