191f5a467SPedro F. Giffuni /*- 2*d63027b6SPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*d63027b6SPedro F. Giffuni * 491f5a467SPedro F. Giffuni * Copyright (c) 2010, 2012 Zheng Liu <lz@freebsd.org> 591f5a467SPedro F. Giffuni * Copyright (c) 2012, Vyacheslav Matyushin 691f5a467SPedro F. Giffuni * All rights reserved. 791f5a467SPedro F. Giffuni * 891f5a467SPedro F. Giffuni * Redistribution and use in source and binary forms, with or without 991f5a467SPedro F. Giffuni * modification, are permitted provided that the following conditions 1091f5a467SPedro F. Giffuni * are met: 1191f5a467SPedro F. Giffuni * 1. Redistributions of source code must retain the above copyright 1291f5a467SPedro F. Giffuni * notice, this list of conditions and the following disclaimer. 1391f5a467SPedro F. Giffuni * 2. Redistributions in binary form must reproduce the above copyright 1491f5a467SPedro F. Giffuni * notice, this list of conditions and the following disclaimer in the 1591f5a467SPedro F. Giffuni * documentation and/or other materials provided with the distribution. 1691f5a467SPedro F. Giffuni * 1791f5a467SPedro F. Giffuni * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1891f5a467SPedro F. Giffuni * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1991f5a467SPedro F. Giffuni * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2091f5a467SPedro F. Giffuni * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2191f5a467SPedro F. Giffuni * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2291f5a467SPedro F. Giffuni * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2391f5a467SPedro F. Giffuni * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2491f5a467SPedro F. Giffuni * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2591f5a467SPedro F. Giffuni * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2691f5a467SPedro F. Giffuni * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2791f5a467SPedro F. Giffuni * SUCH DAMAGE. 2891f5a467SPedro F. Giffuni * 2991f5a467SPedro F. Giffuni * $FreeBSD$ 3091f5a467SPedro F. Giffuni */ 3191f5a467SPedro F. Giffuni 3291f5a467SPedro F. Giffuni #ifndef _FS_EXT2FS_HTREE_H_ 3391f5a467SPedro F. Giffuni #define _FS_EXT2FS_HTREE_H_ 3491f5a467SPedro F. Giffuni 3591f5a467SPedro F. Giffuni /* EXT3 HTree directory indexing */ 3691f5a467SPedro F. Giffuni 3791f5a467SPedro F. Giffuni #define EXT2_HTREE_LEGACY 0 3891f5a467SPedro F. Giffuni #define EXT2_HTREE_HALF_MD4 1 3991f5a467SPedro F. Giffuni #define EXT2_HTREE_TEA 2 4091f5a467SPedro F. Giffuni #define EXT2_HTREE_LEGACY_UNSIGNED 3 4191f5a467SPedro F. Giffuni #define EXT2_HTREE_HALF_MD4_UNSIGNED 4 4291f5a467SPedro F. Giffuni #define EXT2_HTREE_TEA_UNSIGNED 5 4391f5a467SPedro F. Giffuni 4491f5a467SPedro F. Giffuni #define EXT2_HTREE_EOF 0x7FFFFFFF 4591f5a467SPedro F. Giffuni 4691f5a467SPedro F. Giffuni struct ext2fs_fake_direct { 4791f5a467SPedro F. Giffuni uint32_t e2d_ino; /* inode number of entry */ 4891f5a467SPedro F. Giffuni uint16_t e2d_reclen; /* length of this record */ 4991f5a467SPedro F. Giffuni uint8_t e2d_namlen; /* length of string in d_name */ 5091f5a467SPedro F. Giffuni uint8_t e2d_type; /* file type */ 5191f5a467SPedro F. Giffuni }; 5291f5a467SPedro F. Giffuni 5391f5a467SPedro F. Giffuni struct ext2fs_htree_count { 5491f5a467SPedro F. Giffuni uint16_t h_entries_max; 5591f5a467SPedro F. Giffuni uint16_t h_entries_num; 5691f5a467SPedro F. Giffuni }; 5791f5a467SPedro F. Giffuni 5891f5a467SPedro F. Giffuni struct ext2fs_htree_entry { 5991f5a467SPedro F. Giffuni uint32_t h_hash; 6091f5a467SPedro F. Giffuni uint32_t h_blk; 6191f5a467SPedro F. Giffuni }; 6291f5a467SPedro F. Giffuni 6391f5a467SPedro F. Giffuni struct ext2fs_htree_root_info { 6491f5a467SPedro F. Giffuni uint32_t h_reserved1; 6591f5a467SPedro F. Giffuni uint8_t h_hash_version; 6691f5a467SPedro F. Giffuni uint8_t h_info_len; 6791f5a467SPedro F. Giffuni uint8_t h_ind_levels; 6891f5a467SPedro F. Giffuni uint8_t h_reserved2; 6991f5a467SPedro F. Giffuni }; 7091f5a467SPedro F. Giffuni 7191f5a467SPedro F. Giffuni struct ext2fs_htree_root { 7291f5a467SPedro F. Giffuni struct ext2fs_fake_direct h_dot; 7391f5a467SPedro F. Giffuni char h_dot_name[4]; 7491f5a467SPedro F. Giffuni struct ext2fs_fake_direct h_dotdot; 7591f5a467SPedro F. Giffuni char h_dotdot_name[4]; 7691f5a467SPedro F. Giffuni struct ext2fs_htree_root_info h_info; 7791f5a467SPedro F. Giffuni struct ext2fs_htree_entry h_entries[0]; 7891f5a467SPedro F. Giffuni }; 7991f5a467SPedro F. Giffuni 8091f5a467SPedro F. Giffuni struct ext2fs_htree_node { 8191f5a467SPedro F. Giffuni struct ext2fs_fake_direct h_fake_dirent; 8291f5a467SPedro F. Giffuni struct ext2fs_htree_entry h_entries[0]; 8391f5a467SPedro F. Giffuni }; 8491f5a467SPedro F. Giffuni 8591f5a467SPedro F. Giffuni struct ext2fs_htree_lookup_level { 8691f5a467SPedro F. Giffuni struct buf *h_bp; 8791f5a467SPedro F. Giffuni struct ext2fs_htree_entry *h_entries; 8891f5a467SPedro F. Giffuni struct ext2fs_htree_entry *h_entry; 8991f5a467SPedro F. Giffuni }; 9091f5a467SPedro F. Giffuni 9191f5a467SPedro F. Giffuni struct ext2fs_htree_lookup_info { 9291f5a467SPedro F. Giffuni struct ext2fs_htree_lookup_level h_levels[2]; 9391f5a467SPedro F. Giffuni uint32_t h_levels_num; 9491f5a467SPedro F. Giffuni }; 9591f5a467SPedro F. Giffuni 9691f5a467SPedro F. Giffuni struct ext2fs_htree_sort_entry { 9791f5a467SPedro F. Giffuni uint16_t h_offset; 9891f5a467SPedro F. Giffuni uint16_t h_size; 9991f5a467SPedro F. Giffuni uint32_t h_hash; 10091f5a467SPedro F. Giffuni }; 10191f5a467SPedro F. Giffuni 10291f5a467SPedro F. Giffuni #endif /* !_FS_EXT2FS_HTREE_H_ */ 103