zap_leaf.h revision fa9e4066f08beec538e775443c5be79dd423fcab
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_ZAP_LEAF_H
#define _SYS_ZAP_LEAF_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
struct zap;
#define ZAP_LEAF_MAGIC 0x2AB1EAF
/* chunk size = 24 bytes */
#define ZAP_LEAF_NUMCHUNKS 5118
#define ZAP_LEAF_ARRAY_BYTES 21
#define ZAP_LEAF_HASH_SHIFT 12
typedef enum zap_entry_type {
ZAP_LEAF_FREE = 253,
ZAP_LEAF_ENTRY = 252,
ZAP_LEAF_ARRAY = 251,
ZAP_LEAF_TYPE_MAX = 250
/*
* TAKE NOTE:
* If zap_leaf_phys_t is modified, zap_leaf_byteswap() must be modified.
*/
typedef struct zap_leaf_phys {
struct zap_leaf_header {
/* above is accessable to zap, below is zap_leaf private */
} l_hdr; /* 2 24-byte chunks */
/* 170 24-byte chunks plus 16 bytes leftover space */
union zap_leaf_chunk {
struct zap_leaf_entry {
} l_entry;
struct zap_leaf_array {
} l_array;
struct zap_leaf_free {
} l_free;
typedef struct zap_leaf {
} zap_leaf_t;
typedef struct zap_entry_handle {
/* below is set by zap_leaf.c and is public to zap.c */
/* below is private to zap_leaf.c */
/*
* Return a handle to the named entry, or ENOENT if not found. The hash
* value must equal zap_hash(name).
*/
extern int zap_leaf_lookup(zap_leaf_t *l,
/*
* Return a handle to the entry with this hash+cd, or the entry with the
* next closest hash+cd.
*/
extern int zap_leaf_lookup_closest(zap_leaf_t *l,
/*
* Read the first num_integers in the attribute. Integer size
* conversion will be done without sign extension. Return EINVAL if
* integer_size is too small. Return EOVERFLOW if there are more than
* num_integers in the attribute.
*/
/*
* Replace the value of an existing entry.
*
* zap_entry_update may fail if it runs out of space (ENOSPC).
*/
/*
* Remove an entry.
*/
/*
* Create an entry. An equal entry must not exist, and this entry must
* belong in this leaf (according to its hash value). Fills in the
* entry handle on success. Returns 0 on success or ENOSPC on failure.
*/
extern int zap_entry_create(zap_leaf_t *l,
/*
* Other stuff.
*/
extern void zap_leaf_init(zap_leaf_t *l);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_ZAP_LEAF_H */