mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[extfs] add standalone ext2/ext3 formatting
* Only enabled when Advanced format options are shown * Also enable reading of extfs volume label * Also improve GRUB lookup fallback * Also fix possible truncation when sanitizing labels * Also write a zeroed MBR when non-bootable is selected
This commit is contained in:
parent
a696e041e1
commit
2ff6da49f0
12 changed files with 691 additions and 54 deletions
|
@ -77,6 +77,7 @@
|
||||||
<ClCompile Include="..\src\ext2fs\mmp.c" />
|
<ClCompile Include="..\src\ext2fs\mmp.c" />
|
||||||
<ClCompile Include="..\src\ext2fs\newdir.c" />
|
<ClCompile Include="..\src\ext2fs\newdir.c" />
|
||||||
<ClCompile Include="..\src\ext2fs\nt_io.c" />
|
<ClCompile Include="..\src\ext2fs\nt_io.c" />
|
||||||
|
<ClCompile Include="..\src\ext2fs\openfs.c" />
|
||||||
<ClCompile Include="..\src\ext2fs\punch.c" />
|
<ClCompile Include="..\src\ext2fs\punch.c" />
|
||||||
<ClCompile Include="..\src\ext2fs\rbtree.c" />
|
<ClCompile Include="..\src\ext2fs\rbtree.c" />
|
||||||
<ClCompile Include="..\src\ext2fs\read_bb.c" />
|
<ClCompile Include="..\src\ext2fs\read_bb.c" />
|
||||||
|
|
|
@ -156,6 +156,9 @@
|
||||||
<ClCompile Include="..\src\ext2fs\fallocate.c">
|
<ClCompile Include="..\src\ext2fs\fallocate.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\ext2fs\openfs.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\src\ext2fs\ext2_fs.h">
|
<ClInclude Include="..\src\ext2fs\ext2_fs.h">
|
||||||
|
|
|
@ -460,8 +460,8 @@ t MSG_224 "Clearing MBR/PBR/GPT structures..."
|
||||||
t MSG_225 "Requesting disk access..."
|
t MSG_225 "Requesting disk access..."
|
||||||
t MSG_226 "Analyzing existing boot records..."
|
t MSG_226 "Analyzing existing boot records..."
|
||||||
t MSG_227 "Closing existing volume..."
|
t MSG_227 "Closing existing volume..."
|
||||||
t MSG_228 "Writing master boot record..."
|
t MSG_228 "Writing Master Boot Record..."
|
||||||
t MSG_229 "Writing partition boot record..."
|
t MSG_229 "Writing Partition Boot Record..."
|
||||||
t MSG_230 "Copying DOS files..."
|
t MSG_230 "Copying DOS files..."
|
||||||
t MSG_231 "Copying ISO files..."
|
t MSG_231 "Copying ISO files..."
|
||||||
t MSG_232 "Win7 EFI boot setup (This may take a while)..."
|
t MSG_232 "Win7 EFI boot setup (This may take a while)..."
|
||||||
|
@ -2714,8 +2714,8 @@ t MSG_224 "Čistim MBR/PBR/GPT strukture..."
|
||||||
t MSG_225 "Zahtijevam pristup disku..."
|
t MSG_225 "Zahtijevam pristup disku..."
|
||||||
t MSG_226 "Analiziram postojeće boot zapise..."
|
t MSG_226 "Analiziram postojeće boot zapise..."
|
||||||
t MSG_227 "Zatvaram postojeću jedinicu..."
|
t MSG_227 "Zatvaram postojeću jedinicu..."
|
||||||
t MSG_228 "Zapisujem master boot record..."
|
t MSG_228 "Zapisujem Master Boot Record..."
|
||||||
t MSG_229 "Zapisujem partition boot record..."
|
t MSG_229 "Zapisujem Partition Boot Record..."
|
||||||
t MSG_230 "Kopiram DOS datoteke..."
|
t MSG_230 "Kopiram DOS datoteke..."
|
||||||
t MSG_231 "Kopiram ISO datoteku..."
|
t MSG_231 "Kopiram ISO datoteku..."
|
||||||
t MSG_232 "Win7 EFI boot setup..."
|
t MSG_232 "Win7 EFI boot setup..."
|
||||||
|
@ -3425,8 +3425,8 @@ t MSG_224 "Nulstiller MBR/PBR/GPT-strukturer..."
|
||||||
t MSG_225 "Anmoder om disk tilgang..."
|
t MSG_225 "Anmoder om disk tilgang..."
|
||||||
t MSG_226 "Analyserer eksisterende boot records..."
|
t MSG_226 "Analyserer eksisterende boot records..."
|
||||||
t MSG_227 "Lukker eksisterende volume..."
|
t MSG_227 "Lukker eksisterende volume..."
|
||||||
t MSG_228 "Skriver master boot record..."
|
t MSG_228 "Skriver Master Boot Record..."
|
||||||
t MSG_229 "Skriver partition boot record..."
|
t MSG_229 "Skriver Partition Boot Record..."
|
||||||
t MSG_230 "Kopierer DOS-filer..."
|
t MSG_230 "Kopierer DOS-filer..."
|
||||||
t MSG_231 "Kopierer ISO-filer..."
|
t MSG_231 "Kopierer ISO-filer..."
|
||||||
t MSG_232 "Win7 EFI boot setup (dette kan tage noget tid)..."
|
t MSG_232 "Win7 EFI boot setup (dette kan tage noget tid)..."
|
||||||
|
@ -3781,8 +3781,8 @@ t MSG_224 "MBR/PBR/GPT-structuren wissen..."
|
||||||
t MSG_225 "Schijftoegang aanvragen..."
|
t MSG_225 "Schijftoegang aanvragen..."
|
||||||
t MSG_226 "Bestaande boot-records analyseren..."
|
t MSG_226 "Bestaande boot-records analyseren..."
|
||||||
t MSG_227 "Bestaand volume afsluiten..."
|
t MSG_227 "Bestaand volume afsluiten..."
|
||||||
t MSG_228 "Master boot record schrijven..."
|
t MSG_228 "Master Boot Record schrijven..."
|
||||||
t MSG_229 "Partitie-boot-record schrijven..."
|
t MSG_229 "Partitie Boot Record schrijven..."
|
||||||
t MSG_230 "DOS-bestanden kopiëren..."
|
t MSG_230 "DOS-bestanden kopiëren..."
|
||||||
t MSG_231 "ISO-bestanden kopiëren..."
|
t MSG_231 "ISO-bestanden kopiëren..."
|
||||||
t MSG_232 "Win7 EFI boot-setup (dit kan een tijdje duren)..."
|
t MSG_232 "Win7 EFI boot-setup (dit kan een tijdje duren)..."
|
||||||
|
@ -4142,8 +4142,8 @@ t MSG_224 "Selvitetään MBR/PBR/GPT -rakenteita..."
|
||||||
t MSG_225 "Pyydetään pääsyä levylle..."
|
t MSG_225 "Pyydetään pääsyä levylle..."
|
||||||
t MSG_226 "Analysoidaan löytyviä käynnistyslistauksia..."
|
t MSG_226 "Analysoidaan löytyviä käynnistyslistauksia..."
|
||||||
t MSG_227 "Suljetaan olemassaolevaa asemaa..."
|
t MSG_227 "Suljetaan olemassaolevaa asemaa..."
|
||||||
t MSG_228 "Kirjoitetaan master boot record..."
|
t MSG_228 "Kirjoitetaan Master Boot Record..."
|
||||||
t MSG_229 "Kirjoitetaan partition boot record..."
|
t MSG_229 "Kirjoitetaan Partition Boot Record..."
|
||||||
t MSG_230 "Kopioidaan DOS-tiedostoja..."
|
t MSG_230 "Kopioidaan DOS-tiedostoja..."
|
||||||
t MSG_231 "Kopioidaan ISO-tiedostoja..."
|
t MSG_231 "Kopioidaan ISO-tiedostoja..."
|
||||||
t MSG_232 "Win7 EFI -käynnistysasetus (tämä voi viedä hetken)..."
|
t MSG_232 "Win7 EFI -käynnistysasetus (tämä voi viedä hetken)..."
|
||||||
|
@ -6284,7 +6284,7 @@ t MSG_224 "Membersihkan struktur MBR/PBR/GPT..."
|
||||||
t MSG_225 "Meminta akses disk..."
|
t MSG_225 "Meminta akses disk..."
|
||||||
t MSG_226 "Menganalisa boot records yang ada..."
|
t MSG_226 "Menganalisa boot records yang ada..."
|
||||||
t MSG_227 "Menutup volume yang ada..."
|
t MSG_227 "Menutup volume yang ada..."
|
||||||
t MSG_228 "Menulis master boot record..."
|
t MSG_228 "Menulis Master Boot Record..."
|
||||||
t MSG_229 "Menulis boot record partisi..."
|
t MSG_229 "Menulis boot record partisi..."
|
||||||
t MSG_230 "Menyalin berkas DOS..."
|
t MSG_230 "Menyalin berkas DOS..."
|
||||||
t MSG_231 "Menyalin berkas ISO..."
|
t MSG_231 "Menyalin berkas ISO..."
|
||||||
|
@ -6635,7 +6635,7 @@ t MSG_224 "Azzeramento struttura MBR/PBR/GPT..."
|
||||||
t MSG_225 "Richiesta accesso disco..."
|
t MSG_225 "Richiesta accesso disco..."
|
||||||
t MSG_226 "Analisi dati avvio..."
|
t MSG_226 "Analisi dati avvio..."
|
||||||
t MSG_227 "Chiusura volume esistente..."
|
t MSG_227 "Chiusura volume esistente..."
|
||||||
t MSG_228 "Scrittura master boot record..."
|
t MSG_228 "Scrittura Master Boot Record..."
|
||||||
t MSG_229 "Scrittura partizione di avvio..."
|
t MSG_229 "Scrittura partizione di avvio..."
|
||||||
t MSG_230 "Copia file DOS..."
|
t MSG_230 "Copia file DOS..."
|
||||||
t MSG_231 "Copia file immagine ISO..."
|
t MSG_231 "Copia file immagine ISO..."
|
||||||
|
@ -9520,8 +9520,8 @@ t MSG_224 "Czyszczenie struktur MBR/PBR/GPT..."
|
||||||
t MSG_225 "Żądanie dostępu do dysku..."
|
t MSG_225 "Żądanie dostępu do dysku..."
|
||||||
t MSG_226 "Analizowanie istniejących boot sektorów..."
|
t MSG_226 "Analizowanie istniejących boot sektorów..."
|
||||||
t MSG_227 "Zamykanie istniejącego woluminu..."
|
t MSG_227 "Zamykanie istniejącego woluminu..."
|
||||||
t MSG_228 "Zapisywanie master boot record..."
|
t MSG_228 "Zapisywanie Master Boot Record..."
|
||||||
t MSG_229 "Zapisywanie partition boot record..."
|
t MSG_229 "Zapisywanie Partition Boot Record..."
|
||||||
t MSG_230 "Kopiowanie plików DOS..."
|
t MSG_230 "Kopiowanie plików DOS..."
|
||||||
t MSG_231 "Kopiowanie plików ISO..."
|
t MSG_231 "Kopiowanie plików ISO..."
|
||||||
t MSG_232 "Ustawianie bootowania Win7 EFI (to może chwilę potrwać)..."
|
t MSG_232 "Ustawianie bootowania Win7 EFI (to może chwilę potrwać)..."
|
||||||
|
@ -10599,7 +10599,7 @@ t MSG_224 "Resetarea structurii MBR/PBR/GPT..."
|
||||||
t MSG_225 "Solicită accesul la disc..."
|
t MSG_225 "Solicită accesul la disc..."
|
||||||
t MSG_226 "Pornire analiza datelor..."
|
t MSG_226 "Pornire analiza datelor..."
|
||||||
t MSG_227 "Se închide volumul existent..."
|
t MSG_227 "Se închide volumul existent..."
|
||||||
t MSG_228 "Se scrie master boot record..."
|
t MSG_228 "Se scrie Master Boot Record..."
|
||||||
t MSG_229 "Se scrie partiția de boot..."
|
t MSG_229 "Se scrie partiția de boot..."
|
||||||
t MSG_230 "Se copiază fișierul DOS..."
|
t MSG_230 "Se copiază fișierul DOS..."
|
||||||
t MSG_231 "Se copiază imaginea ISO..."
|
t MSG_231 "Se copiază imaginea ISO..."
|
||||||
|
@ -13062,8 +13062,8 @@ t MSG_224 "กำลังจัดการโครงสร้าง MBR/PBR/
|
||||||
t MSG_225 "กำลังเข้าถึงดิสก์..."
|
t MSG_225 "กำลังเข้าถึงดิสก์..."
|
||||||
t MSG_226 "กำลังวิเคราะห์ Boot Record..."
|
t MSG_226 "กำลังวิเคราะห์ Boot Record..."
|
||||||
t MSG_227 "กำลังปิดโวลุ่มปัจจุบัน..."
|
t MSG_227 "กำลังปิดโวลุ่มปัจจุบัน..."
|
||||||
t MSG_228 "กำลังเขียน master boot record..."
|
t MSG_228 "กำลังเขียน Master Boot Record..."
|
||||||
t MSG_229 "กำลังเขียน partition boot record..."
|
t MSG_229 "กำลังเขียน Partition Boot Record..."
|
||||||
t MSG_230 "กำลังคัดลอกไฟล์ DOS..."
|
t MSG_230 "กำลังคัดลอกไฟล์ DOS..."
|
||||||
t MSG_231 "กำลังคัดลอกไฟล์ ISO..."
|
t MSG_231 "กำลังคัดลอกไฟล์ ISO..."
|
||||||
t MSG_232 "Win7 EFI boot setup..."
|
t MSG_232 "Win7 EFI boot setup..."
|
||||||
|
|
12
src/drive.c
12
src/drive.c
|
@ -844,7 +844,7 @@ out:
|
||||||
BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label)
|
BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label)
|
||||||
{
|
{
|
||||||
HANDLE hPhysical;
|
HANDLE hPhysical;
|
||||||
DWORD size;
|
DWORD size, error;
|
||||||
static char VolumeLabel[MAX_PATH + 1];
|
static char VolumeLabel[MAX_PATH + 1];
|
||||||
char DrivePath[] = "#:\\", AutorunPath[] = "#:\\autorun.inf", *AutorunLabel = NULL;
|
char DrivePath[] = "#:\\", AutorunPath[] = "#:\\autorun.inf", *AutorunLabel = NULL;
|
||||||
|
|
||||||
|
@ -879,9 +879,15 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label)
|
||||||
NULL, NULL, NULL, NULL, 0) && (VolumeLabel[0] != 0)) {
|
NULL, NULL, NULL, NULL, 0) && (VolumeLabel[0] != 0)) {
|
||||||
*label = VolumeLabel;
|
*label = VolumeLabel;
|
||||||
} else {
|
} else {
|
||||||
duprintf("Failed to read label: %s", WindowsErrorString());
|
// Might be an extfs label
|
||||||
|
error = GetLastError();
|
||||||
|
*label = (char*)GetExtFsLabel(DriveIndex, 0);
|
||||||
|
if (*label == NULL) {
|
||||||
|
SetLastError(error);
|
||||||
|
duprintf("Failed to read label: %s", WindowsErrorString());
|
||||||
|
*label = STR_NO_LABEL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,3 +386,4 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
||||||
BOOL InitializeDisk(HANDLE hDrive);
|
BOOL InitializeDisk(HANDLE hDrive);
|
||||||
BOOL RefreshDriveLayout(HANDLE hDrive);
|
BOOL RefreshDriveLayout(HANDLE hDrive);
|
||||||
const char* GetPartitionType(BYTE Type);
|
const char* GetPartitionType(BYTE Type);
|
||||||
|
const char* GetExtFsLabel(DWORD DriveIndex, DWORD PartitionIndex);
|
||||||
|
|
|
@ -5,6 +5,6 @@ libext2fs_a_SOURCES = alloc.c alloc_sb.c alloc_stats.c alloc_tables.c badblocks.
|
||||||
crc32c.c csum.c dirblock.c dir_iterate.c extent.c ext_attr.c extent.c fallocate.c fileio.c \
|
crc32c.c csum.c dirblock.c dir_iterate.c extent.c ext_attr.c extent.c fallocate.c fileio.c \
|
||||||
freefs.c gen_bitmap.c gen_bitmap64.c get_num_dirs.c hashmap.c i_block.c ind_block.c initialize.c \
|
freefs.c gen_bitmap.c gen_bitmap64.c get_num_dirs.c hashmap.c i_block.c ind_block.c initialize.c \
|
||||||
inline.c inline_data.c inode.c io_manager.c link.c lookup.c mkdir.c mkjournal.c mmp.c newdir.c \
|
inline.c inline_data.c inode.c io_manager.c link.c lookup.c mkdir.c mkjournal.c mmp.c newdir.c \
|
||||||
nt_io.c punch.c rbtree.c read_bb.c rw_bitmaps.c sha512.c symlink.c valid_blk.c
|
nt_io.c openfs.c punch.c rbtree.c read_bb.c rw_bitmaps.c sha512.c symlink.c valid_blk.c
|
||||||
|
|
||||||
libext2fs_a_CFLAGS = $(AM_CFLAGS) -DEXT2_FLAT_INCLUDES=0 -DHAVE_CONFIG_H -I. -I.. -Wno-undef -Wno-strict-aliasing -Wno-shadow
|
libext2fs_a_CFLAGS = $(AM_CFLAGS) -DEXT2_FLAT_INCLUDES=0 -DHAVE_CONFIG_H -I. -I.. -Wno-undef -Wno-strict-aliasing -Wno-shadow
|
||||||
|
|
|
@ -119,10 +119,10 @@ am_libext2fs_a_OBJECTS = libext2fs_a-alloc.$(OBJEXT) \
|
||||||
libext2fs_a-lookup.$(OBJEXT) libext2fs_a-mkdir.$(OBJEXT) \
|
libext2fs_a-lookup.$(OBJEXT) libext2fs_a-mkdir.$(OBJEXT) \
|
||||||
libext2fs_a-mkjournal.$(OBJEXT) libext2fs_a-mmp.$(OBJEXT) \
|
libext2fs_a-mkjournal.$(OBJEXT) libext2fs_a-mmp.$(OBJEXT) \
|
||||||
libext2fs_a-newdir.$(OBJEXT) libext2fs_a-nt_io.$(OBJEXT) \
|
libext2fs_a-newdir.$(OBJEXT) libext2fs_a-nt_io.$(OBJEXT) \
|
||||||
libext2fs_a-punch.$(OBJEXT) libext2fs_a-rbtree.$(OBJEXT) \
|
libext2fs_a-openfs.$(OBJEXT) libext2fs_a-punch.$(OBJEXT) \
|
||||||
libext2fs_a-read_bb.$(OBJEXT) libext2fs_a-rw_bitmaps.$(OBJEXT) \
|
libext2fs_a-rbtree.$(OBJEXT) libext2fs_a-read_bb.$(OBJEXT) \
|
||||||
libext2fs_a-sha512.$(OBJEXT) libext2fs_a-symlink.$(OBJEXT) \
|
libext2fs_a-rw_bitmaps.$(OBJEXT) libext2fs_a-sha512.$(OBJEXT) \
|
||||||
libext2fs_a-valid_blk.$(OBJEXT)
|
libext2fs_a-symlink.$(OBJEXT) libext2fs_a-valid_blk.$(OBJEXT)
|
||||||
libext2fs_a_OBJECTS = $(am_libext2fs_a_OBJECTS)
|
libext2fs_a_OBJECTS = $(am_libext2fs_a_OBJECTS)
|
||||||
AM_V_P = $(am__v_P_@AM_V@)
|
AM_V_P = $(am__v_P_@AM_V@)
|
||||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||||
|
@ -275,7 +275,7 @@ libext2fs_a_SOURCES = alloc.c alloc_sb.c alloc_stats.c alloc_tables.c badblocks.
|
||||||
crc32c.c csum.c dirblock.c dir_iterate.c extent.c ext_attr.c extent.c fallocate.c fileio.c \
|
crc32c.c csum.c dirblock.c dir_iterate.c extent.c ext_attr.c extent.c fallocate.c fileio.c \
|
||||||
freefs.c gen_bitmap.c gen_bitmap64.c get_num_dirs.c hashmap.c i_block.c ind_block.c initialize.c \
|
freefs.c gen_bitmap.c gen_bitmap64.c get_num_dirs.c hashmap.c i_block.c ind_block.c initialize.c \
|
||||||
inline.c inline_data.c inode.c io_manager.c link.c lookup.c mkdir.c mkjournal.c mmp.c newdir.c \
|
inline.c inline_data.c inode.c io_manager.c link.c lookup.c mkdir.c mkjournal.c mmp.c newdir.c \
|
||||||
nt_io.c punch.c rbtree.c read_bb.c rw_bitmaps.c sha512.c symlink.c valid_blk.c
|
nt_io.c openfs.c punch.c rbtree.c read_bb.c rw_bitmaps.c sha512.c symlink.c valid_blk.c
|
||||||
|
|
||||||
libext2fs_a_CFLAGS = $(AM_CFLAGS) -DEXT2_FLAT_INCLUDES=0 -DHAVE_CONFIG_H -I. -I.. -Wno-undef -Wno-strict-aliasing -Wno-shadow
|
libext2fs_a_CFLAGS = $(AM_CFLAGS) -DEXT2_FLAT_INCLUDES=0 -DHAVE_CONFIG_H -I. -I.. -Wno-undef -Wno-strict-aliasing -Wno-shadow
|
||||||
all: all-am
|
all: all-am
|
||||||
|
@ -585,6 +585,12 @@ libext2fs_a-nt_io.o: nt_io.c
|
||||||
libext2fs_a-nt_io.obj: nt_io.c
|
libext2fs_a-nt_io.obj: nt_io.c
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libext2fs_a_CFLAGS) $(CFLAGS) -c -o libext2fs_a-nt_io.obj `if test -f 'nt_io.c'; then $(CYGPATH_W) 'nt_io.c'; else $(CYGPATH_W) '$(srcdir)/nt_io.c'; fi`
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libext2fs_a_CFLAGS) $(CFLAGS) -c -o libext2fs_a-nt_io.obj `if test -f 'nt_io.c'; then $(CYGPATH_W) 'nt_io.c'; else $(CYGPATH_W) '$(srcdir)/nt_io.c'; fi`
|
||||||
|
|
||||||
|
libext2fs_a-openfs.o: openfs.c
|
||||||
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libext2fs_a_CFLAGS) $(CFLAGS) -c -o libext2fs_a-openfs.o `test -f 'openfs.c' || echo '$(srcdir)/'`openfs.c
|
||||||
|
|
||||||
|
libext2fs_a-openfs.obj: openfs.c
|
||||||
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libext2fs_a_CFLAGS) $(CFLAGS) -c -o libext2fs_a-openfs.obj `if test -f 'openfs.c'; then $(CYGPATH_W) 'openfs.c'; else $(CYGPATH_W) '$(srcdir)/openfs.c'; fi`
|
||||||
|
|
||||||
libext2fs_a-punch.o: punch.c
|
libext2fs_a-punch.o: punch.c
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libext2fs_a_CFLAGS) $(CFLAGS) -c -o libext2fs_a-punch.o `test -f 'punch.c' || echo '$(srcdir)/'`punch.c
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libext2fs_a_CFLAGS) $(CFLAGS) -c -o libext2fs_a-punch.o `test -f 'punch.c' || echo '$(srcdir)/'`punch.c
|
||||||
|
|
||||||
|
|
562
src/ext2fs/openfs.c
Normal file
562
src/ext2fs/openfs.c
Normal file
|
@ -0,0 +1,562 @@
|
||||||
|
/*
|
||||||
|
* openfs.c --- open an ext2 filesystem
|
||||||
|
*
|
||||||
|
* Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
|
||||||
|
*
|
||||||
|
* %Begin-Header%
|
||||||
|
* This file may be redistributed under the terms of the GNU Library
|
||||||
|
* General Public License, version 2.
|
||||||
|
* %End-Header%
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <time.h>
|
||||||
|
#if HAVE_SYS_STAT_H
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
#if HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_ERRNO_H
|
||||||
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ext2_fs.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "ext2fs.h"
|
||||||
|
#include "e2image.h"
|
||||||
|
|
||||||
|
blk64_t ext2fs_descriptor_block_loc2(ext2_filsys fs, blk64_t group_block,
|
||||||
|
dgrp_t i)
|
||||||
|
{
|
||||||
|
int bg;
|
||||||
|
int has_super = 0, group_zero_adjust = 0;
|
||||||
|
blk64_t ret_blk;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On a bigalloc FS with 1K blocks, block 0 is reserved for non-ext4
|
||||||
|
* stuff, so adjust for that if we're being asked for group 0.
|
||||||
|
*/
|
||||||
|
if (i == 0 && fs->blocksize == 1024 && EXT2FS_CLUSTER_RATIO(fs) > 1)
|
||||||
|
group_zero_adjust = 1;
|
||||||
|
|
||||||
|
if (!ext2fs_has_feature_meta_bg(fs->super) ||
|
||||||
|
(i < fs->super->s_first_meta_bg))
|
||||||
|
return group_block + i + 1 + group_zero_adjust;
|
||||||
|
|
||||||
|
bg = EXT2_DESC_PER_BLOCK(fs->super) * i;
|
||||||
|
if (ext2fs_bg_has_super(fs, bg))
|
||||||
|
has_super = 1;
|
||||||
|
ret_blk = ext2fs_group_first_block2(fs, bg);
|
||||||
|
/*
|
||||||
|
* If group_block is not the normal value, we're trying to use
|
||||||
|
* the backup group descriptors and superblock --- so use the
|
||||||
|
* alternate location of the second block group in the
|
||||||
|
* metablock group. Ideally we should be testing each bg
|
||||||
|
* descriptor block individually for correctness, but we don't
|
||||||
|
* have the infrastructure in place to do that.
|
||||||
|
*/
|
||||||
|
if (group_block != fs->super->s_first_data_block &&
|
||||||
|
((ret_blk + has_super + fs->super->s_blocks_per_group) <
|
||||||
|
ext2fs_blocks_count(fs->super))) {
|
||||||
|
ret_blk += fs->super->s_blocks_per_group;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we're going to jump forward a block group, make sure
|
||||||
|
* that we adjust has_super to account for the next group's
|
||||||
|
* backup superblock (or lack thereof).
|
||||||
|
*/
|
||||||
|
if (ext2fs_bg_has_super(fs, bg + 1))
|
||||||
|
has_super = 1;
|
||||||
|
else
|
||||||
|
has_super = 0;
|
||||||
|
}
|
||||||
|
return ret_blk + has_super + group_zero_adjust;
|
||||||
|
}
|
||||||
|
|
||||||
|
blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i)
|
||||||
|
{
|
||||||
|
return ext2fs_descriptor_block_loc2(fs, group_block, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
errcode_t ext2fs_open(const char *name, int flags, int superblock,
|
||||||
|
unsigned int block_size, io_manager manager,
|
||||||
|
ext2_filsys *ret_fs)
|
||||||
|
{
|
||||||
|
return ext2fs_open2(name, 0, flags, superblock, block_size,
|
||||||
|
manager, ret_fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void block_sha_map_free_entry(void *data)
|
||||||
|
{
|
||||||
|
free(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note: if superblock is non-zero, block-size must also be non-zero.
|
||||||
|
* Superblock and block_size can be zero to use the default size.
|
||||||
|
*
|
||||||
|
* Valid flags for ext2fs_open()
|
||||||
|
*
|
||||||
|
* EXT2_FLAG_RW - Open the filesystem for read/write.
|
||||||
|
* EXT2_FLAG_FORCE - Open the filesystem even if some of the
|
||||||
|
* features aren't supported.
|
||||||
|
* EXT2_FLAG_JOURNAL_DEV_OK - Open an ext3 journal device
|
||||||
|
* EXT2_FLAG_SKIP_MMP - Open without multi-mount protection check.
|
||||||
|
* EXT2_FLAG_64BITS - Allow 64-bit bitfields (needed for large
|
||||||
|
* filesystems)
|
||||||
|
*/
|
||||||
|
errcode_t ext2fs_open2(const char *name, const char *io_options,
|
||||||
|
int flags, int superblock,
|
||||||
|
unsigned int block_size, io_manager manager,
|
||||||
|
ext2_filsys *ret_fs)
|
||||||
|
{
|
||||||
|
ext2_filsys fs;
|
||||||
|
errcode_t retval;
|
||||||
|
unsigned long i, first_meta_bg;
|
||||||
|
__u32 features;
|
||||||
|
unsigned int blocks_per_group, io_flags;
|
||||||
|
blk64_t group_block, blk;
|
||||||
|
char *dest, *cp;
|
||||||
|
int group_zero_adjust = 0;
|
||||||
|
unsigned int inode_size;
|
||||||
|
__u64 groups_cnt;
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
unsigned int groups_per_block;
|
||||||
|
struct ext2_group_desc *gdp;
|
||||||
|
int j;
|
||||||
|
#endif
|
||||||
|
char *time_env;
|
||||||
|
|
||||||
|
EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER);
|
||||||
|
|
||||||
|
retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
|
||||||
|
if (retval)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
memset(fs, 0, sizeof(struct struct_ext2_filsys));
|
||||||
|
fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
|
||||||
|
fs->flags = flags;
|
||||||
|
/* don't overwrite sb backups unless flag is explicitly cleared */
|
||||||
|
fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
|
||||||
|
fs->umask = 022;
|
||||||
|
|
||||||
|
time_env = getenv("E2FSPROGS_FAKE_TIME");
|
||||||
|
if (time_env)
|
||||||
|
fs->now = strtoul(time_env, NULL, 0);
|
||||||
|
|
||||||
|
retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name);
|
||||||
|
if (retval)
|
||||||
|
goto cleanup;
|
||||||
|
strcpy(fs->device_name, name);
|
||||||
|
cp = strchr(fs->device_name, '?');
|
||||||
|
if (!io_options && cp) {
|
||||||
|
*cp++ = 0;
|
||||||
|
io_options = cp;
|
||||||
|
}
|
||||||
|
|
||||||
|
io_flags = 0;
|
||||||
|
if (flags & EXT2_FLAG_RW)
|
||||||
|
io_flags |= IO_FLAG_RW;
|
||||||
|
if (flags & EXT2_FLAG_EXCLUSIVE)
|
||||||
|
io_flags |= IO_FLAG_EXCLUSIVE;
|
||||||
|
if (flags & EXT2_FLAG_DIRECT_IO)
|
||||||
|
io_flags |= IO_FLAG_DIRECT_IO;
|
||||||
|
retval = manager->open(fs->device_name, io_flags, &fs->io);
|
||||||
|
if (retval)
|
||||||
|
goto cleanup;
|
||||||
|
if (io_options &&
|
||||||
|
(retval = io_channel_set_options(fs->io, io_options)))
|
||||||
|
goto cleanup;
|
||||||
|
fs->image_io = fs->io;
|
||||||
|
fs->io->app_data = fs;
|
||||||
|
retval = io_channel_alloc_buf(fs->io, -SUPERBLOCK_SIZE, &fs->super);
|
||||||
|
if (retval)
|
||||||
|
goto cleanup;
|
||||||
|
if (flags & EXT2_FLAG_IMAGE_FILE) {
|
||||||
|
retval = ext2fs_get_mem(sizeof(struct ext2_image_hdr),
|
||||||
|
&fs->image_header);
|
||||||
|
if (retval)
|
||||||
|
goto cleanup;
|
||||||
|
retval = io_channel_read_blk(fs->io, 0,
|
||||||
|
-(int)sizeof(struct ext2_image_hdr),
|
||||||
|
fs->image_header);
|
||||||
|
if (retval)
|
||||||
|
goto cleanup;
|
||||||
|
if (ext2fs_le32_to_cpu(fs->image_header->magic_number) != EXT2_ET_MAGIC_E2IMAGE)
|
||||||
|
return EXT2_ET_MAGIC_E2IMAGE;
|
||||||
|
superblock = 1;
|
||||||
|
block_size = ext2fs_le32_to_cpu(fs->image_header->fs_blocksize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the user specifies a specific block # for the
|
||||||
|
* superblock, then he/she must also specify the block size!
|
||||||
|
* Otherwise, read the master superblock located at offset
|
||||||
|
* SUPERBLOCK_OFFSET from the start of the partition.
|
||||||
|
*
|
||||||
|
* Note: we only save a backup copy of the superblock if we
|
||||||
|
* are reading the superblock from the primary superblock location.
|
||||||
|
*/
|
||||||
|
if (superblock) {
|
||||||
|
if (!block_size) {
|
||||||
|
retval = EXT2_ET_INVALID_ARGUMENT;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
io_channel_set_blksize(fs->io, block_size);
|
||||||
|
group_block = superblock;
|
||||||
|
fs->orig_super = 0;
|
||||||
|
} else {
|
||||||
|
io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET);
|
||||||
|
superblock = 1;
|
||||||
|
group_block = 0;
|
||||||
|
retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->orig_super);
|
||||||
|
if (retval)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
retval = io_channel_read_blk(fs->io, superblock, -SUPERBLOCK_SIZE,
|
||||||
|
fs->super);
|
||||||
|
if (retval)
|
||||||
|
goto cleanup;
|
||||||
|
if (fs->orig_super)
|
||||||
|
memcpy(fs->orig_super, fs->super, SUPERBLOCK_SIZE);
|
||||||
|
|
||||||
|
if (!(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS)) {
|
||||||
|
retval = 0;
|
||||||
|
if (!ext2fs_verify_csum_type(fs, fs->super))
|
||||||
|
retval = EXT2_ET_UNKNOWN_CSUM;
|
||||||
|
if (!ext2fs_superblock_csum_verify(fs, fs->super))
|
||||||
|
retval = EXT2_ET_SB_CSUM_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
fs->flags |= EXT2_FLAG_SWAP_BYTES;
|
||||||
|
ext2fs_swap_super(fs->super);
|
||||||
|
#else
|
||||||
|
if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
|
||||||
|
retval = EXT2_ET_UNIMPLEMENTED;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (fs->super->s_magic != EXT2_SUPER_MAGIC)
|
||||||
|
retval = EXT2_ET_BAD_MAGIC;
|
||||||
|
if (retval)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (fs->super->s_rev_level > EXT2_LIB_CURRENT_REV) {
|
||||||
|
retval = EXT2_ET_REV_TOO_HIGH;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check for feature set incompatibility
|
||||||
|
*/
|
||||||
|
if (!(flags & EXT2_FLAG_FORCE)) {
|
||||||
|
features = fs->super->s_feature_incompat;
|
||||||
|
#ifdef EXT2_LIB_SOFTSUPP_INCOMPAT
|
||||||
|
if (flags & EXT2_FLAG_SOFTSUPP_FEATURES)
|
||||||
|
features &= ~EXT2_LIB_SOFTSUPP_INCOMPAT;
|
||||||
|
#endif
|
||||||
|
if (features & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
|
||||||
|
retval = EXT2_ET_UNSUPP_FEATURE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
features = fs->super->s_feature_ro_compat;
|
||||||
|
#ifdef EXT2_LIB_SOFTSUPP_RO_COMPAT
|
||||||
|
if (flags & EXT2_FLAG_SOFTSUPP_FEATURES)
|
||||||
|
features &= ~EXT2_LIB_SOFTSUPP_RO_COMPAT;
|
||||||
|
#endif
|
||||||
|
if ((flags & EXT2_FLAG_RW) &&
|
||||||
|
(features & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP)) {
|
||||||
|
retval = EXT2_ET_RO_UNSUPP_FEATURE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(flags & EXT2_FLAG_JOURNAL_DEV_OK) &&
|
||||||
|
ext2fs_has_feature_journal_dev(fs->super)) {
|
||||||
|
retval = EXT2_ET_UNSUPP_FEATURE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fs->super->s_log_block_size >
|
||||||
|
(unsigned) (EXT2_MAX_BLOCK_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE)) {
|
||||||
|
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* bigalloc requires cluster-aware bitfield operations, which at the
|
||||||
|
* moment means we need EXT2_FLAG_64BITS.
|
||||||
|
*/
|
||||||
|
if (ext2fs_has_feature_bigalloc(fs->super) &&
|
||||||
|
!(flags & EXT2_FLAG_64BITS)) {
|
||||||
|
retval = EXT2_ET_CANT_USE_LEGACY_BITMAPS;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ext2fs_has_feature_bigalloc(fs->super) &&
|
||||||
|
(fs->super->s_log_block_size != fs->super->s_log_cluster_size)) {
|
||||||
|
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
fs->fragsize = fs->blocksize = EXT2_BLOCK_SIZE(fs->super);
|
||||||
|
inode_size = EXT2_INODE_SIZE(fs->super);
|
||||||
|
if ((inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
|
||||||
|
(inode_size > fs->blocksize) ||
|
||||||
|
(inode_size & (inode_size - 1))) {
|
||||||
|
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Enforce the block group descriptor size */
|
||||||
|
if (ext2fs_has_feature_64bit(fs->super)) {
|
||||||
|
if (fs->super->s_desc_size < EXT2_MIN_DESC_SIZE_64BIT) {
|
||||||
|
retval = EXT2_ET_BAD_DESC_SIZE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fs->cluster_ratio_bits = fs->super->s_log_cluster_size -
|
||||||
|
fs->super->s_log_block_size;
|
||||||
|
if (EXT2_BLOCKS_PER_GROUP(fs->super) !=
|
||||||
|
EXT2_CLUSTERS_PER_GROUP(fs->super) << fs->cluster_ratio_bits) {
|
||||||
|
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
fs->inode_blocks_per_group = ((EXT2_INODES_PER_GROUP(fs->super) *
|
||||||
|
EXT2_INODE_SIZE(fs->super) +
|
||||||
|
EXT2_BLOCK_SIZE(fs->super) - 1) /
|
||||||
|
EXT2_BLOCK_SIZE(fs->super));
|
||||||
|
if (block_size) {
|
||||||
|
if (block_size != fs->blocksize) {
|
||||||
|
retval = EXT2_ET_UNEXPECTED_BLOCK_SIZE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Set the blocksize to the filesystem's blocksize.
|
||||||
|
*/
|
||||||
|
io_channel_set_blksize(fs->io, fs->blocksize);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If this is an external journal device, don't try to read
|
||||||
|
* the group descriptors, because they're not there.
|
||||||
|
*/
|
||||||
|
if (ext2fs_has_feature_journal_dev(fs->super)) {
|
||||||
|
fs->group_desc_count = 0;
|
||||||
|
*ret_fs = fs;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EXT2_INODES_PER_GROUP(fs->super) == 0) {
|
||||||
|
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
/* Precompute the FS UUID to seed other checksums */
|
||||||
|
ext2fs_init_csum_seed(fs);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read group descriptors
|
||||||
|
*/
|
||||||
|
blocks_per_group = EXT2_BLOCKS_PER_GROUP(fs->super);
|
||||||
|
if (blocks_per_group == 0 ||
|
||||||
|
blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(fs->super) ||
|
||||||
|
fs->inode_blocks_per_group > EXT2_MAX_INODES_PER_GROUP(fs->super) ||
|
||||||
|
EXT2_DESC_PER_BLOCK(fs->super) == 0 ||
|
||||||
|
fs->super->s_first_data_block >= ext2fs_blocks_count(fs->super)) {
|
||||||
|
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
groups_cnt = ext2fs_div64_ceil(ext2fs_blocks_count(fs->super) -
|
||||||
|
fs->super->s_first_data_block,
|
||||||
|
blocks_per_group);
|
||||||
|
if (groups_cnt >> 32) {
|
||||||
|
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
fs->group_desc_count = groups_cnt;
|
||||||
|
if (!(flags & EXT2_FLAG_IGNORE_SB_ERRORS) &&
|
||||||
|
(__u64)fs->group_desc_count * EXT2_INODES_PER_GROUP(fs->super) !=
|
||||||
|
fs->super->s_inodes_count) {
|
||||||
|
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count,
|
||||||
|
EXT2_DESC_PER_BLOCK(fs->super));
|
||||||
|
retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
|
||||||
|
&fs->group_desc);
|
||||||
|
if (retval)
|
||||||
|
goto cleanup;
|
||||||
|
if (!group_block)
|
||||||
|
group_block = fs->super->s_first_data_block;
|
||||||
|
/*
|
||||||
|
* On a FS with a 1K blocksize, block 0 is reserved for bootloaders
|
||||||
|
* so we must increment block numbers to any group 0 items.
|
||||||
|
*
|
||||||
|
* However, we cannot touch group_block directly because in the meta_bg
|
||||||
|
* case, the ext2fs_descriptor_block_loc2() function will interpret
|
||||||
|
* group_block != s_first_data_block to mean that we want to access the
|
||||||
|
* backup group descriptors. This is not what we want if the caller
|
||||||
|
* set superblock == 0 (i.e. auto-detect the superblock), which is
|
||||||
|
* what's going on here.
|
||||||
|
*/
|
||||||
|
if (group_block == 0 && fs->blocksize == 1024)
|
||||||
|
group_zero_adjust = 1;
|
||||||
|
dest = (char *) fs->group_desc;
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
groups_per_block = EXT2_DESC_PER_BLOCK(fs->super);
|
||||||
|
#endif
|
||||||
|
if (ext2fs_has_feature_meta_bg(fs->super) &&
|
||||||
|
!(flags & EXT2_FLAG_IMAGE_FILE)) {
|
||||||
|
first_meta_bg = fs->super->s_first_meta_bg;
|
||||||
|
if (first_meta_bg > fs->desc_blocks)
|
||||||
|
first_meta_bg = fs->desc_blocks;
|
||||||
|
} else
|
||||||
|
first_meta_bg = fs->desc_blocks;
|
||||||
|
if (first_meta_bg) {
|
||||||
|
retval = io_channel_read_blk(fs->io, group_block +
|
||||||
|
group_zero_adjust + 1,
|
||||||
|
first_meta_bg, dest);
|
||||||
|
if (retval)
|
||||||
|
goto cleanup;
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
gdp = (struct ext2_group_desc *) dest;
|
||||||
|
for (j=0; j < groups_per_block*first_meta_bg; j++) {
|
||||||
|
gdp = ext2fs_group_desc(fs, fs->group_desc, j);
|
||||||
|
ext2fs_swap_group_desc2(fs, gdp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
dest += fs->blocksize*first_meta_bg;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = first_meta_bg ; i < fs->desc_blocks; i++) {
|
||||||
|
blk = ext2fs_descriptor_block_loc2(fs, group_block, i);
|
||||||
|
io_channel_cache_readahead(fs->io, blk, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=first_meta_bg ; i < fs->desc_blocks; i++) {
|
||||||
|
blk = ext2fs_descriptor_block_loc2(fs, group_block, i);
|
||||||
|
retval = io_channel_read_blk64(fs->io, blk, 1, dest);
|
||||||
|
if (retval)
|
||||||
|
goto cleanup;
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
for (j=0; j < groups_per_block; j++) {
|
||||||
|
gdp = ext2fs_group_desc(fs, fs->group_desc,
|
||||||
|
i * groups_per_block + j);
|
||||||
|
ext2fs_swap_group_desc2(fs, gdp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
dest += fs->blocksize;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs->stride = fs->super->s_raid_stride;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If recovery is from backup superblock, Clear _UNININT flags &
|
||||||
|
* reset bg_itable_unused to zero
|
||||||
|
*/
|
||||||
|
if (superblock > 1 && ext2fs_has_group_desc_csum(fs)) {
|
||||||
|
dgrp_t group;
|
||||||
|
|
||||||
|
for (group = 0; group < fs->group_desc_count; group++) {
|
||||||
|
ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
|
||||||
|
ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
|
||||||
|
ext2fs_bg_itable_unused_set(fs, group, 0);
|
||||||
|
/* The checksum will be reset later, but fix it here
|
||||||
|
* anyway to avoid printing a lot of spurious errors. */
|
||||||
|
ext2fs_group_desc_csum_set(fs, group);
|
||||||
|
}
|
||||||
|
if (fs->flags & EXT2_FLAG_RW)
|
||||||
|
ext2fs_mark_super_dirty(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ext2fs_has_feature_mmp(fs->super) &&
|
||||||
|
!(flags & EXT2_FLAG_SKIP_MMP) &&
|
||||||
|
(flags & (EXT2_FLAG_RW | EXT2_FLAG_EXCLUSIVE))) {
|
||||||
|
retval = ext2fs_mmp_start(fs);
|
||||||
|
if (retval) {
|
||||||
|
fs->flags |= EXT2_FLAG_SKIP_MMP; /* just do cleanup */
|
||||||
|
ext2fs_mmp_stop(fs);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fs->flags & EXT2_FLAG_SHARE_DUP) {
|
||||||
|
fs->block_sha_map = ext2fs_hashmap_create(ext2fs_djb2_hash,
|
||||||
|
block_sha_map_free_entry, 4096);
|
||||||
|
if (!fs->block_sha_map) {
|
||||||
|
retval = EXT2_ET_NO_MEMORY;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
ext2fs_set_feature_shared_blocks(fs->super);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs->flags &= ~EXT2_FLAG_NOFREE_ON_ERROR;
|
||||||
|
*ret_fs = fs;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
cleanup:
|
||||||
|
if (!(flags & EXT2_FLAG_NOFREE_ON_ERROR)) {
|
||||||
|
ext2fs_free(fs);
|
||||||
|
fs = NULL;
|
||||||
|
}
|
||||||
|
*ret_fs = fs;
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set/get the filesystem data I/O channel.
|
||||||
|
*
|
||||||
|
* These functions are only valid if EXT2_FLAG_IMAGE_FILE is true.
|
||||||
|
*/
|
||||||
|
errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io)
|
||||||
|
{
|
||||||
|
if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0)
|
||||||
|
return EXT2_ET_NOT_IMAGE_FILE;
|
||||||
|
if (old_io) {
|
||||||
|
*old_io = (fs->image_io == fs->io) ? 0 : fs->io;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
errcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io)
|
||||||
|
{
|
||||||
|
if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0)
|
||||||
|
return EXT2_ET_NOT_IMAGE_FILE;
|
||||||
|
fs->io = new_io ? new_io : fs->image_io;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io)
|
||||||
|
{
|
||||||
|
errcode_t err;
|
||||||
|
|
||||||
|
if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0)
|
||||||
|
return EXT2_ET_NOT_IMAGE_FILE;
|
||||||
|
err = io_channel_set_blksize(new_io, fs->blocksize);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
if ((new_io == fs->image_io) || (new_io == fs->io))
|
||||||
|
return 0;
|
||||||
|
if ((fs->image_io != fs->io) &&
|
||||||
|
fs->image_io)
|
||||||
|
io_channel_close(fs->image_io);
|
||||||
|
if (fs->io)
|
||||||
|
io_channel_close(fs->io);
|
||||||
|
fs->io = fs->image_io = new_io;
|
||||||
|
fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_RW |
|
||||||
|
EXT2_FLAG_BB_DIRTY | EXT2_FLAG_IB_DIRTY;
|
||||||
|
fs->flags &= ~EXT2_FLAG_IMAGE_FILE;
|
||||||
|
return 0;
|
||||||
|
}
|
45
src/format.c
45
src/format.c
|
@ -258,7 +258,6 @@ static void ToValidLabel(char* Label, BOOL bFAT)
|
||||||
if (wLabel == NULL)
|
if (wLabel == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
for (i = 0, k = 0; i < wcslen(wLabel); i++) {
|
for (i = 0, k = 0; i < wcslen(wLabel); i++) {
|
||||||
if (bFAT) { // NTFS does allows all the FAT unauthorized above
|
if (bFAT) { // NTFS does allows all the FAT unauthorized above
|
||||||
found = FALSE;
|
found = FALSE;
|
||||||
|
@ -289,6 +288,7 @@ static void ToValidLabel(char* Label, BOOL bFAT)
|
||||||
wLabel[k++] = bFAT ? toupper(wLabel[i]) : wLabel[i];
|
wLabel[k++] = bFAT ? toupper(wLabel[i]) : wLabel[i];
|
||||||
}
|
}
|
||||||
wLabel[k] = 0;
|
wLabel[k] = 0;
|
||||||
|
|
||||||
if (bFAT) {
|
if (bFAT) {
|
||||||
if (wcslen(wLabel) > 11)
|
if (wcslen(wLabel) > 11)
|
||||||
wLabel[11] = 0;
|
wLabel[11] = 0;
|
||||||
|
@ -308,7 +308,7 @@ static void ToValidLabel(char* Label, BOOL bFAT)
|
||||||
|
|
||||||
// Needed for disk by label isolinux.cfg workaround
|
// Needed for disk by label isolinux.cfg workaround
|
||||||
wchar_to_utf8_no_alloc(wLabel, img_report.usb_label, sizeof(img_report.usb_label));
|
wchar_to_utf8_no_alloc(wLabel, img_report.usb_label, sizeof(img_report.usb_label));
|
||||||
safe_strcpy(Label, strlen(Label), img_report.usb_label);
|
safe_strcpy(Label, strlen(Label) + 1, img_report.usb_label);
|
||||||
free(wLabel);
|
free(wLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,6 +817,24 @@ errcode_t ext2fs_print_progress(int64_t cur_value, int64_t max_value)
|
||||||
return IS_ERROR(FormatStatus) ? EXT2_ET_CANCEL_REQUESTED : 0;
|
return IS_ERROR(FormatStatus) ? EXT2_ET_CANCEL_REQUESTED : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* GetExtFsLabel(DWORD DriveIndex, DWORD PartitionIndex)
|
||||||
|
{
|
||||||
|
static char label[EXT2_LABEL_LEN + 1];
|
||||||
|
errcode_t r;
|
||||||
|
ext2_filsys ext2fs = NULL;
|
||||||
|
io_manager manager = nt_io_manager();
|
||||||
|
char* volume_name = GetPartitionName(DriveIndex, PartitionIndex);
|
||||||
|
|
||||||
|
r = ext2fs_open(volume_name, EXT2_FLAG_SKIP_MMP, 0, 0, manager, &ext2fs);
|
||||||
|
free(volume_name);
|
||||||
|
if (r != 0)
|
||||||
|
return NULL;
|
||||||
|
strncpy(label, ext2fs->super->s_volume_name, EXT2_LABEL_LEN);
|
||||||
|
label[EXT2_LABEL_LEN] = 0;
|
||||||
|
ext2fs_close(ext2fs);
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL FormatExtFs(DWORD DriveIndex, DWORD PartitionIndex, DWORD BlockSize, LPCSTR FSName, LPCSTR Label, DWORD Flags)
|
BOOL FormatExtFs(DWORD DriveIndex, DWORD PartitionIndex, DWORD BlockSize, LPCSTR FSName, LPCSTR Label, DWORD Flags)
|
||||||
{
|
{
|
||||||
// Mostly taken from mke2fs.conf
|
// Mostly taken from mke2fs.conf
|
||||||
|
@ -1494,9 +1512,9 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
|
||||||
unsigned char* buffer = NULL;
|
unsigned char* buffer = NULL;
|
||||||
FAKE_FD fake_fd = { 0 };
|
FAKE_FD fake_fd = { 0 };
|
||||||
FILE* fp = (FILE*)&fake_fd;
|
FILE* fp = (FILE*)&fake_fd;
|
||||||
const char* using_msg = "Using %s MBR\n";
|
const char* using_msg = "Using %s MBR";
|
||||||
|
|
||||||
AnalyzeMBR(hPhysicalDrive, "Drive", FALSE);
|
// AnalyzeMBR(hPhysicalDrive, "Drive", FALSE);
|
||||||
|
|
||||||
if (SelectedDrive.SectorSize < 512)
|
if (SelectedDrive.SectorSize < 512)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -1561,12 +1579,12 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
|
||||||
|
|
||||||
// What follows is really a case statement with complex conditions listed
|
// What follows is really a case statement with complex conditions listed
|
||||||
// by order of preference
|
// by order of preference
|
||||||
if (HAS_WINDOWS(img_report) && (allow_dual_uefi_bios) && (target_type == TT_BIOS))
|
if ((boot_type == BT_IMAGE) && HAS_WINDOWS(img_report) && (allow_dual_uefi_bios) && (target_type == TT_BIOS))
|
||||||
goto windows_mbr;
|
goto windows_mbr;
|
||||||
|
|
||||||
// Forced UEFI (by zeroing the MBR)
|
// Non bootable or forced UEFI (zeroed MBR)
|
||||||
if (target_type == TT_UEFI) {
|
if ((boot_type == BT_NON_BOOTABLE) || (target_type == TT_UEFI)) {
|
||||||
uprintf(using_msg, "zeroed");
|
uprintf(using_msg, "Zeroed");
|
||||||
r = write_zero_mbr(fp);
|
r = write_zero_mbr(fp);
|
||||||
goto notify;
|
goto notify;
|
||||||
}
|
}
|
||||||
|
@ -2623,7 +2641,8 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
}
|
}
|
||||||
|
|
||||||
GetWindowTextU(hLabel, label, sizeof(label));
|
GetWindowTextU(hLabel, label, sizeof(label));
|
||||||
ToValidLabel(label, (fs_type == FS_FAT16) || (fs_type == FS_FAT32) || (fs_type == FS_EXFAT));
|
if (fs_type < FS_EXT2)
|
||||||
|
ToValidLabel(label, (fs_type == FS_FAT16) || (fs_type == FS_FAT32) || (fs_type == FS_EXFAT));
|
||||||
ClusterSize = (DWORD)ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize));
|
ClusterSize = (DWORD)ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize));
|
||||||
if (ClusterSize < 0x200)
|
if (ClusterSize < 0x200)
|
||||||
ClusterSize = 0; // 0 = default cluster size
|
ClusterSize = 0; // 0 = default cluster size
|
||||||
|
@ -2689,9 +2708,13 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
|
|
||||||
// Refresh the drive label - This is needed as Windows may have altered it from
|
// Refresh the drive label - This is needed as Windows may have altered it from
|
||||||
// the name we proposed, and we require an exact label, to patch config files.
|
// the name we proposed, and we require an exact label, to patch config files.
|
||||||
if (!GetVolumeInformationU(drive_name, img_report.usb_label, ARRAYSIZE(img_report.usb_label),
|
if ((fs_type < FS_EXT2) && !GetVolumeInformationU(drive_name, img_report.usb_label,
|
||||||
NULL, NULL, NULL, NULL, 0)) {
|
ARRAYSIZE(img_report.usb_label), NULL, NULL, NULL, NULL, 0)) {
|
||||||
uprintf("Warning: Failed to refresh label: %s", WindowsErrorString());
|
uprintf("Warning: Failed to refresh label: %s", WindowsErrorString());
|
||||||
|
} else if ((fs_type >= FS_EXT2) && (fs_type <= FS_EXT4)) {
|
||||||
|
const char* ext_label = GetExtFsLabel(DriveIndex, 0);
|
||||||
|
if (ext_label != NULL)
|
||||||
|
static_strcpy(img_report.usb_label, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boot_type != BT_NON_BOOTABLE) {
|
if (boot_type != BT_NON_BOOTABLE) {
|
||||||
|
|
|
@ -903,6 +903,10 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
|
||||||
//#define FORCE_URL "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-9.8.0-amd64-netinst.iso"
|
//#define FORCE_URL "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-9.8.0-amd64-netinst.iso"
|
||||||
#if !defined(FORCE_URL)
|
#if !defined(FORCE_URL)
|
||||||
#if defined(RUFUS_TEST)
|
#if defined(RUFUS_TEST)
|
||||||
|
IGNORE_RETVAL(hFile);
|
||||||
|
IGNORE_RETVAL(sig_url);
|
||||||
|
IGNORE_RETVAL(dwCompressedSize);
|
||||||
|
IGNORE_RETVAL(uncompressed_size);
|
||||||
// In test mode, just use our local script
|
// In test mode, just use our local script
|
||||||
static_strcpy(script_path, "D:\\Projects\\Fido\\Fido.ps1");
|
static_strcpy(script_path, "D:\\Projects\\Fido\\Fido.ps1");
|
||||||
#else
|
#else
|
||||||
|
|
55
src/rufus.c
55
src/rufus.c
|
@ -480,7 +480,16 @@ static BOOL SetFileSystemAndClusterSize(char* fs_name)
|
||||||
SelectedDrive.ClusterSize[FS_UDF].Allowed = SINGLE_CLUSTERSIZE_DEFAULT;
|
SelectedDrive.ClusterSize[FS_UDF].Allowed = SINGLE_CLUSTERSIZE_DEFAULT;
|
||||||
SelectedDrive.ClusterSize[FS_UDF].Default = 1;
|
SelectedDrive.ClusterSize[FS_UDF].Default = 1;
|
||||||
|
|
||||||
|
// ext2/ext3/ext4
|
||||||
|
if (advanced_mode_format) {
|
||||||
|
SelectedDrive.ClusterSize[FS_EXT2].Allowed = SINGLE_CLUSTERSIZE_DEFAULT;
|
||||||
|
SelectedDrive.ClusterSize[FS_EXT2].Default = 1;
|
||||||
|
SelectedDrive.ClusterSize[FS_EXT3].Allowed = SINGLE_CLUSTERSIZE_DEFAULT;
|
||||||
|
SelectedDrive.ClusterSize[FS_EXT3].Default = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// ReFS (only supported for Windows 8.1 and later and for fixed disks)
|
// ReFS (only supported for Windows 8.1 and later and for fixed disks)
|
||||||
|
// TODO: Check later versions of Windows 10 for disabled ReFS (IVdsService::QueryFileSystemTypes?)
|
||||||
if (SelectedDrive.DiskSize >= 512*MB) {
|
if (SelectedDrive.DiskSize >= 512*MB) {
|
||||||
if ((nWindowsVersion >= WINDOWS_8_1) && (SelectedDrive.MediaType == FixedMedia)) {
|
if ((nWindowsVersion >= WINDOWS_8_1) && (SelectedDrive.MediaType == FixedMedia)) {
|
||||||
SelectedDrive.ClusterSize[FS_REFS].Allowed = SINGLE_CLUSTERSIZE_DEFAULT;
|
SelectedDrive.ClusterSize[FS_REFS].Allowed = SINGLE_CLUSTERSIZE_DEFAULT;
|
||||||
|
@ -668,7 +677,8 @@ static void EnableMBRBootOptions(BOOL enable, BOOL remove_checkboxes)
|
||||||
BOOL actual_enable_fix = enable;
|
BOOL actual_enable_fix = enable;
|
||||||
static UINT uXPartChecked = BST_UNCHECKED;
|
static UINT uXPartChecked = BST_UNCHECKED;
|
||||||
|
|
||||||
if ((partition_type != PARTITION_STYLE_MBR) || (target_type != TT_BIOS) || ((boot_type == BT_IMAGE) && !IS_BIOS_BOOTABLE(img_report))) {
|
if ((partition_type != PARTITION_STYLE_MBR) || (target_type != TT_BIOS) || (boot_type == BT_NON_BOOTABLE) ||
|
||||||
|
((boot_type == BT_IMAGE) && !IS_BIOS_BOOTABLE(img_report))) {
|
||||||
// These options cannot apply if we aren't using MBR+BIOS, or are using an image that isn't BIOS bootable
|
// These options cannot apply if we aren't using MBR+BIOS, or are using an image that isn't BIOS bootable
|
||||||
actual_enable_mbr = FALSE;
|
actual_enable_mbr = FALSE;
|
||||||
actual_enable_fix = FALSE;
|
actual_enable_fix = FALSE;
|
||||||
|
@ -701,6 +711,23 @@ static void EnableMBRBootOptions(BOOL enable, BOOL remove_checkboxes)
|
||||||
EnableWindow(hDiskID, actual_enable_mbr);
|
EnableWindow(hDiskID, actual_enable_mbr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void EnableExtendedLabel(BOOL enable)
|
||||||
|
{
|
||||||
|
HWND hCtrl = GetDlgItem(hMainDialog, IDC_EXTENDED_LABEL);
|
||||||
|
static UINT checked, state = 0;
|
||||||
|
|
||||||
|
if (!enable && IsWindowEnabled(hCtrl) && (state != 1)) {
|
||||||
|
checked = IsChecked(IDC_EXTENDED_LABEL);
|
||||||
|
CheckDlgButton(hMainDialog, IDC_EXTENDED_LABEL, BST_UNCHECKED);
|
||||||
|
state = 1;
|
||||||
|
} else if (enable && !IsWindowEnabled(hCtrl) && (state != 2)) {
|
||||||
|
if (state != 0)
|
||||||
|
CheckDlgButton(hMainDialog, IDC_EXTENDED_LABEL, checked);
|
||||||
|
state = 2;
|
||||||
|
}
|
||||||
|
EnableWindow(hCtrl, enable);
|
||||||
|
}
|
||||||
|
|
||||||
static void EnableQuickFormat(BOOL enable)
|
static void EnableQuickFormat(BOOL enable)
|
||||||
{
|
{
|
||||||
HWND hCtrl = GetDlgItem(hMainDialog, IDC_QUICK_FORMAT);
|
HWND hCtrl = GetDlgItem(hMainDialog, IDC_QUICK_FORMAT);
|
||||||
|
@ -753,7 +780,7 @@ static void EnableBootOptions(BOOL enable, BOOL remove_checkboxes)
|
||||||
EnableQuickFormat(actual_enable);
|
EnableQuickFormat(actual_enable);
|
||||||
EnableWindow(GetDlgItem(hMainDialog, IDC_BAD_BLOCKS), actual_enable_bb);
|
EnableWindow(GetDlgItem(hMainDialog, IDC_BAD_BLOCKS), actual_enable_bb);
|
||||||
EnableWindow(GetDlgItem(hMainDialog, IDC_NB_PASSES), actual_enable_bb);
|
EnableWindow(GetDlgItem(hMainDialog, IDC_NB_PASSES), actual_enable_bb);
|
||||||
EnableWindow(GetDlgItem(hMainDialog, IDC_EXTENDED_LABEL), actual_enable);
|
EnableExtendedLabel((fs_type < FS_EXT2) ? actual_enable : FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle controls according to operation
|
// Toggle controls according to operation
|
||||||
|
@ -1266,11 +1293,16 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
||||||
static_sprintf(tmp, "%s/%s-%s/%s", FILES_URL, grub, img_report.grub2_version, core_img);
|
static_sprintf(tmp, "%s/%s-%s/%s", FILES_URL, grub, img_report.grub2_version, core_img);
|
||||||
grub2_len = (long)DownloadSignedFile(tmp, core_img, hMainDialog, FALSE);
|
grub2_len = (long)DownloadSignedFile(tmp, core_img, hMainDialog, FALSE);
|
||||||
if ((grub2_len == 0) && (DownloadStatus == 404)) {
|
if ((grub2_len == 0) && (DownloadStatus == 404)) {
|
||||||
|
// Manjaro (always them!) are using "2.03.5" as identifier, so we must detect first dot...
|
||||||
|
BOOL first_dot = TRUE;
|
||||||
// Couldn't locate the file on the server => try to download without the version extra
|
// Couldn't locate the file on the server => try to download without the version extra
|
||||||
uprintf("Extended version was not found, trying main version...");
|
uprintf("Extended version was not found, trying main version...");
|
||||||
static_strcpy(tmp2, img_report.grub2_version);
|
static_strcpy(tmp2, img_report.grub2_version);
|
||||||
// Isolate the #.### part
|
// Isolate the #.### part
|
||||||
for (i = 0; ((tmp2[i] >= '0') && (tmp2[i] <= '9')) || (tmp2[i] == '.'); i++);
|
for (i = 0; ((tmp2[i] >= '0') && (tmp2[i] <= '9')) || ((tmp2[i] == '.') && first_dot); i++) {
|
||||||
|
if (tmp2[i] == '.')
|
||||||
|
first_dot = FALSE;
|
||||||
|
}
|
||||||
tmp2[i] = 0;
|
tmp2[i] = 0;
|
||||||
static_sprintf(tmp, "%s/%s-%s/%s", FILES_URL, grub, tmp2, core_img);
|
static_sprintf(tmp, "%s/%s-%s/%s", FILES_URL, grub, tmp2, core_img);
|
||||||
grub2_len = (long)DownloadSignedFile(tmp, core_img, hMainDialog, FALSE);
|
grub2_len = (long)DownloadSignedFile(tmp, core_img, hMainDialog, FALSE);
|
||||||
|
@ -1894,15 +1926,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
#ifdef RUFUS_TEST
|
#ifdef RUFUS_TEST
|
||||||
if (LOWORD(wParam) == IDC_TEST) {
|
if (LOWORD(wParam) == IDC_TEST) {
|
||||||
// uprintf(" IID_IVdsVolume: %s", GuidToString(&IID_IVdsVolume));
|
DWORD DriveIndex = (DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList));
|
||||||
// uprintf(" IID_IVdsVolumeMF3: %s", GuidToString(&IID_IVdsVolumeMF3));
|
uprintf("label = '%s'", GetExtFsLabel(DriveIndex, 1));
|
||||||
nDeviceIndex = ComboBox_GetCurSel(hDeviceList);
|
|
||||||
// AltMountVolume2("G:", 3);
|
|
||||||
AltMountVolume((DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex), 3);
|
|
||||||
// AltUnmountVolume("P:");
|
|
||||||
// uprintf("%s", GetLogicalName((DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex), 0, FALSE, FALSE));
|
|
||||||
// uprintf("%s", GetLogicalName((DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex), 1, FALSE, FALSE));
|
|
||||||
// uprintf("%s", GetLogicalName((DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex), 2, FALSE, FALSE));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2035,6 +2060,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
advanced_mode_format = !advanced_mode_format;
|
advanced_mode_format = !advanced_mode_format;
|
||||||
WriteSettingBool(SETTING_ADVANCED_MODE_FORMAT, advanced_mode_format);
|
WriteSettingBool(SETTING_ADVANCED_MODE_FORMAT, advanced_mode_format);
|
||||||
ToggleAdvancedFormatOptions(advanced_mode_format);
|
ToggleAdvancedFormatOptions(advanced_mode_format);
|
||||||
|
if (selected_fs == FS_UNKNOWN)
|
||||||
|
selected_fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
|
||||||
|
SetFileSystemAndClusterSize(NULL);
|
||||||
|
SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE_INTERNAL << 16) | IDC_FILE_SYSTEM,
|
||||||
|
ComboBox_GetCurSel(hFileSystem));
|
||||||
break;
|
break;
|
||||||
case IDC_LABEL:
|
case IDC_LABEL:
|
||||||
if (HIWORD(wParam) == EN_CHANGE) {
|
if (HIWORD(wParam) == EN_CHANGE) {
|
||||||
|
@ -2141,6 +2171,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
selected_fs = fs_type;
|
selected_fs = fs_type;
|
||||||
EnableMBRBootOptions(TRUE, FALSE);
|
EnableMBRBootOptions(TRUE, FALSE);
|
||||||
SetMBRProps();
|
SetMBRProps();
|
||||||
|
EnableExtendedLabel((fs_type < FS_EXT2));
|
||||||
break;
|
break;
|
||||||
case IDC_BOOT_SELECTION:
|
case IDC_BOOT_SELECTION:
|
||||||
if (HIWORD(wParam) != CBN_SELCHANGE)
|
if (HIWORD(wParam) != CBN_SELCHANGE)
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 3.6.1531"
|
CAPTION "Rufus 3.6.1532"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
@ -394,8 +394,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 3,6,1531,0
|
FILEVERSION 3,6,1532,0
|
||||||
PRODUCTVERSION 3,6,1531,0
|
PRODUCTVERSION 3,6,1532,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -413,13 +413,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://akeo.ie"
|
VALUE "Comments", "https://akeo.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "3.6.1531"
|
VALUE "FileVersion", "3.6.1532"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
|
||||||
VALUE "OriginalFilename", "rufus-3.6.exe"
|
VALUE "OriginalFilename", "rufus-3.6.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "3.6.1531"
|
VALUE "ProductVersion", "3.6.1532"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue