ReactOS  0.4.14-dev-552-g2fad488
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 
16 int 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 
30 bool 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 }
int blocksize
Definition: Mke2fs.h:154
bool ext2_allocate_group_desc(PEXT2_FILESYS Ext2Sys)
Definition: Group.c:43
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
struct ext2_block_group * PEXT2_GROUP_DESC
Definition: ext2.h:173
PEXT2_GROUP_DESC group_desc
Definition: Mke2fs.h:158
smooth NULL
Definition: ftsmooth.c:416
#define b
Definition: ke_i.h:79
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLsizeiptr size
Definition: glext.h:5919
unsigned long desc_blocks
Definition: Mke2fs.h:157
int test_root(int a, int b)
Definition: Group.c:16
bool ext2_bg_has_super(PEXT2_SUPER_BLOCK pExt2Sb, int group_block)
Definition: Group.c:30
void ext2_free_group_desc(PEXT2_FILESYS Ext2Sys)
Definition: Group.c:61
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
Definition: ext2_fs.h:465
unsigned int ULONG
Definition: retypes.h:1
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define memset(x, y, z)
Definition: compat.h:39