/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2010, 2012 Zheng Liu <[email protected]>4* Copyright (c) 2012, Vyacheslav Matyushin5* All rights reserved.6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _FS_EXT2FS_HTREE_H_30#define _FS_EXT2FS_HTREE_H_3132/* EXT3 HTree directory indexing */3334#define EXT2_HTREE_LEGACY 035#define EXT2_HTREE_HALF_MD4 136#define EXT2_HTREE_TEA 237#define EXT2_HTREE_LEGACY_UNSIGNED 338#define EXT2_HTREE_HALF_MD4_UNSIGNED 439#define EXT2_HTREE_TEA_UNSIGNED 54041#define EXT2_HTREE_EOF 0x7FFFFFFF4243struct ext2fs_fake_direct {44uint32_t e2d_ino; /* inode number of entry */45uint16_t e2d_reclen; /* length of this record */46uint8_t e2d_namlen; /* length of string in d_name */47uint8_t e2d_type; /* file type */48};4950struct ext2fs_htree_count {51uint16_t h_entries_max;52uint16_t h_entries_num;53};5455struct ext2fs_htree_entry {56uint32_t h_hash;57uint32_t h_blk;58};5960/*61* This goes at the end of each htree block.62*/63struct ext2fs_htree_tail {64uint32_t ht_reserved;65uint32_t ht_checksum; /* crc32c(uuid+inum+dirblock) */66};6768struct ext2fs_htree_root_info {69uint32_t h_reserved1;70uint8_t h_hash_version;71uint8_t h_info_len;72uint8_t h_ind_levels;73uint8_t h_reserved2;74};7576struct ext2fs_htree_root {77struct ext2fs_fake_direct h_dot;78char h_dot_name[4];79struct ext2fs_fake_direct h_dotdot;80char h_dotdot_name[4];81struct ext2fs_htree_root_info h_info;82struct ext2fs_htree_entry h_entries[0];83};8485struct ext2fs_htree_node {86struct ext2fs_fake_direct h_fake_dirent;87struct ext2fs_htree_entry h_entries[0];88};8990struct ext2fs_htree_lookup_level {91struct buf *h_bp;92struct ext2fs_htree_entry *h_entries;93struct ext2fs_htree_entry *h_entry;94};9596struct ext2fs_htree_lookup_info {97struct ext2fs_htree_lookup_level h_levels[2];98uint32_t h_levels_num;99};100101struct ext2fs_htree_sort_entry {102uint16_t h_offset;103uint16_t h_size;104uint32_t h_hash;105};106107#endif /* !_FS_EXT2FS_HTREE_H_ */108109110