2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _LOWLEVEL_IMPL_H
2N/A#define _LOWLEVEL_IMPL_H
2N/A
2N/A#include "libscf_impl.h"
2N/A
2N/A#include <door.h>
2N/A#include <libuutil.h>
2N/A#include <limits.h>
2N/A#include <pthread.h>
2N/A#include <stddef.h>
2N/A
2N/A#include "repcache_protocol.h"
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/Atypedef struct scf_datael {
2N/A scf_handle_t *rd_handle;
2N/A uint32_t rd_entity;
2N/A uint32_t rd_type;
2N/A uint32_t rd_reset;
2N/A uu_list_node_t rd_node;
2N/A} scf_datael_t;
2N/A#define DATAEL_VALID 0x0001
2N/A
2N/A/*
2N/A * Handle structure.
2N/A *
2N/A * Access to handles is serialized -- access to and modification of a handle
2N/A * and all of its children is protected by rh_lock.
2N/A *
2N/A * Different handles don't interfere with each other.
2N/A */
2N/Astruct scf_handle {
2N/A pthread_mutex_t rh_lock;
2N/A pthread_cond_t rh_cv;
2N/A
2N/A uint32_t rh_nextiter;
2N/A uint32_t rh_nextentity;
2N/A uint32_t rh_nextchangeid;
2N/A
2N/A int rh_doorfd;
2N/A int rh_doorfd_old; /* fd to close once rh_fd_users == 0 */
2N/A door_id_t rh_doorid;
2N/A pid_t rh_doorpid; /* pid at bind time */
2N/A
2N/A uid_t rh_uid;
2N/A uint32_t rh_debug;
2N/A uint32_t rh_show_masked;
2N/A uint32_t rh_flags; /* HANDLE_*, below */
2N/A uint32_t rh_fd_users; /* non-locked users of rh_doorfd */
2N/A
2N/A uu_list_t *rh_dataels;
2N/A uu_list_t *rh_iters;
2N/A long rh_entries;
2N/A long rh_values;
2N/A
2N/A long rh_extrefs; /* user-created subhandle count */
2N/A long rh_intrefs; /* handle-internal subhandle count */
2N/A
2N/A char rh_doorpath[PATH_MAX + 1];
2N/A
2N/A pthread_t rh_holder; /* thread using subhandles */
2N/A uint32_t rh_hold_flags; /* which are in use */
2N/A
2N/A scf_iter_t *rh_iter;
2N/A scf_scope_t *rh_scope;
2N/A scf_service_t *rh_service;
2N/A scf_instance_t *rh_instance;
2N/A scf_snapshot_t *rh_snapshot;
2N/A scf_snaplevel_t *rh_snaplvl;
2N/A scf_propertygroup_t *rh_pg;
2N/A scf_property_t *rh_property;
2N/A scf_value_t *rh_value;
2N/A};
2N/A#define HANDLE_DEAD 0x0001
2N/A#define HANDLE_UNREFED 0x0002
2N/A#define HANDLE_WRAPPED_ENTITY 0x0004
2N/A#define HANDLE_WRAPPED_ITER 0x0008
2N/A
2N/A#define RH_HOLD_ITER 0x0001
2N/A#define RH_HOLD_SCOPE 0x0002
2N/A#define RH_HOLD_SERVICE 0x0004
2N/A#define RH_HOLD_INSTANCE 0x0008
2N/A#define RH_HOLD_SNAPSHOT 0x0010
2N/A#define RH_HOLD_SNAPLVL 0x0020
2N/A#define RH_HOLD_PG 0x0040
2N/A#define RH_HOLD_PROPERTY 0x0080
2N/A#define RH_HOLD_VALUE 0x0100
2N/A
2N/A#define RH_HOLD_ALL 0x01ff
2N/A
2N/Astruct scf_scope {
2N/A scf_datael_t rd_d;
2N/A};
2N/A
2N/Astruct scf_service {
2N/A scf_datael_t rd_d;
2N/A};
2N/A
2N/Astruct scf_instance {
2N/A scf_datael_t rd_d;
2N/A};
2N/A
2N/Astruct scf_snapshot {
2N/A scf_datael_t rd_d;
2N/A};
2N/A
2N/A/*
2N/A * note: be careful of adding more state here -- snaplevel_next() relies on
2N/A * the fact that the entityid is the only library-level state.
2N/A */
2N/Astruct scf_snaplevel {
2N/A scf_datael_t rd_d;
2N/A};
2N/A
2N/Astruct scf_propertygroup {
2N/A scf_datael_t rd_d;
2N/A};
2N/A
2N/Astruct scf_property {
2N/A scf_datael_t rd_d;
2N/A};
2N/A
2N/Astruct scf_decoration {
2N/A scf_datael_t rd_d;
2N/A};
2N/A
2N/Astruct scf_value {
2N/A scf_handle_t *value_handle;
2N/A scf_value_t *value_next;
2N/A scf_transaction_entry_t *value_tx;
2N/A
2N/A rep_protocol_value_type_t value_type;
2N/A size_t value_size; /* only for opaque values */
2N/A char value_value[REP_PROTOCOL_VALUE_LEN];
2N/A};
2N/A
2N/Aenum scf_entry_state {
2N/A ENTRY_STATE_INVALID,
2N/A ENTRY_STATE_IN_TX_ACTION
2N/A};
2N/Astruct scf_transaction_entry {
2N/A const char *entry_property;
2N/A scf_handle_t *entry_handle;
2N/A scf_transaction_t *entry_tx;
2N/A enum scf_entry_state entry_state;
2N/A uu_list_node_t entry_link; /* for property name list */
2N/A
2N/A scf_value_t *entry_head;
2N/A scf_value_t *entry_tail; /* for linked values */
2N/A
2N/A enum rep_protocol_transaction_action entry_action;
2N/A rep_protocol_value_type_t entry_type;
2N/A char entry_namebuf[REP_PROTOCOL_NAME_LEN];
2N/A};
2N/A
2N/Aenum scf_tx_state {
2N/A TRAN_STATE_NEW,
2N/A TRAN_STATE_SETUP,
2N/A TRAN_STATE_COMMITTED
2N/A};
2N/A
2N/Astruct scf_transaction {
2N/A enum scf_tx_state tran_state;
2N/A scf_propertygroup_t tran_pg;
2N/A char *tran_pg_type;
2N/A uint32_t tran_pg_flags;
2N/A enum rep_protocol_requestid tran_pg_action;
2N/A int tran_invalid;
2N/A uu_list_t *tran_props;
2N/A};
2N/A
2N/Astruct scf_iter {
2N/A scf_handle_t *iter_handle;
2N/A int iter_type;
2N/A uint32_t iter_id;
2N/A uint32_t iter_sequence;
2N/A uu_list_node_t iter_node;
2N/A};
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _LOWLEVEL_IMPL_H */