VirtualBox

source: vbox/trunk/include/iprt/formats/ext.h@ 76216

Last change on this file since 76216 was 76216, checked in by vboxsync, 6 years ago

Runtime/fs: Started restructurin the ext2 filesystem code to indicate that it will be used for ext3/ext4 later on

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: ext.h 76216 2018-12-13 19:26:25Z vboxsync $ */
2/** @file
3 * IPRT, Ext2/3/4 format.
4 */
5
6/*
7 * Copyright (C) 2012-2018 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___iprt_formats_ext_h
28#define ___iprt_formats_ext_h
29
30#include <iprt/types.h>
31#include <iprt/assertcompile.h>
32
33
34/*
35 * The filesystem structures were retrieved from:
36 * https://www.kernel.org/doc/html/latest/filesystems/ext4/index.html
37 */
38
39/**
40 * Ext superblock.
41 *
42 * Everything is stored little endian on the disk.
43 */
44typedef struct EXTSUPERBLOCK
45{
46 /** Total number of inodes in the filesystem. */
47 uint32_t cInodesTotal;
48 /** Total number of blocks in the filesystem. */
49 uint32_t cBlocksTotal;
50 /** Number of blocks reserved for the super user. */
51 uint32_t cBlocksRsvdForSuperUser;
52 /** Total number of unallocated blocks. */
53 uint32_t cBlocksUnallocated;
54 /** Total number of unallocated inodes. */
55 uint32_t cInodesUnallocated;
56 /** Block number of block containing the superblock. */
57 uint32_t iBlockOfSuperblock;
58 /** Number of bits to shift 1024 to the left to get the block size */
59 uint32_t cBitsShiftLeftBlockSize;
60 /** Number of bits to shift 1024 to the left to get the fragment size */
61 uint32_t cBitsShiftLeftFragmentSize;
62 /** Number of blocks in each block group. */
63 uint32_t cBlocksPerGroup;
64 /** Number of fragments in each block group. */
65 uint32_t cFragmentsPerBlockGroup;
66 /** Number of inodes in each block group. */
67 uint32_t cInodesPerBlockGroup;
68 /** Last mount time. */
69 uint32_t u32LastMountTime;
70 /** Last written time. */
71 uint32_t u32LastWrittenTime;
72 /** Number of times the volume was mounted since the last check. */
73 uint16_t cMountsSinceLastCheck;
74 /** Number of mounts allowed before a consistency check. */
75 uint16_t cMaxMountsUntilCheck;
76 /** Signature to identify a ext2 volume (EXT2_SIGNATURE). */
77 uint16_t u16Signature;
78 /** State of the filesystem (clean/errors) */
79 uint16_t u16FilesystemState;
80 /** What to do on an error. */
81 uint16_t u16ActionOnError;
82 /** Minor version field. */
83 uint16_t u16VersionMinor;
84 /** Time of last check. */
85 uint32_t u32LastCheckTime;
86 /** Interval between consistency checks. */
87 uint32_t u32CheckInterval;
88 /** Operating system ID of the filesystem creator. */
89 uint32_t u32OsIdCreator;
90 /** Major version field. */
91 uint32_t u32VersionMajor;
92 /** User ID that is allowed to use reserved blocks. */
93 uint16_t u16UidReservedBlocks;
94 /** Group ID that is allowed to use reserved blocks. */
95 uint16_t u16GidReservedBlocks;
96 /** Reserved fields. */
97 uint8_t abReserved[940];
98} EXTSUPERBLOCK;
99AssertCompileSize(EXTSUPERBLOCK, 1024);
100/** Pointer to an ext super block. */
101typedef EXTSUPERBLOCK *PEXTSUPERBLOCK;
102/** Pointer to a const ext super block. */
103typedef EXTSUPERBLOCK const *PCEXTSUPERBLOCK;
104
105/** Ext signature. */
106#define EXT_SIGNATURE UINT16_C(0xef53)
107/** Clean filesystem state. */
108#define EXT_STATE_CLEAN UINT16_C(0x0001)
109/** Error filesystem state. */
110#define EXT_STATE_ERRORS UINT16_C(0x0002)
111
112/**
113 * Block group descriptor.
114 */
115typedef struct EXTBLOCKGROUPDESC
116{
117 /** Block address of the block bitmap. */
118 uint32_t offBlockBitmap;
119 /** Block address of the inode bitmap. */
120 uint32_t offInodeBitmap;
121 /** Start block address of the inode table. */
122 uint32_t offInodeTable;
123 /** Number of unallocated blocks in group. */
124 uint16_t cBlocksUnallocated;
125 /** Number of unallocated inodes in group. */
126 uint16_t cInodesUnallocated;
127 /** Number of directories in the group. */
128 uint16_t cDirectories;
129 /** Padding. */
130 uint16_t u16Padding;
131 /** Reserved. */
132 uint8_t abReserved[12];
133} EXTBLOCKGROUPDESC;
134AssertCompileSize(EXTBLOCKGROUPDESC, 32);
135/** Pointer to an ext block group descriptor. */
136typedef EXTBLOCKGROUPDESC *PEXTBLOCKGROUPDESC;
137
138#endif
139
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette