htree.h revision 252890
1252890Spfg/*- 2252890Spfg * Copyright (c) 2010, 2012 Zheng Liu <lz@freebsd.org> 3252890Spfg * Copyright (c) 2012, Vyacheslav Matyushin 4252890Spfg * All rights reserved. 5252890Spfg * 6252890Spfg * Redistribution and use in source and binary forms, with or without 7252890Spfg * modification, are permitted provided that the following conditions 8252890Spfg * are met: 9252890Spfg * 1. Redistributions of source code must retain the above copyright 10252890Spfg * notice, this list of conditions and the following disclaimer. 11252890Spfg * 2. Redistributions in binary form must reproduce the above copyright 12252890Spfg * notice, this list of conditions and the following disclaimer in the 13252890Spfg * documentation and/or other materials provided with the distribution. 14252890Spfg * 15252890Spfg * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 16252890Spfg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17252890Spfg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18252890Spfg * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 19252890Spfg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20252890Spfg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21252890Spfg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22252890Spfg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23252890Spfg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24252890Spfg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25252890Spfg * SUCH DAMAGE. 26252890Spfg * 27252890Spfg * $FreeBSD: head/sys/fs/ext2fs/htree.h 252890 2013-07-06 18:28:06Z pfg $ 28252890Spfg */ 29252890Spfg 30252890Spfg#ifndef _FS_EXT2FS_HTREE_H_ 31252890Spfg#define _FS_EXT2FS_HTREE_H_ 32252890Spfg 33252890Spfg/* EXT3 HTree directory indexing */ 34252890Spfg 35252890Spfg#define EXT2_HTREE_LEGACY 0 36252890Spfg#define EXT2_HTREE_HALF_MD4 1 37252890Spfg#define EXT2_HTREE_TEA 2 38252890Spfg#define EXT2_HTREE_LEGACY_UNSIGNED 3 39252890Spfg#define EXT2_HTREE_HALF_MD4_UNSIGNED 4 40252890Spfg#define EXT2_HTREE_TEA_UNSIGNED 5 41252890Spfg 42252890Spfg#define EXT2_HTREE_EOF 0x7FFFFFFF 43252890Spfg 44252890Spfgstruct ext2fs_fake_direct { 45252890Spfg uint32_t e2d_ino; /* inode number of entry */ 46252890Spfg uint16_t e2d_reclen; /* length of this record */ 47252890Spfg uint8_t e2d_namlen; /* length of string in d_name */ 48252890Spfg uint8_t e2d_type; /* file type */ 49252890Spfg}; 50252890Spfg 51252890Spfgstruct ext2fs_htree_count { 52252890Spfg uint16_t h_entries_max; 53252890Spfg uint16_t h_entries_num; 54252890Spfg}; 55252890Spfg 56252890Spfgstruct ext2fs_htree_entry { 57252890Spfg uint32_t h_hash; 58252890Spfg uint32_t h_blk; 59252890Spfg}; 60252890Spfg 61252890Spfgstruct ext2fs_htree_root_info { 62252890Spfg uint32_t h_reserved1; 63252890Spfg uint8_t h_hash_version; 64252890Spfg uint8_t h_info_len; 65252890Spfg uint8_t h_ind_levels; 66252890Spfg uint8_t h_reserved2; 67252890Spfg}; 68252890Spfg 69252890Spfgstruct ext2fs_htree_root { 70252890Spfg struct ext2fs_fake_direct h_dot; 71252890Spfg char h_dot_name[4]; 72252890Spfg struct ext2fs_fake_direct h_dotdot; 73252890Spfg char h_dotdot_name[4]; 74252890Spfg struct ext2fs_htree_root_info h_info; 75252890Spfg struct ext2fs_htree_entry h_entries[0]; 76252890Spfg}; 77252890Spfg 78252890Spfgstruct ext2fs_htree_node { 79252890Spfg struct ext2fs_fake_direct h_fake_dirent; 80252890Spfg struct ext2fs_htree_entry h_entries[0]; 81252890Spfg}; 82252890Spfg 83252890Spfgstruct ext2fs_htree_lookup_level { 84252890Spfg struct buf *h_bp; 85252890Spfg struct ext2fs_htree_entry *h_entries; 86252890Spfg struct ext2fs_htree_entry *h_entry; 87252890Spfg}; 88252890Spfg 89252890Spfgstruct ext2fs_htree_lookup_info { 90252890Spfg struct ext2fs_htree_lookup_level h_levels[2]; 91252890Spfg uint32_t h_levels_num; 92252890Spfg}; 93252890Spfg 94252890Spfgstruct ext2fs_htree_sort_entry { 95252890Spfg uint16_t h_offset; 96252890Spfg uint16_t h_size; 97252890Spfg uint32_t h_hash; 98252890Spfg}; 99252890Spfg 100252890Spfg#endif /* !_FS_EXT2FS_HTREE_H_ */ 101