Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../bin/.././include/sysobj.h
Real path: /usr/include/sysobj.h
Zurück
/* * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. */ #ifndef _SYSOBJ_H #define _SYSOBJ_H #include <sys/sysobj.h> #include <sys/list.h> #include <sys/nvpair.h> #include <pthread.h> #include <uuid/uuid.h> #include <ucred.h> #ifdef __cplusplus extern "C" { #endif #ifdef _SYSOBJ_INTERNAL typedef enum { SYSOBJ_CHG_NONE = 0, SYSOBJ_CHG_ADD_ALIAS, SYSOBJ_CHG_UPD_ALIAS, SYSOBJ_CHG_DEL_ALIAS, SYSOBJ_CHG_ADD_PROPERTY, SYSOBJ_CHG_UPD_PROPERTY, SYSOBJ_CHG_DEL_PROPERTY } sysobjdb_chg_t; typedef enum { SYSOBJ_OPEN_CREATE = 0x0001, SYSOBJ_OPEN_WRITE = 0x0002, SYSOBJ_OPEN_CHECK = 0x0004 } sysobjdb_open_t; /* * Internal interfaces only to set access mode. Everyone should use * server mode, except sysobjd and sysobjadm (with the right flag and * if executed by a privileged user). */ typedef enum { SERVERONLY = 0, /* use server for call calls. wait until available */ DIRECT /* directly use SQL to access the database */ } connect_policy_t; extern connect_policy_t connect_policy; #endif /* * sysobj type. opaque to users. */ typedef struct _sysobj { /* quantities we expose to users via access routines */ uuid_t uuid; /* stuff below this line is implementation private */ struct _sysobj *next; char uuname[UUID_PRINTABLE_STRING_LENGTH]; size_t nclasses; char **classes; } *sysobj_t; #define SYSOBJ_EVREG_NOWAIT 0x0001 #define SYSOBJ_EVREG_PORT 0x0002 #define SYSOBJ_EVREG_DELETED 0x0004 #define SYSOBJ_EVREG_INTERNAL (SYSOBJ_EVREG_DELETED) /* * Free sysobj struct. */ void sysobj_free(sysobj_t __obj); /* * Duplicate sysobj struct. */ sysobj_t sysobj_dup(sysobj_t __obj); /* * Create/remove entry in db. */ int sysobj_create(uuid_t *__uuidp, const char *__class, sysobj_t *__objp); int sysobj_destroy(sysobj_t __obj); /* * Retrieve classes an entry belongs to. */ int sysobj_classes(sysobj_t __obj, char ***__classes, size_t *__nclasses); /* * Add/delete get properties. */ int sysobj_add_property(sysobj_t __obj, const char *__classname, const char *__propname, data_type_t __type, ...); int sysobj_del_property(sysobj_t __obj, const char *__classname, const char *__property); int sysobj_get_property(sysobj_t __obj, const char *__classname, const char *__property, data_type_t __type, ...); int sysobj_properties(sysobj_t __obj, const char *__classname, const char *__property, nvlist_t **__nvlp); #ifdef _SYSOBJ_INTERNAL int __sysobj_add_property_nvpair(sysobj_t __obj, const char *__class, nvpair_t *__nvp); #endif /* * sysobj_properties helper functions. */ int sysobj_nvl_prop_classes(nvlist_t *__nvl, nvlist_t **__nvlp); int sysobj_nvl_prop_list(nvlist_t *__nvl, const char *__class, nvlist_t **__nvlp); int sysobj_nvl_prop_nvpair(nvlist_t *__nvl, const char *__class, const char *__name, nvpair_t **__nvp); int sysobj_nvl_prop_value(nvlist_t *__nvl, const char *__class, const char *__name, data_type_t __type, ...); /* * Add/delete get aliases. */ int sysobj_add_alias(sysobj_t __obj, const char *__classname, const char *__namespace, const char *__alias); int sysobj_del_alias(sysobj_t __obj, const char *__classname, const char *__namespace, const char *__alias); int sysobj_get_aliases(sysobj_t __obj, const char *__classname, const char *__namespace, char ***__aliasesp, size_t *__nelemp); int sysobj_aliases(sysobj_t __obj, const char *__class, const char *__namespace, nvlist_t **__nvlp); /* * sysobj_aliases helper functions. */ int sysobj_nvl_alias_classes(nvlist_t *__nvl, nvlist_t **__nvlp); int sysobj_nvl_alias_namespaces(nvlist_t *__nvl, const char *__class, nvlist_t **__nvlp); int sysobj_nvl_alias_array(nvlist_t *__nvl, const char *__class, const char *__namespace, char ***__aliases, size_t *__naliases); /* * Extract UUID from sysobj_t. */ void sysobj_uuid(sysobj_t __obj, uuid_t *__uuidp); void sysobj_uuidstr(sysobj_t __obj, char *__uuidstr); /* * Get a list of sysobj_t's matching criteria. * * Where the parameter "search" is: * SET [logicop SET logicop SET ... ] * * Where SET is a comma-separated list of these comparisons (not all have * to be specified): * * aliasclass $EQOP 'string' * aliasspace $EQOP 'string' * aliasval $EQOP 'string' * propclass $EQOP 'string' * propname $EQOP 'string' * propval $EQOP 'string'|intval|hexval|floatval * [where $EQOP is '==' or '!='] * * propval $NUMOP intval|hexval|floatval * [where $NUMOP is '>' or '<' or '>=' or '<='] * * Extended RE matching is done on string values. * * logicop is either && (AND, intersection of two sets) or || (OR, union * of two sets). * * Bracketing may be used for grouping. */ int sysobj_lookup(const char *__search, sysobj_t **__results, size_t *__nresults); /* * Find an object by its uuid. */ int sysobj_find(char *__uuidstr, sysobj_t *__objp); /* * Register and unregister as an event watcher. */ int sysobj_event_register(uint64_t __flags, int *__portfdp); int sysobj_event_unregister(void); /* * Watch for certain type of events. */ int sysobj_event_watch(const char *__class, uint64_t __mask); /* * Get the next event that was queued for us because we said we were * interested in it. */ int sysobj_event_get(nvlist_t **__evnvlp); /* * Send a user event. */ int sysobj_event_user(const char *__class, const char *__evname, uint64_t __id, nvlist_t *__userdata); /* * Project private functions and definitions. */ #ifdef _SYSOBJ_INTERNAL #define SYSOBJ_DB_VERSION 1 #define SYSOBJDB_MAGIC_STR "#sysobjdb_bootstrap_1" #define SYSOBJDB_MAGIC_LEN 21 #define SYSOBJ_SCF_INSTANCE "svc:/system/sysobj:default" #define SYSOBJ_SCF_PRIVATE_PG "__private_start_ok__" int __sysobj_open_db(const char *dbpath, sysobjdb_open_t flags); int __sysobj_close_db(void); void *__sysobj_db_ptr(void); pthread_key_t __sysobj_chg_key(void); #endif #ifdef _SYSOBJ_DAEMON /* * Definitions for private sysobjd interfaces. These can also be used * by sysobjd plugins. */ /* * Commands for the plugin _init entry point. */ #define SYSOBJ_PLUGIN_DAEMON_INIT 0 /* * Commands for the plugin _adm entry point. */ #define SYSOBJ_PLUGIN_ADM_REGENAUX 0 #define SYSOBJ_PLUGIN_ADM_COMMAND 1 #define _PATH_SYSOBJ_PLUGINS "/usr/lib/sysobj/plugins" struct sysobjdb_priv_checks { int (*create)(ucred_t *__cred, const char *__class); int (*destroy)(ucred_t *__cred, sysobj_t __obj); int (*add_alias)(ucred_t *__cred, sysobj_t __obj, const char *__class, const char *__space, const char *__alias); int (*del_alias)(ucred_t *__cred, sysobj_t __obj, const char *__class, const char *__space, const char *__alias); int (*add_property)(ucred_t *__cred, sysobj_t __obj, const char *__propclass, const char *__propname, data_type_t __type, sysobj_propval_t *__value, size_t __nel); int (*del_property)(ucred_t *__cred, sysobj_t __obj, const char *__propclass, const char *__propname); int (*lookup)(ucred_t *__cred, sysobj_t __obj); int (*aliases)(ucred_t *__cred, sysobj_t __obj, nvlist_t *__nvl); int (*properties)(ucred_t *__cred, sysobj_t __obj, nvlist_t *__nvl); int (*classes)(ucred_t *__cred, sysobj_t __obj, char **__classes, size_t *__nclasses); int (*event_watch)(ucred_t *__cred, sysobj_t __obj, sysobj_event_mask_t __evtype, const char *__class); int (*event_notify)(ucred_t *__cred, sysobj_t __obj, sysobj_event_mask_t __evtype, nvlist_t *__nvl); int (*event_user)(ucred_t *__cred, const char *__class, const char *__evname); }; int sysobjdb_register_priv_checks(const char *__class, struct sysobjdb_priv_checks *__checks); int sysobjdb_unregister_priv_checks(const char *__class); int sysobjdb_command_register(const char *__cmd, int (*__f)(int __argc, char **__argv), const char **__usage); int sysobjdb_command_find(const char *__cmd, int (**__fp)(int __argc, char **__argv), const char ***__usagep); void sysobjdb_command_usage(void); int sysobjdb_register_exithook(void (*__func)(void), void **__cookiep); void sysobjdb_unregister_exithook(void *__cookie); void sysobjdb_get_state(char **__dbpathp, boolean_t *__dbrunning); int sysobjdb_register_event_hook(const char *__class, void (*__func)(ucred_t *, sysobj_t, sysobj_op_t, nvlist_t *), void **__cookiep); void sysobjdb_unregister_event_hook(void *__cookie); /* * Kernel event handling. */ int sysobjdb_kevent_add(sysobj_t __obj, nvlist_t *__nvl); int sysobjdb_kevent_get(nvlist_t **__nvlp); /* * Event hooks. */ void sysobjdb_event_init(void); int sysobjdb_catch_events(sysobjdb_chg_t *__chgp); void sysobjdb_drop_events(void); sysobjdb_chg_t sysobjdb_get_event(void); void sysobjdb_run_event_hooks(ucred_t *__ucred, sysobj_t __obj, sysobj_op_t __op, nvlist_t *__nvl); /* * Client event handling. */ int sysobjdb_ev_register(ucred_t *__cred, int __portfd, uint64_t __flags); int sysobjdb_ev_unregister(ucred_t *__cred); int sysobjdb_ev_watch(ucred_t *__cred, const char *__class, uint64_t __mask); int sysobjdb_ev_get_event(ucred_t *__cred, nvlist_t **__nvlp); void sysobjdb_event_fini(void); /* * Plugin handling. */ int sysobjdb_plugins_load(void); int sysobjdb_plugins_call_init(uintptr_t __arg, int __abortfail); int sysobjdb_plugins_call_adm(uintptr_t __arg, int __abortfail); /* * Simple hash table definitions. */ typedef struct sysobjdb_hash_entry { void *entry_match; void *entry_data; list_node_t entry_list; } sysobjdb_hash_entry_t; typedef struct sysobjdb_hash_bucket { pthread_mutex_t bucket_lock; list_t bucket_entries; } sysobjdb_hash_bucket_t; typedef struct sysobjdb_hash_table { const char *table_name; size_t table_size; volatile uint64_t table_nentries; int (*table_cmpf)(const void *, const void *); uint_t (*table_hashf)(struct sysobjdb_hash_table *, const void *); struct sysobjdb_hash_bucket *table_buckets; } sysobjdb_hash_table_t; #define HASH_OP_RETURN 0 #define HASH_OP_NEW 1 #define HASH_OP_DELETE 2 #define HASH_OP_CONT 3 sysobjdb_hash_table_t *sysobjdb_hash_create(const char *__name, size_t __size, int (*cmp)(const void *, const void *), uint_t (*hash)(sysobjdb_hash_table_t *, const void *)); int sysobjdb_hash_insert(sysobjdb_hash_table_t *__table, void *__str, void *__data); int sysobjdb_hash_remove(sysobjdb_hash_table_t *__table, void *__str); int sysobjdb_hash_find(sysobjdb_hash_table_t *__table, void *__str, void **__data); int sysobjdb_hash_walk(sysobjdb_hash_table_t *__table, int (*__cb)(void *, void *, int *, void *), void *__aux); int sysobjdb_hash_op(sysobjdb_hash_table_t *__table, void *__str, void **__data, int (*__cb)(void *, void **, void *, void **, int *, void *), void *__aux); uint64_t sysobjdb_hash_nentries(sysobjdb_hash_table_t *__table); void sysobjdb_set_rootpath(char *__root); /* * Other definitions. */ #define sysobjdb_primary_class(name) (name)->classes[0] void sysobjdb_free_string_array(char **__strs, size_t __nel); int sysobjdb_copy_string_array(char **__strs, char ***__dstrsp, size_t __n); void sysobjdb_free_objs(sysobj_t *__objs, size_t __nel); int sysobjdb_write_file(const char *__fname, mode_t __mode, char *__buf, size_t __buflen, int __isnvf); void sysobjdb_printf(int __level, const char *__fmt, ...); void sysobjdb_errmsg(int __error, char *cmd, char *__s); int sysobjdb_scf_init(void); void sysobjdb_scf_set_first_start(void); boolean_t sysobjdb_scf_get_smf_control(void); boolean_t sysobjdb_scf_get_smf_restart(void); void sysobjdb_set_boot_data_inconsistent(void); boolean_t sysobjdb_get_boot_data_inconsistent(void); #endif /* _SYSOBJ_DAEMON */ #ifdef __cplusplus } #endif #endif /* _SYSOBJ_H */