xref: /onnv-gate/usr/src/cmd/modload/addrem.h (revision 12182:2c66b1e5416b)
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
54145Scth  * Common Development and Distribution License (the "License").
64145Scth  * 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  */
210Sstevel@tonic-gate /*
22*12182Smita@sun.com  * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef _CMD_MODLOAD_ADDREM_H
260Sstevel@tonic-gate #define	_CMD_MODLOAD_ADDREM_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include <sys/modctl.h>
290Sstevel@tonic-gate #include <device_info.h>
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate /* defines for add_drv.c, update_drv.c, and rem_drv.c */
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #define	SUCCESS	0
380Sstevel@tonic-gate #define	FAILURE -1
390Sstevel@tonic-gate #define	NOERR	0
400Sstevel@tonic-gate #define	ERROR	-1
410Sstevel@tonic-gate #define	UNIQUE	-2
420Sstevel@tonic-gate #define	NOT_UNIQUE -3
430Sstevel@tonic-gate #define	NONE_FOUND -4
440Sstevel@tonic-gate 
450Sstevel@tonic-gate #define	MAX_CMD_LINE	256
460Sstevel@tonic-gate #define	MAX_N2M_ALIAS_LINE	FILENAME_MAX + FILENAME_MAX + 1
470Sstevel@tonic-gate #define	MAXLEN_NAM_TO_MAJ_ENT 	FILENAME_MAX + MAX_STR_MAJOR + 1
480Sstevel@tonic-gate #define	OPT_LEN		128
490Sstevel@tonic-gate #define	CADDR_HEX_STR	16
500Sstevel@tonic-gate #define	UINT_STR	10
510Sstevel@tonic-gate #define	MODLINE_ENT_MAX	(4 * UINT_STR) + CADDR_HEX_STR + MODMAXNAMELEN
520Sstevel@tonic-gate #define	MAX_STR_MAJOR	UINT_STR
530Sstevel@tonic-gate #define	STR_LONG	10
540Sstevel@tonic-gate #define	PERM_STR	4
550Sstevel@tonic-gate #define	MAX_PERM_ENTRY	(2 * STR_LONG) + PERM_STR + (2 * FILENAME_MAX) + 1
560Sstevel@tonic-gate #define	MAX_DBFILE_ENTRY	MAX_PERM_ENTRY
570Sstevel@tonic-gate 
580Sstevel@tonic-gate #define	CLEAN_MINOR_PERM	0x00000001
590Sstevel@tonic-gate #define	CLEAN_DRV_ALIAS		0x00000002
600Sstevel@tonic-gate #define	CLEAN_NAM_MAJ		0x00000004
610Sstevel@tonic-gate #define	CLEAN_DRV_CLASSES	0x00000010
620Sstevel@tonic-gate #define	CLEAN_DEV_POLICY	0x00000020
630Sstevel@tonic-gate #define	CLEAN_DRV_PRIV		0x00000040
640Sstevel@tonic-gate #define	CLEAN_ALL		(CLEAN_MINOR_PERM | CLEAN_DRV_ALIAS | \
650Sstevel@tonic-gate 				CLEAN_NAM_MAJ | CLEAN_DRV_CLASSES | \
660Sstevel@tonic-gate 				CLEAN_DEV_POLICY | CLEAN_DRV_PRIV)
670Sstevel@tonic-gate 
680Sstevel@tonic-gate /* add_drv/rem_drv database files */
690Sstevel@tonic-gate #define	DRIVER_ALIAS	"/etc/driver_aliases"
700Sstevel@tonic-gate #define	DRIVER_CLASSES	"/etc/driver_classes"
710Sstevel@tonic-gate #define	MINOR_PERM	"/etc/minor_perm"
720Sstevel@tonic-gate #define	NAM_TO_MAJ	"/etc/name_to_major"
730Sstevel@tonic-gate #define	REM_NAM_TO_MAJ	"/etc/rem_name_to_major"
740Sstevel@tonic-gate 
75*12182Smita@sun.com #define	ADD_REM_LOCK	"/var/run/AdDrEm.lck"
760Sstevel@tonic-gate #define	TMPHOLD		"/etc/TmPhOlD"
770Sstevel@tonic-gate 
780Sstevel@tonic-gate #if defined(__x86)
790Sstevel@tonic-gate #define	DRVDIR64	"amd64"
800Sstevel@tonic-gate #elif defined(__sparc)
810Sstevel@tonic-gate #define	DRVDIR64	"sparcv9"
820Sstevel@tonic-gate #endif
830Sstevel@tonic-gate 
840Sstevel@tonic-gate /* pointers to add_drv/rem_drv database files */
850Sstevel@tonic-gate char *driver_aliases;
860Sstevel@tonic-gate char *driver_classes;
870Sstevel@tonic-gate char *minor_perm;
880Sstevel@tonic-gate char *name_to_major;
890Sstevel@tonic-gate char *rem_name_to_major;
900Sstevel@tonic-gate char *device_policy;
910Sstevel@tonic-gate char *extra_privs;
920Sstevel@tonic-gate 
930Sstevel@tonic-gate /* devfs root string */
940Sstevel@tonic-gate char *devfs_root;
950Sstevel@tonic-gate 
960Sstevel@tonic-gate /* module path searching structure */
970Sstevel@tonic-gate struct drvmod_dir {
980Sstevel@tonic-gate 	char direc[FILENAME_MAX + 1];
990Sstevel@tonic-gate 	struct drvmod_dir *next;
1000Sstevel@tonic-gate };
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate struct drvmod_dir *moddir;
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate /* names of things: directories, commands, files */
1050Sstevel@tonic-gate #define	KERNEL_DRV	"/kernel/drv"
1060Sstevel@tonic-gate #define	USR_KERNEL_DRV	"/usr/kernel/drv"
1070Sstevel@tonic-gate #define	DRVCONFIG_PATH	"/usr/sbin/drvconfig"
1080Sstevel@tonic-gate #define	DRVCONFIG	"drvconfig"
1090Sstevel@tonic-gate #define	DEVFSADM_PATH	"/usr/sbin/devfsadm"
1100Sstevel@tonic-gate #define	DEVFSADM	"devfsadm"
1110Sstevel@tonic-gate #define	DEVFS_ROOT	"/devices"
1120Sstevel@tonic-gate #define	RECONFIGURE	"/reconfigure"
1130Sstevel@tonic-gate #define	MODUNLOAD_PATH	"/usr/sbin/modunload"
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate extern void log_minorperm_error(minorperm_err_t, int);
1160Sstevel@tonic-gate extern void remove_entry(int, char *);
1170Sstevel@tonic-gate extern char *get_next_entry(char *, char *);
1180Sstevel@tonic-gate extern char *get_perm_entry(char *, char *);
1190Sstevel@tonic-gate extern int check_perms_aliases(int, int);
1200Sstevel@tonic-gate extern int check_name_to_major(int);
1210Sstevel@tonic-gate extern void enter_lock(void);
1220Sstevel@tonic-gate extern void err_exit(void);
1230Sstevel@tonic-gate extern void exit_unlock(void);
1244145Scth extern char *get_entry(char *, char *, char, int);
1250Sstevel@tonic-gate extern int build_filenames(char *);
1264145Scth extern int append_to_file(char *, char *, char *, char, char *, int);
12710599SJerry.Gilliam@Sun.COM extern int append_to_minor_perm(char *, char *, char *);
1280Sstevel@tonic-gate extern int get_major_no(char *, char *);
1290Sstevel@tonic-gate extern int get_driver_name(int, char *, char *);
1300Sstevel@tonic-gate extern int delete_entry(char *, char *, char *, char *);
1310Sstevel@tonic-gate extern int check_space_within_quote(char *);
1320Sstevel@tonic-gate extern void list_entry(char *, char *, char *);
1330Sstevel@tonic-gate extern int update_minor_entry(char *, char *);
1340Sstevel@tonic-gate extern int check_perm_opts(char *);
1350Sstevel@tonic-gate extern int update_name_to_major(char *, major_t *, int);
1360Sstevel@tonic-gate extern int do_the_update(char *, char *);
1370Sstevel@tonic-gate extern int fill_n2m_array(char *, char **, int *);
1380Sstevel@tonic-gate extern int aliases_unique(char *);
1399268SJerry.Gilliam@Sun.COM extern int aliases_exist(char *);
1404145Scth extern int aliases_paths_exist(char *);
1410Sstevel@tonic-gate extern int update_driver_aliases(char *, char *);
1420Sstevel@tonic-gate extern int unique_driver_name(char *, char *, int *);
1430Sstevel@tonic-gate extern int unique_drv_alias(char *);
1448331SJerry.Gilliam@Sun.COM extern int check_duplicate_driver_alias(char *, char *);
1458331SJerry.Gilliam@Sun.COM extern int trim_duplicate_aliases(char *, char *, char **);
1460Sstevel@tonic-gate extern int get_max_major(char *);
1470Sstevel@tonic-gate extern void get_modid(char *, int *);
1480Sstevel@tonic-gate extern int config_driver(char *, major_t, char *, char *, int, int);
14910842SJerry.Gilliam@Sun.COM extern int unconfig_driver(char *, major_t, char *, int);
1500Sstevel@tonic-gate extern void load_driver(char *, int);
1510Sstevel@tonic-gate extern int create_reconfig(char *);
1520Sstevel@tonic-gate extern void cleanup_moddir(void);
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate /* drvsubr.c */
1550Sstevel@tonic-gate #define	XEND	".XXXXXX"
1560Sstevel@tonic-gate #define	MAXMODPATHS	1024
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate /* module path list separators */
1590Sstevel@tonic-gate #define	MOD_SEP	" :"
1600Sstevel@tonic-gate #define	DIR_SEP "/"
1610Sstevel@tonic-gate 
16210842SJerry.Gilliam@Sun.COM /* [un]config_driver flags */
16310842SJerry.Gilliam@Sun.COM #define	CONFIG_DRV_VERBOSE	0x01		/* verbose */
16410842SJerry.Gilliam@Sun.COM #define	CONFIG_DRV_FORCE	0x02		/* unconfig even if in use */
16510842SJerry.Gilliam@Sun.COM #define	CONFIG_DRV_UPDATE_ONLY	0x04		/* -u update only */
16610842SJerry.Gilliam@Sun.COM 
1670Sstevel@tonic-gate #ifdef	__cplusplus
1680Sstevel@tonic-gate }
1690Sstevel@tonic-gate #endif
1700Sstevel@tonic-gate 
1710Sstevel@tonic-gate #endif /* _CMD_MODLOAD_ADDREM_H */
172