ReactOS 0.4.16-dev-336-gb667d82
Group.c
Go to the documentation of this file.
1/*
2 * PROJECT: Mke2fs
3 * FILE: Group.c
4 * PROGRAMMER: Matt Wu <mattwu@163.com>
5 * HOMEPAGE: http://ext2.yeah.net
6 */
7
8/* INCLUDES **************************************************************/
9
10#include "Mke2fs.h"
11
12/* DEFINITIONS ***********************************************************/
13
14/* FUNCTIONS *************************************************************/
15
16int test_root(int a, int b)
17{
18 if (a == 0)
19 return 1;
20 while (1)
21 {
22 if (a == 1)
23 return 1;
24 if (a % b)
25 return 0;
26 a = a / b;
27 }
28}
29
30bool ext2_bg_has_super(PEXT2_SUPER_BLOCK pExt2Sb, int group_block)
31{
32 if (!(pExt2Sb->s_feature_ro_compat & EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))
33 return true;
34
35 if (test_root(group_block, 3) || (test_root(group_block, 5)) ||
36 test_root(group_block, 7))
37 return true;
38
39 return false;
40}
41
42
44{
45 ULONG size;
46
47 size = Ext2Sys->desc_blocks * Ext2Sys->blocksize;
48
49 Ext2Sys->group_desc =
50 (PEXT2_GROUP_DESC)RtlAllocateHeap(RtlGetProcessHeap(), 0, size);
51
52 if (Ext2Sys->group_desc)
53 {
54 memset(Ext2Sys->group_desc, 0, size);
55 return true;
56 }
57
58 return false;
59}
60
62{
63 if (Ext2Sys->group_desc)
64 {
65 RtlFreeHeap(RtlGetProcessHeap(), 0, Ext2Sys->group_desc);
66 Ext2Sys->group_desc = NULL;
67 }
68}
void ext2_free_group_desc(PEXT2_FILESYS Ext2Sys)
Definition: Group.c:61
bool ext2_bg_has_super(PEXT2_SUPER_BLOCK pExt2Sb, int group_block)
Definition: Group.c:30
bool ext2_allocate_group_desc(PEXT2_FILESYS Ext2Sys)
Definition: Group.c:43
int test_root(int a, int b)
Definition: Group.c:16
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define NULL
Definition: types.h:112
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
Definition: ext2_fs.h:465
struct ext2_block_group * PEXT2_GROUP_DESC
Definition: ext2.h:173
GLsizeiptr size
Definition: glext.h:5919
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
#define memset(x, y, z)
Definition: compat.h:39
int blocksize
Definition: Mke2fs.h:154
unsigned long desc_blocks
Definition: Mke2fs.h:157
PEXT2_GROUP_DESC group_desc
Definition: Mke2fs.h:158
uint32_t ULONG
Definition: typedefs.h:59