/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _DEVFSADM_IMPL_H
#define _DEVFSADM_IMPL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <dlfcn.h>
#include <stdarg.h>
#include <fcntl.h>
#include <locale.h>
#include <libintl.h>
#include <ctype.h>
#include <signal.h>
#include <deflt.h>
#include <ftw.h>
#include <sys/instance.h>
#include <dirent.h>
#include <pwd.h>
#include <grp.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/int_types.h>
#include <limits.h>
#include <strings.h>
#include <devfsadm.h>
#include <libdevinfo.h>
#include <sys/devinfo_impl.h>
#include <libgen.h>
#include <door.h>
#include <syslog.h>
#include <libsysevent.h>
#include <thread.h>
#include <message.h>
#include <libzonecfg.h>
#include <device_info.h>
#define INTEGER 0
/* Possible flag values for flag member of numeral_t */
#define EV_TYPE 0
/* add new debug level and meanings here */
typedef struct recurse_dev {
void (*fcn)(char *, void *);
void *data;
typedef struct link {
} link_t;
typedef struct linkhead {
char *dir_re;
} linkhead_t;
typedef struct link_list {
int type;
char *constant;
int arg;
} link_list_t;
typedef struct selector_list {
int key;
char *val;
int arg;
typedef struct devlinktab_list {
int line_number;
char *selector_pattern;
char *p_link_pattern;
char *s_link_pattern;
typedef struct module {
char *name;
void *dlhandle;
int (*minor_init)();
int (*minor_fini)();
int flags;
} module_t;
typedef struct create_list {
struct minor {
};
struct mlist {
};
typedef struct remove_list {
typedef struct item {
char *i_key;
} item_t;
typedef struct cleanup_data {
int flags;
char *phypath;
typedef struct n2m {
char *driver;
} n2m_t;
/* structures for devfsadm_enumerate() */
typedef struct numeral {
char *id;
char *full_path;
int rule_index;
char *cmp_str;
int flags;
} numeral_t;
typedef struct numeral_set {
int re_count;
char **re;
typedef struct temp {
int integer;
} temp_t;
typedef struct driver_alias {
char *driver_name;
char *alias_name;
struct driver_list {
};
struct login_dev {
char *ldev_console;
int ldev_perms;
char *ldev_device;
};
struct devlink_cb_arg {
int count;
int rv;
};
struct dca_impl {
char *dci_root;
char *dci_minor;
char *dci_driver;
void *dci_arg;
int dci_error;
int dci_flags;
};
/* sysevent queue related */
typedef struct syseventq_s {
char *class;
char *subclass;
} syseventq_t;
static int devfsadm_enumerate_int_start(char *devfs_path,
static void set_root_devices_dev_dir(char *dir);
static void pre_and_post_cleanup(int flags);
static void hot_cleanup(char *, char *, char *, char *, int);
static void devfsadm_exit(int status);
static void rm_link_from_cache(char *devlink);
static void rm_all_links_from_cache();
static void instance_flush_thread(void);
static void rm_parent_dir_if_empty(char *path);
void devfsadm_err_print(char *message, ...);
static void invalidate_enumerate_cache(void);
static pid_t enter_dev_lock(void);
static void exit_dev_lock(int exiting);
static pid_t enter_daemon_lock(void);
static void exit_daemon_lock(int exiting);
static int alias(char *, char *);
static int devfsadm_copy(void);
static void flush_path_to_inst(void);
static void detachfromtty(void);
static void read_minor_perm_file(void);
static void read_driver_aliases_file(void);
static void load_modules(void);
static void unload_modules(void);
static void devfs_instance_mod(void);
static void add_minor_pathname(char *, char *, char *);
char **devfs_path, int dangle);
static int load_n2m_table(char *filename);
static int get_stat_info(char *, struct stat *);
static void daemon_update(void);
static void usage(void);
static void process_devinfo_tree(void);
static void minor_fini_thread(void *arg);
static void read_devlinktab_file(void);
int devfsadm_noupdate(void);
const char *devfsadm_root_path(void);
char **s_link);
int nrules);
int subexp);
static void add_verbose_id(char *mid);
static int zone_pathcheck(char *checkpath);
static void lock_dev(void);
static void unlock_dev(int flag);
static void free_dev_names(struct devlink_cb_arg *x);
int load_devpolicy(void);
static void load_dev_acl(void);
static void load_minor_perm_file(void);
static nvlist_t *build_event_attributes(char *, char *, char *,
di_node_t, char *, int, char *);
static void build_and_enq_event(char *, char *, char *, di_node_t, char *);
static void read_logindevperm_file(void);
static void set_logindev_perms(char *devlink);
/*
* devname related
*/
static void devname_lookup_handler(void *, char *, size_t,
static int devname_kcall(int, void *); /* syscall into the devname fs */
static void nfphash_create(void);
static int nfphash_fcn(char *key);
static void nfphash_insert(char *key);
static void nfphash_destroy(void);
/* Enumerate reserve related */
static void read_enumerate_file(void);
/* convenient short hands */
#ifndef TRUE
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifdef __cplusplus
}
#endif
#endif /* _DEVFSADM_IMPL_H */