diff --git a/_chver.sh b/_chver.sh index 6ea1389f..755fdd98 100644 --- a/_chver.sh +++ b/_chver.sh @@ -43,3 +43,4 @@ sed -f cmd.sed src/rufus.rc > src/rufus.rc~ sed 's/$/\r/' src/rufus.rc~ > src/rufus.rc rm src/rufus.rc~ rm cmd.sed +source _autogen.sh diff --git a/configure b/configure index 81c7c2db..7c30c72a 100644 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for rufus 1.0.1. +# Generated by GNU Autoconf 2.68 for rufus 1.0.2. # # Report bugs to . # @@ -559,8 +559,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='rufus' PACKAGE_TARNAME='rufus' -PACKAGE_VERSION='1.0.1' -PACKAGE_STRING='rufus 1.0.1' +PACKAGE_VERSION='1.0.2' +PACKAGE_STRING='rufus 1.0.2' PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues' PACKAGE_URL='https://github.com/pbatard/rufus' @@ -1200,7 +1200,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures rufus 1.0.1 to adapt to many kinds of systems. +\`configure' configures rufus 1.0.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1266,7 +1266,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of rufus 1.0.1:";; + short | recursive ) echo "Configuration of rufus 1.0.2:";; esac cat <<\_ACEOF @@ -1354,7 +1354,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -rufus configure 1.0.1 +rufus configure 1.0.2 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1409,7 +1409,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by rufus $as_me 1.0.1, which was +It was created by rufus $as_me 1.0.2, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2224,7 +2224,7 @@ fi # Define the identity of the package. PACKAGE='rufus' - VERSION='1.0.1' + VERSION='1.0.2' cat >>confdefs.h <<_ACEOF @@ -3360,7 +3360,7 @@ $as_echo "#define _GNU_SOURCE /**/" >>confdefs.h # AC_MSG_ERROR([unsupported development environment]) #esac -AM_CFLAGS="${AM_CFLAGS} -D__MSVCRT_VERSION__=0x700 -DWINVER=0x501 -D_WIN32_IE=0x501" +AM_CFLAGS="${AM_CFLAGS} -DWINVER=0x501 -D_WIN32_WINNT=0x501 -D_WIN32_IE=0x501" AM_LDFLAGS="${AM_LDFLAGS} -Wl,-no-undefined" # Debug logging @@ -3980,7 +3980,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by rufus $as_me 1.0.1, which was +This file was extended by rufus $as_me 1.0.2, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4034,7 +4034,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -rufus config.status 1.0.1 +rufus config.status 1.0.2 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 6320e096..a1e36ec6 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions]) # AC_MSG_ERROR([unsupported development environment]) #esac -AM_CFLAGS="${AM_CFLAGS} -D__MSVCRT_VERSION__=0x700 -DWINVER=0x501 -D_WIN32_IE=0x501" +AM_CFLAGS="${AM_CFLAGS} -DWINVER=0x501 -D_WIN32_WINNT=0x501 -D_WIN32_IE=0x501" AM_LDFLAGS="${AM_LDFLAGS} -Wl,-no-undefined" # Debug logging diff --git a/src/badblocks.c b/src/badblocks.c index 8e9e13dd..046b1a68 100644 --- a/src/badblocks.c +++ b/src/badblocks.c @@ -34,7 +34,6 @@ #include #include #include -//#include #include #include #include @@ -46,10 +45,9 @@ #include "file.h" /* - *From e2fsprogs/e2fsck/badblocks.c + *From e2fsprogs/lib/ext2fs/badblocks.c */ -static errcode_t make_u32_list(int size, int num, __u32 *list, - ext2_u32_list *ret) +static errcode_t make_u32_list(int size, int num, __u32 *list, ext2_u32_list *ret) { ext2_u32_list bb; @@ -87,13 +85,11 @@ static errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, int size static errcode_t ext2fs_u32_list_add(ext2_u32_list bb, __u32 blk) { int i, j; - unsigned long old_size; __u32* old_bb_list = bb->list; EXT2_CHECK_MAGIC(bb, EXT2_ET_MAGIC_BADBLOCKS_LIST); if (bb->num >= bb->size) { - old_size = bb->size * sizeof(__u32); bb->size += 100; bb->list = realloc(bb->list, bb->size * sizeof(__u32)); if (bb->list == NULL) { @@ -187,31 +183,6 @@ static int ext2fs_badblocks_list_test(ext2_badblocks_list bb, blk_t blk) return ext2fs_u32_list_test((ext2_u32_list) bb, (__u32) blk); } -/* - * Remove a block from the badblock list - */ -int ext2fs_u32_list_del(ext2_u32_list bb, __u32 blk) -{ - int remloc, i; - - if (bb->num == 0) - return -1; - - remloc = ext2fs_u32_list_find(bb, blk); - if (remloc < 0) - return -1; - - for (i = remloc ; i < bb->num-1; i++) - bb->list[i] = bb->list[i+1]; - bb->num--; - return 0; -} - -static void ext2fs_badblocks_list_del(ext2_u32_list bb, __u32 blk) -{ - ext2fs_u32_list_del(bb, blk); -} - static errcode_t ext2fs_u32_list_iterate_begin(ext2_u32_list bb, ext2_u32_iterate *ret) { @@ -280,39 +251,12 @@ static void ext2fs_badblocks_list_iterate_end(ext2_badblocks_iterate iter) } -static int ext2fs_u32_list_equal(ext2_u32_list bb1, ext2_u32_list bb2) -{ - EXT2_CHECK_MAGIC(bb1, EXT2_ET_MAGIC_BADBLOCKS_LIST); - EXT2_CHECK_MAGIC(bb2, EXT2_ET_MAGIC_BADBLOCKS_LIST); - - if (bb1->num != bb2->num) - return 0; - - if (memcmp(bb1->list, bb2->list, bb1->num * sizeof(blk_t)) != 0) - return 0; - return 1; -} - -static int ext2fs_badblocks_equal(ext2_badblocks_list bb1, ext2_badblocks_list bb2) -{ - return ext2fs_u32_list_equal((ext2_u32_list) bb1, - (ext2_u32_list) bb2); -} - -static int ext2fs_u32_list_count(ext2_u32_list bb) -{ - return bb->num; -} - /* - * from e2fsprogs\misc\badblocks.c + * from e2fsprogs/misc/badblocks.c */ static int v_flag = 2; /* verbose */ -static int w_flag = 0; /* do r/w test: 0=no, 1=yes, - * 2=non-destructive */ static int s_flag = 1; /* show progress of test */ static int t_flag = 0; /* number of test patterns */ -static int t_max = 0; /* allocated test patterns */ static unsigned int *t_patts = NULL; /* test patterns */ // TODO: set this from parameter static unsigned int max_bb = 32; /* Abort test if more than this number of bad blocks has been encountered */ @@ -336,13 +280,19 @@ static ext2_badblocks_iterate bb_iter = NULL; enum error_types { READ_ERROR, WRITE_ERROR, CORRUPTION_ERROR }; static __inline void *allocate_buffer(size_t size) { - // TODO: requires -D__MSVCRT_VERSION__=0x700 for MinGW - // find out if older XP platforms might miss it +#ifdef __MINGW32__ + return __mingw_aligned_malloc(size, sys_page_size); +#else return _aligned_malloc(size, sys_page_size); +#endif } static __inline void free_buffer(void* p) { +#ifdef __MINGW32__ + __mingw_aligned_free(p); +#else _aligned_free(p); +#endif } /* @@ -351,16 +301,16 @@ static __inline void free_buffer(void* p) { */ static int bb_output (blk_t bad, enum error_types error_type) { - errcode_t errcode; + errcode_t error_code; if (ext2fs_badblocks_list_test(bb_list, bad)) return 0; uprintf("%lu\n", (unsigned long) bad); - errcode = ext2fs_badblocks_list_add(bb_list, bad); - if (errcode) { - uprintf("Error %d adding to in-memory bad block list", errcode); + error_code = ext2fs_badblocks_list_add(bb_list, bad); + if (error_code) { + uprintf("Error %d adding to in-memory bad block list", error_code); exit (1); } @@ -453,7 +403,7 @@ static int do_read (HANDLE hDrive, unsigned char * buffer, int tryout, int block blk_t current_block) { long got; - DWORD tv1, tv2; +// DWORD tv1, tv2; #define NANOSEC (1000000000L) #define MILISEC (1000L) @@ -465,12 +415,12 @@ static int do_read (HANDLE hDrive, unsigned char * buffer, int tryout, int block print_status(); /* Try the read */ - if (d_flag) - tv1 = GetTickCount(); +// if (d_flag) +// tv1 = GetTickCount(); got = read_sectors(hDrive, block_size, current_block, tryout, buffer); // read (dev, buffer, tryout * block_size); - if (d_flag) - tv2 = GetTickCount(); +// if (d_flag) +// tv2 = GetTickCount(); if (got < 0) got = 0; if (got & 511) @@ -549,13 +499,13 @@ static unsigned int test_ro (HANDLE hDrive, blk_t last_block, int tryout; int got; unsigned int bb_count = 0; - errcode_t errcode; + errcode_t error_code; blk_t recover_block = ~0; - errcode = ext2fs_badblocks_list_iterate_begin(bb_list,&bb_iter); - if (errcode) { + error_code = ext2fs_badblocks_list_iterate_begin(bb_list,&bb_iter); + if (error_code) { // TODO: set FormatStatus - uprintf("errcode %d while beginning bad block list iteration\n", errcode); + uprintf("errcode %d while beginning bad block list iteration\n", error_code); return 0; } do { @@ -785,16 +735,16 @@ static unsigned int test_nd(HANDLE hDrive, blk_t last_block, /* This is static to prevent being clobbered by the longjmp */ static int num_saved; jmp_buf terminate_env; - errcode_t errcode; + errcode_t error_code; unsigned long buf_used; static unsigned int bb_count; int granularity = blocks_at_once; blk_t recover_block = ~0; bb_count = 0; - errcode = ext2fs_badblocks_list_iterate_begin(bb_list,&bb_iter); - if (errcode) { - uprintf("Error %d while beginning bad block list iteration", errcode); + error_code = ext2fs_badblocks_list_iterate_begin(bb_list,&bb_iter); + if (error_code) { + uprintf("Error %d while beginning bad block list iteration", error_code); exit (1); } do { @@ -867,7 +817,7 @@ static unsigned int test_nd(HANDLE hDrive, blk_t last_block, } break; } - got = tryout = granularity - buf_used; + tryout = granularity - buf_used; if (next_bad) { if (currently_testing == next_bad) { /* fprintf (out, "%lu\n", nextbad); */ @@ -916,7 +866,6 @@ static unsigned int test_nd(HANDLE hDrive, blk_t last_block, test_ptr += got * block_size; currently_testing += got; if (got != tryout) { - tryout = 1; if (recover_block == ~0) recover_block = currently_testing - got + blocks_at_once; @@ -1011,9 +960,9 @@ static unsigned int test_nd(HANDLE hDrive, blk_t last_block, return bb_count; } -int BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int block_size) +int BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int block_size, int test_type) { - errcode_t errcode; + errcode_t error_code; unsigned int blocks_at_once = 64; unsigned int (*test_func)(HANDLE, blk_t, int, blk_t, @@ -1023,13 +972,23 @@ int BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int block_size) int bb_count; blk_t first_block = 0, last_block = (blk_t)disk_size/block_size; - errcode = ext2fs_badblocks_list_create(&bb_list, 0); - if (errcode) { - uprintf("Error %d while creating in-memory bad blocks list", errcode); + error_code = ext2fs_badblocks_list_create(&bb_list, 0); + if (error_code) { + uprintf("Error %d while creating in-memory bad blocks list", error_code); return -1; } - test_func = test_rw; + switch(test_type) { + case BADBLOCKS_RW: + test_func = test_rw; + break; + case BADBLOCKS_ND: + test_func = test_nd; + break; + default: + test_func = test_ro; + break; + } time_start = GetTickCount(); do { bb_count = test_func(hPhysicalDrive, last_block, block_size, first_block, blocks_at_once); diff --git a/src/badblocks.h b/src/badblocks.h index 20e23963..5d4e7dd9 100644 --- a/src/badblocks.h +++ b/src/badblocks.h @@ -54,7 +54,14 @@ struct ext2_struct_u32_iterate { int ptr; }; +/* Test type */ +enum { + BADBLOCKS_RO, /* Read-only */ + BADBLOCKS_RW, /* *DESTRUCTIVE* read-write */ + BADBLOCKS_ND /* non-destructive read-write */ +}; + /* * Shared prototypes */ -BOOL BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int block_size); +int BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int block_size, int test_type); diff --git a/src/file.c b/src/file.c index 31c2e319..6d618f33 100644 --- a/src/file.c +++ b/src/file.c @@ -28,7 +28,7 @@ int write_sectors(HANDLE hDrive, size_t SectorSize, const void *pBuf) { LARGE_INTEGER ptr; - DWORD Size = 0; + DWORD Size = (DWORD)(nSectors*SectorSize); ptr.QuadPart = StartSector*SectorSize; if(!SetFilePointerEx(hDrive, ptr, NULL, FILE_BEGIN)) @@ -37,7 +37,7 @@ int write_sectors(HANDLE hDrive, size_t SectorSize, return -1; } - if((!WriteFile(hDrive, pBuf, (DWORD)nSectors*SectorSize, &Size, NULL)) || (Size != nSectors*SectorSize)) + if((!WriteFile(hDrive, pBuf, Size, &Size, NULL)) || (Size != nSectors*SectorSize)) { uprintf("write_sectors: Write error - %s\n", WindowsErrorString()); uprintf(" StartSector:%0X, nSectors:%0X, SectorSize:%0X\n", StartSector, nSectors, SectorSize); @@ -53,7 +53,7 @@ int read_sectors(HANDLE hDrive, size_t SectorSize, void *pBuf) { LARGE_INTEGER ptr; - DWORD Size = 0; + DWORD Size = (DWORD)(nSectors*SectorSize); ptr.QuadPart = StartSector*SectorSize; if(!SetFilePointerEx(hDrive, ptr, NULL, FILE_BEGIN)) @@ -62,7 +62,7 @@ int read_sectors(HANDLE hDrive, size_t SectorSize, return -1; } - if((!ReadFile(hDrive, pBuf, (DWORD)nSectors*SectorSize, &Size, NULL)) || (Size != nSectors*SectorSize)) + if((!ReadFile(hDrive, pBuf, Size, &Size, NULL)) || (Size != nSectors*SectorSize)) { uprintf("read_sectors: Read error - %s\n", WindowsErrorString()); uprintf(" StartSector:%0X, nSectors:%0X, SectorSize:%0X\n", StartSector, nSectors, SectorSize); diff --git a/src/format.c b/src/format.c index 7afdf6be..3eabd3cc 100644 --- a/src/format.c +++ b/src/format.c @@ -331,7 +331,8 @@ void __cdecl FormatThread(void* param) goto out; } - if (BadBlocks(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.Geometry.BytesPerSector)) { + if (BadBlocks(hPhysicalDrive, SelectedDrive.DiskSize, + SelectedDrive.Geometry.BytesPerSector, BADBLOCKS_RW)) { // TODO: report block failure number, etc uprintf("Bad blocks check failed.\n"); goto out; diff --git a/src/rufus.rc b/src/rufus.rc index 255809c5..63008469 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 278 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.0.2.77" +CAPTION "Rufus v1.0.2.78" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,236,50,14 @@ -65,7 +65,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP CONTROL "https://github.com/pbatard/rufus",IDC_ABOUT_RUFUS_URL, "SysLink",WS_TABSTOP,46,47,114,9 - LTEXT "Version 1.0.2 (Build 77)",IDC_STATIC,46,19,78,8 + LTEXT "Version 1.0.2 (Build 78)",IDC_STATIC,46,19,78,8 PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 @@ -164,8 +164,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,2,77 - PRODUCTVERSION 1,0,2,77 + FILEVERSION 1,0,2,78 + PRODUCTVERSION 1,0,2,78 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -182,13 +182,13 @@ BEGIN BEGIN VALUE "CompanyName", "akeo.ie" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.0.2.77" + VALUE "FileVersion", "1.0.2.78" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.0.2.77" + VALUE "ProductVersion", "1.0.2.78" END END BLOCK "VarFileInfo"