source: mainline/uspace/lib/ext2/libext2_superblock.h@ 15f3c3f

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 15f3c3f was 15f3c3f, checked in by Jiri Svoboda <jiri@…>, 14 years ago

Rename devmap to loc, devfs to locfs.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 * Copyright (c) 2011 Martin Sucha
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 libext2
30 * @{
31 */
32/**
33 * @file
34 */
35
36#ifndef LIBEXT2_LIBEXT2_SUPERBLOCK_H_
37#define LIBEXT2_LIBEXT2_SUPERBLOCK_H_
38
39#include <libblock.h>
40
41typedef struct ext2_superblock {
42 uint32_t total_inode_count; // Total number of inodes
43 uint32_t total_block_count; // Total number of blocks
44 uint32_t reserved_block_count; // Total number of reserved blocks
45 uint32_t free_block_count; // Total number of free blocks
46 uint32_t free_inode_count; // Total number of free inodes
47 uint32_t first_block; // Block containing the superblock (either 0 or 1)
48 uint32_t block_size_log2; // log_2(block_size)
49 int32_t fragment_size_log2; // log_2(fragment size)
50 uint32_t blocks_per_group; // Number of blocks in one block group
51 uint32_t fragments_per_group; // Number of fragments per block group
52 uint32_t inodes_per_group; // Number of inodes per block group
53 uint8_t unused2[12];
54 uint16_t magic; // Magic value
55 uint16_t state; // State (mounted/unmounted)
56 uint16_t error_behavior; // What to do when errors are encountered
57 uint16_t rev_minor; // Minor revision level
58 uint8_t unused3[8];
59 uint32_t os; // OS that created the filesystem
60 uint32_t rev_major; // Major revision level
61 uint8_t unused4[4];
62
63 // Following is for ext2 revision 1 only
64 uint32_t first_inode;
65 uint16_t inode_size;
66 uint16_t unused5;
67 uint32_t features_compatible;
68 uint32_t features_incompatible;
69 uint32_t features_read_only;
70 uint8_t uuid[16]; // UUID TODO: Create a library for UUIDs
71 uint8_t volume_name[16];
72
73// TODO: add __attribute__((aligned(...)) for better performance?
74// (it is necessary to ensure the superblock is correctly aligned then
75// though)
76} __attribute__ ((packed)) ext2_superblock_t;
77
78#define EXT2_SUPERBLOCK_MAGIC 0xEF53
79#define EXT2_SUPERBLOCK_SIZE 1024
80#define EXT2_SUPERBLOCK_OFFSET 1024
81#define EXT2_SUPERBLOCK_LAST_BYTE (EXT2_SUPERBLOCK_OFFSET + \
82 EXT2_SUPERBLOCK_SIZE -1)
83#define EXT2_SUPERBLOCK_OS_LINUX 0
84#define EXT2_SUPERBLOCK_OS_HURD 1
85
86
87extern uint16_t ext2_superblock_get_magic(ext2_superblock_t *);
88extern uint32_t ext2_superblock_get_first_block(ext2_superblock_t *);
89extern uint32_t ext2_superblock_get_block_size_log2(ext2_superblock_t *);
90extern uint32_t ext2_superblock_get_block_size(ext2_superblock_t *);
91extern int32_t ext2_superblock_get_fragment_size_log2(ext2_superblock_t *);
92extern uint32_t ext2_superblock_get_fragment_size(ext2_superblock_t *);
93extern uint32_t ext2_superblock_get_blocks_per_group(ext2_superblock_t *);
94extern uint32_t ext2_superblock_get_fragments_per_group(ext2_superblock_t *);
95extern uint16_t ext2_superblock_get_state(ext2_superblock_t *);
96extern uint16_t ext2_superblock_get_rev_minor(ext2_superblock_t *);
97extern uint32_t ext2_superblock_get_rev_major(ext2_superblock_t *);
98extern uint32_t ext2_superblock_get_os(ext2_superblock_t *);
99extern uint32_t ext2_superblock_get_first_inode(ext2_superblock_t *);
100extern uint16_t ext2_superblock_get_inode_size(ext2_superblock_t *);
101extern uint32_t ext2_superblock_get_total_inode_count(ext2_superblock_t *);
102extern uint32_t ext2_superblock_get_total_block_count(ext2_superblock_t *);
103extern uint32_t ext2_superblock_get_reserved_block_count(ext2_superblock_t *);
104extern uint32_t ext2_superblock_get_free_block_count(ext2_superblock_t *);
105extern uint32_t ext2_superblock_get_free_inode_count(ext2_superblock_t *);
106extern uint32_t ext2_superblock_get_block_group_count(ext2_superblock_t *);
107extern uint32_t ext2_superblock_get_inodes_per_group(ext2_superblock_t *);
108extern uint32_t ext2_superblock_get_features_compatible(ext2_superblock_t *);
109extern uint32_t ext2_superblock_get_features_incompatible(ext2_superblock_t *);
110extern uint32_t ext2_superblock_get_features_read_only(ext2_superblock_t *);
111
112extern int ext2_superblock_read_direct(service_id_t, ext2_superblock_t **);
113extern int ext2_superblock_check_sanity(ext2_superblock_t *);
114
115#endif
116
117/** @}
118 */
Note: See TracBrowser for help on using the repository browser.