VirtualBox

source: vbox/trunk/include/iprt/formats/ext2.h@ 73886

Last change on this file since 73886 was 69840, checked in by vboxsync, 7 years ago

IPRT: VFS volume mouning cleanup, replacing RTFilesystemVfsFromFile with RTVfsMountVol.

  • RTVfsMountVol will do basic file system recognizion and call the right file system volume open API.
  • Moved ext2 definitions to iprt/formats/ext2.h, dropping unnecessary pragma pack(1) and adjusted names.
  • Added RTFsExt2VolOpen.
  • Removed iprt/filesystem.h.
  • Removed include/internal/filesystem.h.
  • Nothing has been tested yet! :-)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: ext2.h 69840 2017-11-27 15:19:30Z vboxsync $ */
2/** @file
3 * IPRT Filesystem API (FileSys) - ext2/3 format.
4 */
5
6/*
7 * Copyright (C) 2012-2017 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_ext2_h
28#define ___iprt_formats_ext2_h
29
30#include <iprt/types.h>
31#include <iprt/assertcompile.h>
32
33
34/*
35 * The filesystem structures are from http://wiki.osdev.org/Ext2 and
36 * http://www.nongnu.org/ext2-doc/ext2.html
37 */
38
39/**
40 * Ext2 superblock.
41 *
42 * Everything is stored little endian on the disk.
43 */
44typedef struct EXT2SUPERBLOCK
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} EXT2SUPERBLOCK;
99AssertCompileSize(EXT2SUPERBLOCK, 1024);
100/** Pointer to an ext2 super block. */
101typedef EXT2SUPERBLOCK *PEXT2SUPERBLOCK;
102/** Pointer to a const ext2 super block. */
103typedef EXT2SUPERBLOCK const *PCEXT2SUPERBLOCK;
104
105/** Ext2 signature. */
106#define EXT2_SIGNATURE UINT16_C(0xef53)
107/** Clean filesystem state. */
108#define EXT2_STATE_CLEAN UINT16_C(0x0001)
109/** Error filesystem state. */
110#define EXT2_STATE_ERRORS UINT16_C(0x0002)
111
112/**
113 * Block group descriptor.
114 */
115typedef struct EXT2BLOCKGROUPDESC
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} EXT2BLOCKGROUPDESC;
134AssertCompileSize(EXT2BLOCKGROUPDESC, 32);
135/** Pointer to an ext block group descriptor. */
136typedef EXT2BLOCKGROUPDESC *PEXT2BLOCKGROUPDESC;
137
138#endif
139
Note: See TracBrowser for help on using the repository browser.

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