ReactOS  0.4.14-dev-297-g23e575c
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

NTSTATUS NTAPI Ext2Chkdsk (IN PUNICODE_STRING DriveRoot, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PFMIFSCALLBACK Callback)
 
NTSTATUS NTAPI Ext2Format (IN PUNICODE_STRING DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
 

Function Documentation

◆ Ext2Chkdsk()

NTSTATUS NTAPI Ext2Chkdsk ( IN PUNICODE_STRING  DriveRoot,
IN BOOLEAN  FixErrors,
IN BOOLEAN  Verbose,
IN BOOLEAN  CheckOnlyIfDirty,
IN BOOLEAN  ScanDrive,
IN PFMIFSCALLBACK  Callback 
)

Definition at line 1008 of file Mke2fs.c.

1014 {
1015  UNIMPLEMENTED;
1016  return STATUS_SUCCESS;
1017 }
#define UNIMPLEMENTED
Definition: debug.h:114
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ Ext2Format()

NTSTATUS NTAPI Ext2Format ( IN PUNICODE_STRING  DriveRoot,
IN FMIFS_MEDIA_FLAG  MediaFlag,
IN PUNICODE_STRING  Label,
IN BOOLEAN  QuickFormat,
IN ULONG  ClusterSize,
IN PFMIFSCALLBACK  Callback 
)

Definition at line 803 of file Mke2fs.c.

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