]>
git.ipfire.org Git - people/ms/u-boot.git/blob - include/zfs/zap_leaf.h
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
5 * SPDX-License-Identifier: GPL-2.0+
8 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
9 * Use is subject to license terms.
12 #ifndef _SYS_ZAP_LEAF_H
13 #define _SYS_ZAP_LEAF_H
15 #define ZAP_LEAF_MAGIC 0x2AB1EAF
17 /* chunk size = 24 bytes */
18 #define ZAP_LEAF_CHUNKSIZE 24
21 * The amount of space within the chunk available for the array is:
22 * chunk size - space for type (1) - space for next pointer (2)
24 #define ZAP_LEAF_ARRAY_BYTES (ZAP_LEAF_CHUNKSIZE - 3)
26 typedef enum zap_chunk_type
{
28 ZAP_CHUNK_ENTRY
= 252,
29 ZAP_CHUNK_ARRAY
= 251,
30 ZAP_CHUNK_TYPE_MAX
= 250
35 * If zap_leaf_phys_t is modified, zap_leaf_byteswap() must be modified.
37 typedef struct zap_leaf_phys
{
38 struct zap_leaf_header
{
39 uint64_t lh_block_type
; /* ZBT_LEAF */
41 uint64_t lh_prefix
; /* hash prefix of this leaf */
42 uint32_t lh_magic
; /* ZAP_LEAF_MAGIC */
43 uint16_t lh_nfree
; /* number free chunks */
44 uint16_t lh_nentries
; /* number of entries */
45 uint16_t lh_prefix_len
; /* num bits used to id this */
47 /* above is accessable to zap, below is zap_leaf private */
49 uint16_t lh_freelist
; /* chunk head of free list */
51 } l_hdr
; /* 2 24-byte chunks */
54 * The header is followed by a hash table with
55 * ZAP_LEAF_HASH_NUMENTRIES(zap) entries. The hash table is
56 * followed by an array of ZAP_LEAF_NUMCHUNKS(zap)
57 * zap_leaf_chunk structures. These structures are accessed
58 * with the ZAP_LEAF_CHUNK() macro.
64 typedef union zap_leaf_chunk
{
65 struct zap_leaf_entry
{
66 uint8_t le_type
; /* always ZAP_CHUNK_ENTRY */
67 uint8_t le_int_size
; /* size of ints */
68 uint16_t le_next
; /* next entry in hash chain */
69 uint16_t le_name_chunk
; /* first chunk of the name */
70 uint16_t le_name_length
; /* bytes in name, incl null */
71 uint16_t le_value_chunk
; /* first chunk of the value */
72 uint16_t le_value_length
; /* value length in ints */
73 uint32_t le_cd
; /* collision differentiator */
74 uint64_t le_hash
; /* hash value of the name */
76 struct zap_leaf_array
{
77 uint8_t la_type
; /* always ZAP_CHUNK_ARRAY */
79 uint8_t la_array
[ZAP_LEAF_ARRAY_BYTES
];
81 } __attribute__ ((packed
));
82 uint16_t la_next
; /* next blk or CHAIN_END */
84 struct zap_leaf_free
{
85 uint8_t lf_type
; /* always ZAP_CHUNK_FREE */
86 uint8_t lf_pad
[ZAP_LEAF_ARRAY_BYTES
];
87 uint16_t lf_next
; /* next in free list, or CHAIN_END */
91 #endif /* _SYS_ZAP_LEAF_H */