ReactOS 0.4.15-dev-7953-g1f49173
ext2lib.h File Reference
#include <fmifs/fmifs.h>
Include dependency graph for ext2lib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BOOLEAN NTAPI Ext2Chkdsk (IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID pUnknown1, IN PVOID pUnknown2, IN PVOID pUnknown3, IN PVOID pUnknown4, IN PULONG ExitStatus)
 
BOOLEAN NTAPI Ext2Format (IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN QuickFormat, IN BOOLEAN BackwardCompatible, IN MEDIA_TYPE MediaType, IN PUNICODE_STRING Label, IN ULONG ClusterSize)
 

Function Documentation

◆ Ext2Chkdsk()

BOOLEAN NTAPI Ext2Chkdsk ( IN PUNICODE_STRING  DriveRoot,
IN PFMIFSCALLBACK  Callback,
IN BOOLEAN  FixErrors,
IN BOOLEAN  Verbose,
IN BOOLEAN  CheckOnlyIfDirty,
IN BOOLEAN  ScanDrive,
IN PVOID  pUnknown1,
IN PVOID  pUnknown2,
IN PVOID  pUnknown3,
IN PVOID  pUnknown4,
IN PULONG  ExitStatus 
)

Definition at line 1007 of file Mke2fs.c.

1019{
1022 return TRUE;
1023}
#define UNIMPLEMENTED
Definition: debug.h:115
#define TRUE
Definition: types.h:120
_In_ NTSTATUS ExitStatus
Definition: psfuncs.h:867
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59

◆ Ext2Format()

BOOLEAN NTAPI Ext2Format ( IN PUNICODE_STRING  DriveRoot,
IN PFMIFSCALLBACK  Callback,
IN BOOLEAN  QuickFormat,
IN BOOLEAN  BackwardCompatible,
IN MEDIA_TYPE  MediaType,
IN PUNICODE_STRING  Label,
IN ULONG  ClusterSize 
)

Definition at line 803 of file Mke2fs.c.

811{
812 BOOLEAN bRet;
814 /* Super Block: 1024 bytes long */
815 EXT2_SUPER_BLOCK Ext2Sb;
816 /* File Sys Structure */
817 EXT2_FILESYS FileSys;
818 ULONG Percent;
819 ULONG rsv;
821 ULONG start;
822 ULONG ret_blk;
823
824 // FIXME:
825 UNREFERENCED_PARAMETER(BackwardCompatible);
826 UNREFERENCED_PARAMETER(MediaType);
827
828 if (Callback != NULL)
829 {
830 Callback(PROGRESS, 0, (PVOID)&Percent);
831 }
832
833
834 RtlZeroMemory(&Ext2Sb, sizeof(EXT2_SUPER_BLOCK));
835 RtlZeroMemory(&FileSys, sizeof(EXT2_FILESYS));
836 FileSys.ext2_sb = &Ext2Sb;
837
838
839 if (!NT_SUCCESS(Ext2OpenDevice(&FileSys, DriveRoot)))
840 {
841 DPRINT1("Mke2fs: Volume %wZ does not exist, ...\n", DriveRoot);
842 goto clean_up;
843 }
844
845
846 if (!NT_SUCCESS(Ext2GetMediaInfo(&FileSys)))
847 {
848 DPRINT1("Mke2fs: Can't get media information\n");
849 goto clean_up;
850 }
851
853
854 Ext2Sb.s_blocks_count = FileSys.PartInfo.PartitionLength.QuadPart /
855 EXT2_BLOCK_SIZE(&Ext2Sb);
856
857
858 /*
859 * Calculate number of inodes based on the inode ratio
860 */
861 Ext2Sb.s_inodes_count =
862 (ULONG)(((LONGLONG) Ext2Sb.s_blocks_count * EXT2_BLOCK_SIZE(&Ext2Sb)) / inode_ratio);
863
864 /*
865 * Calculate number of blocks to reserve
866 */
867 Ext2Sb.s_r_blocks_count = (Ext2Sb.s_blocks_count * 5) / 100;
868
869
870 Status = Ext2LockVolume(&FileSys);
871 if (NT_SUCCESS(Status))
872 {
873 bLocked = TRUE;
874 }
875
877
878 // Initialize
879 if (!ext2_initialize_sb(&FileSys))
880 {
881 DPRINT1("Mke2fs: error...\n");
882 goto clean_up;
883 }
884
885
886 zap_sector(&FileSys, 2, 6);
887
888 /*
889 * Generate a UUID for it...
890 */
891 {
892 __u8 uuid[16];
893 uuid_generate(&uuid[0]);
894 memcpy(&Ext2Sb.s_uuid[0], &uuid[0], 16);
895 }
896
897 /*
898 * Add "jitter" to the superblock's check interval so that we
899 * don't check all the filesystems at the same time. We use a
900 * kludgy hack of using the UUID to derive a random jitter value.
901 */
902 {
903 ULONG i, val;
904
905 for (i = 0, val = 0 ; i < sizeof(Ext2Sb.s_uuid); i++)
906 val += Ext2Sb.s_uuid[i];
907
908 Ext2Sb.s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
909 }
910
911 /*
912 * Set the volume label...
913 */
914 if (Label)
915 {
916 ANSI_STRING ansi_label;
917 ansi_label.MaximumLength = sizeof(Ext2Sb.s_volume_name);
918 ansi_label.Length = 0;
919 ansi_label.Buffer = Ext2Sb.s_volume_name;
921 }
922
923 ext2_print_super(&Ext2Sb);
924
925 bRet = ext2_allocate_tables(&FileSys);
926 if (!bRet)
927 {
928 goto clean_up;
929 }
930
931 /* rsv must be a power of two (64kB is MD RAID sb alignment) */
932 rsv = 65536 / FileSys.blocksize;
933 blocks = Ext2Sb.s_blocks_count;
934
935#ifdef ZAP_BOOTBLOCK
936 DPRINT1("Mke2fs: zeroing volume boot record\n");
937 zap_sector(&FileSys, 0, 2);
938#endif
939
940 /*
941 * Wipe out any old MD RAID (or other) metadata at the end
942 * of the device. This will also verify that the device is
943 * as large as we think. Be careful with very small devices.
944 */
945
946 start = (blocks & ~(rsv - 1));
947 if (start > rsv)
948 start -= rsv;
949
950 bRet = TRUE;
951 if (start > 0)
952 bRet = zero_blocks(&FileSys, start, blocks - start, &ret_blk, NULL);
953
954 if (!bRet)
955 {
956 DPRINT1("Mke2fs: zeroing block %lu at end of filesystem", ret_blk);
957 goto clean_up;
958 }
959
960 write_inode_tables(&FileSys);
961
962 create_root_dir(&FileSys);
963 create_lost_and_found(&FileSys);
964
965 ext2_reserve_inodes(&FileSys);
966
967 create_bad_block_inode(&FileSys, NULL);
968
969 DPRINT("Mke2fs: Writing superblocks and filesystem accounting information ... \n");
970
971 if (!QuickFormat)
972 {
973 DPRINT1("Mke2fs: Slow format not supported yet\n");
974 }
975
976 if (!ext2_flush(&FileSys))
977 {
978 DPRINT1("Mke2fs: Warning, had trouble writing out superblocks.\n");
979 goto clean_up;
980 }
981
982 DPRINT("Mke2fs: Writing superblocks and filesystem accounting information done!\n");
983
985
986clean_up:
987
988 // Clean up ...
989 ext2_free_group_desc(&FileSys);
990
991 ext2_free_block_bitmap(&FileSys);
992 ext2_free_inode_bitmap(&FileSys);
993
994 if(bLocked)
995 {
996 Ext2DisMountVolume(&FileSys);
997 Ext2UnLockVolume(&FileSys);
998 }
999
1000 Ext2CloseDevice(&FileSys);
1001
1002 return NT_SUCCESS(Status);
1003}
bool create_bad_block_inode(PEXT2_FILESYS Ext2Sys, PEXT2_BADBLK_LIST bb_list)
Definition: Badblock.c:16
void ext2_free_inode_bitmap(PEXT2_FILESYS Ext2Sys)
Definition: Bitmap.c:194
void ext2_free_block_bitmap(PEXT2_FILESYS Ext2Sys)
Definition: Bitmap.c:205
NTSTATUS Ext2GetMediaInfo(PEXT2_FILESYS Ext2Sys)
Definition: Disk.c:1162
NTSTATUS Ext2OpenDevice(PEXT2_FILESYS Ext2Sys, PUNICODE_STRING DeviceName)
Definition: Disk.c:1282
NTSTATUS Ext2DisMountVolume(PEXT2_FILESYS Ext2Sys)
Definition: Disk.c:1260
NTSTATUS Ext2UnLockVolume(PEXT2_FILESYS Ext2Sys)
Definition: Disk.c:1237
NTSTATUS Ext2CloseDevice(PEXT2_FILESYS Ext2Sys)
Definition: Disk.c:1342
void ext2_free_group_desc(PEXT2_FILESYS Ext2Sys)
Definition: Group.c:61
bool ext2_reserve_inodes(PEXT2_FILESYS fs)
Definition: Inode.c:681
bool ext2_allocate_tables(PEXT2_FILESYS Ext2Sys)
Definition: Memory.c:75
bool write_inode_tables(PEXT2_FILESYS fs)
Definition: Memory.c:221
BOOLEAN bLocked
Definition: Mke2fs.c:19
bool zero_blocks(PEXT2_FILESYS fs, ULONG blk, ULONG num, ULONG *ret_blk, ULONG *ret_count)
Definition: Mke2fs.c:122
bool create_root_dir(PEXT2_FILESYS fs)
Definition: Mke2fs.c:364
int inode_ratio
Definition: Mke2fs.c:17
bool ext2_flush(PEXT2_FILESYS fs)
Definition: Mke2fs.c:525
bool create_lost_and_found(PEXT2_FILESYS Ext2Sys)
Definition: Mke2fs.c:392
void set_fs_defaults(const char *fs_type, PEXT2_SUPER_BLOCK super, int blocksize, int *inode_ratio)
Definition: Mke2fs.c:70
bool zap_sector(PEXT2_FILESYS Ext2Sys, int sect, int nsect)
Definition: Mke2fs.c:187
void ext2_print_super(PEXT2_SUPER_BLOCK pExt2Sb)
Definition: Super.c:20
void uuid_generate(__u8 *uuid)
Definition: Uuid.c:17
bool ext2_initialize_sb(PEXT2_FILESYS pExt2Sys)
Definition: Super.c:74
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
BOOL QuickFormat
Definition: format.c:66
PWCHAR Label
Definition: format.c:70
DWORD ClusterSize
Definition: format.c:67
u8 __u8
Definition: btrfs.h:17
#define EXT2_BLOCK_SIZE(sb)
Definition: ext2.h:186
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define EXT2_DFL_MAX_MNT_COUNT
Definition: ext2_fs.h:332
NTSTATUS Ext2LockVolume(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:136
@ PROGRESS
Definition: fmifs.h:68
Status
Definition: gdiplustypes.h:25
GLuint start
Definition: gl.h:1545
GLuint GLfloat * val
Definition: glext.h:7180
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: msctf.idl:550
static int blocks
Definition: mkdosfs.c:527
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define DPRINT
Definition: sndvol32.h:71
USHORT MaximumLength
Definition: env_spec_w32.h:377
LARGE_INTEGER PartitionLength
Definition: ntdddisk.h:414
PEXT2_SUPER_BLOCK ext2_sb
Definition: Mke2fs.h:159
PARTITION_INFORMATION PartInfo
Definition: Mke2fs.h:186
int blocksize
Definition: Mke2fs.h:154
int64_t LONGLONG
Definition: typedefs.h:68
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458