source: mainline/uspace/lib/ext4/libext4_extent.h@ 1a7756a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 1a7756a was 1a7756a, checked in by Frantisek Princ <frantisek.princ@…>, 14 years ago

support for reading more complex extents (tree with nonzero depth)

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * Copyright (c) 2011 Frantisek Princ
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libext4
30 * @{
31 */
32
33#ifndef LIBEXT4_LIBEXT4_EXTENT_H_
34#define LIBEXT4_LIBEXT4_EXTENT_H_
35
36/*
37 * This is the extent on-disk structure.
38 * It's used at the bottom of the tree.
39 */
40typedef struct ext4_extent {
41 uint32_t first_block; // First logical block extent covers
42 uint16_t block_count; // Number of blocks covered by extent
43 uint16_t start_hi; // High 16 bits of physical block
44 uint32_t start_lo; // Low 32 bits of physical block
45} ext4_extent_t;
46
47/*
48 * This is index on-disk structure.
49 * It's used at all the levels except the bottom.
50 */
51typedef struct ext4_extent_index {
52 uint32_t first_block; // Index covers logical blocks from 'block'
53 uint32_t leaf_lo; /* Pointer to the physical block of the next
54 * level. leaf or next index could be there */
55 uint16_t leaf_hi; /* high 16 bits of physical block */
56 uint16_t padding;
57} ext4_extent_index_t;
58
59/*
60 * Each block (leaves and indexes), even inode-stored has header.
61 */
62typedef struct ext4_extent_header {
63 uint16_t magic;
64 uint16_t entries_count; // Number of valid entries
65 uint16_t max_entries_count; // Capacity of store in entries
66 uint16_t depth; // Has tree real underlying blocks?
67 uint32_t generation; // generation of the tree
68} ext4_extent_header_t;
69
70#define EXT4_EXTENT_MAGIC 0xF30A
71#define EXT4_EXTENT_FIRST(header) \
72 ((ext4_extent_t *) (((void *) (header)) + sizeof(ext4_extent_header_t)))
73#define EXT4_EXTENT_FIRST_INDEX(header) \
74 ((ext4_extent_index_t *) (((void *) (header)) + sizeof(ext4_extent_header_t)))
75
76extern uint32_t ext4_extent_get_first_block(ext4_extent_t *);
77extern uint16_t ext4_extent_get_block_count(ext4_extent_t *);
78extern uint64_t ext4_extent_get_start(ext4_extent_t *);
79
80extern uint32_t ext4_extent_index_get_first_block(ext4_extent_index_t *);
81extern uint64_t ext4_extent_index_get_leaf(ext4_extent_index_t *);
82
83extern uint16_t ext4_extent_header_get_magic(ext4_extent_header_t *);
84extern uint16_t ext4_extent_header_get_entries_count(ext4_extent_header_t *);
85extern uint16_t ext4_extent_header_get_max_entries_count(ext4_extent_header_t *);
86extern uint16_t ext4_extent_header_get_depth(ext4_extent_header_t *);
87extern uint32_t ext4_extent_header_get_generation(ext4_extent_header_t *);
88
89#endif
90
91/**
92 * @}
93 */
Note: See TracBrowser for help on using the repository browser.