|
Navigation
- Home
- Community
- Development
- myReactOS
- Fundraiser 2012
Doxygen
- Main Page
- Alphabetical List
- Data Structures
- Directories
- File List
- Data Fields
- Globals
- Related Pages
Search
|
|
|
Definition at line 806 of file Mke2fs.c.
Referenced by NATIVE_CreateFileSystemList().
{
BOOLEAN bRet = FALSE;
NTSTATUS Status = STATUS_UNSUCCESSFUL;
EXT2_SUPER_BLOCK Ext2Sb;
EXT2_FILESYS FileSys;
ULONG Percent;
ULONG rsv;
ULONG blocks;
ULONG start;
ULONG ret_blk;
if (Callback != NULL)
{
Callback(PROGRESS, 0, (PVOID)&Percent);
}
RtlZeroMemory(&Ext2Sb, sizeof(EXT2_SUPER_BLOCK));
RtlZeroMemory(&FileSys, sizeof(EXT2_FILESYS));
FileSys.ext2_sb = &Ext2Sb;
if (!NT_SUCCESS(Ext2OpenDevice(&FileSys, DriveRoot)))
{
DPRINT1("Mke2fs: Volume %wZ does not exist, ...\n", DriveRoot);
goto clean_up;
}
if (!NT_SUCCESS(Ext2GetMediaInfo(&FileSys)))
{
DPRINT1("Mke2fs: Can't get media information\n");
goto clean_up;
}
set_fs_defaults(NULL, &Ext2Sb, ClusterSize, &inode_ratio);
Ext2Sb.s_blocks_count = FileSys.PartInfo.PartitionLength.QuadPart /
EXT2_BLOCK_SIZE(&Ext2Sb);
Ext2Sb.s_inodes_count =
(ULONG)(((LONGLONG) Ext2Sb.s_blocks_count * EXT2_BLOCK_SIZE(&Ext2Sb)) / inode_ratio);
Ext2Sb.s_r_blocks_count = (Ext2Sb.s_blocks_count * 5) / 100;
Status = Ext2LockVolume(&FileSys);
if (NT_SUCCESS(Status))
{
bLocked = TRUE;
}
if (!ext2_initialize_sb(&FileSys))
{
DPRINT1("Mke2fs: error...\n");
goto clean_up;
}
zap_sector(&FileSys, 2, 6);
{
__u8 uuid[16];
uuid_generate(&uuid[0]);
memcpy(&Ext2Sb.s_uuid[0], &uuid[0], 16);
}
{
ULONG i, val;
for (i = 0, val = 0 ; i < sizeof(Ext2Sb.s_uuid); i++)
val += Ext2Sb.s_uuid[i];
Ext2Sb.s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
}
if (Label)
{
ANSI_STRING ansi_label;
ansi_label.MaximumLength = sizeof(Ext2Sb.s_volume_name);
ansi_label.Length = 0;
ansi_label.Buffer = Ext2Sb.s_volume_name;
RtlUnicodeStringToAnsiString(&ansi_label, Label, FALSE);
}
ext2_print_super(&Ext2Sb);
bRet = ext2_allocate_tables(&FileSys);
if (!bRet)
{
goto clean_up;
}
rsv = 65536 / FileSys.blocksize;
blocks = Ext2Sb.s_blocks_count;
#ifdef ZAP_BOOTBLOCK
DPRINT1("Mke2fs: zeroing volume boot record\n");
zap_sector(&FileSys, 0, 2);
#endif
start = (blocks & ~(rsv - 1));
if (start > rsv)
start -= rsv;
if (start > 0)
bRet = zero_blocks(&FileSys, start, blocks - start, &ret_blk, NULL);
if (!bRet)
{
DPRINT1("Mke2fs: zeroing block %lu at end of filesystem", ret_blk);
goto clean_up;
}
write_inode_tables(&FileSys);
create_root_dir(&FileSys);
create_lost_and_found(&FileSys);
ext2_reserve_inodes(&FileSys);
create_bad_block_inode(&FileSys, NULL);
DPRINT("Mke2fs: Writing superblocks and filesystem accounting information ... \n");
if (!QuickFormat)
{
DPRINT1("Mke2fs: Slow format not supported yet\n");
}
if (!ext2_flush(&FileSys))
{
bRet = false;
DPRINT1("Mke2fs: Warning, had trouble writing out superblocks.\n");
goto clean_up;
}
DPRINT("Mke2fs: Writing superblocks and filesystem accounting information done!\n");
bRet = true;
Status = STATUS_SUCCESS;
clean_up:
ext2_free_group_desc(&FileSys);
ext2_free_block_bitmap(&FileSys);
ext2_free_inode_bitmap(&FileSys);
if (!bRet)
{
Ext2DisMountVolume(&FileSys);
}
else
{
if(bLocked)
{
Ext2UnLockVolume(&FileSys);
}
}
Ext2CloseDevice(&FileSys);
if (Callback != NULL)
{
Callback(DONE, 0, (PVOID)&bRet);
}
return Status;
}
|
Generated on Wed May 23 2012 05:54:16 for ReactOS by
1.7.6.1
|