mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[ext2fs] don't override FormatStatus on user cancel
This commit is contained in:
		
							parent
							
								
									2538974318
								
							
						
					
					
						commit
						f8c951f3d7
					
				
					 2 changed files with 18 additions and 17 deletions
				
			
		|  | @ -220,6 +220,7 @@ const char* GetExtFsLabel(DWORD DriveIndex, uint64_t PartitionOffset) | |||
| 
 | ||||
| #define TEST_IMG_PATH               "\\??\\C:\\tmp\\disk.img" | ||||
| #define TEST_IMG_SIZE               4000		// Size in MB
 | ||||
| #define SET_EXT2_FORMAT_ERROR(x)    if (!IS_ERROR(FormatStatus)) FormatStatus = ext2_last_winerror(x) | ||||
| 
 | ||||
| BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LPCSTR FSName, LPCSTR Label, DWORD Flags) | ||||
| { | ||||
|  | @ -289,7 +290,7 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP | |||
| 	// Figure out the volume size and block size
 | ||||
| 	r = ext2fs_get_device_size2(volume_name, KB, &size); | ||||
| 	if ((r != 0) || (size == 0)) { | ||||
| 		FormatStatus = ext2_last_winerror(ERROR_READ_FAULT); | ||||
| 		SET_EXT2_FORMAT_ERROR(ERROR_READ_FAULT); | ||||
| 		uprintf("Could not read device size: %s", error_message(r)); | ||||
| 		goto out; | ||||
| 	} | ||||
|  | @ -313,7 +314,7 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP | |||
| 	// ext2 and ext3 have a can only accomodate up to Blocksize * 2^32 sized volumes
 | ||||
| 	if (((strcmp(FSName, FileSystemLabel[FS_EXT2]) == 0) || (strcmp(FSName, FileSystemLabel[FS_EXT3]) == 0)) && | ||||
| 		(size >= 0x100000000ULL)) { | ||||
| 		FormatStatus = ext2_last_winerror(ERROR_INVALID_VOLUME_SIZE); | ||||
| 		SET_EXT2_FORMAT_ERROR(ERROR_INVALID_VOLUME_SIZE); | ||||
| 		uprintf("Volume size is too large for ext2 or ext3"); | ||||
| 		goto out; | ||||
| 	} | ||||
|  | @ -341,7 +342,7 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP | |||
| 	// Now that we have set our base features, initialize a virtual superblock
 | ||||
| 	r = ext2fs_initialize(volume_name, EXT2_FLAG_EXCLUSIVE | EXT2_FLAG_64BITS, &features, manager, &ext2fs); | ||||
| 	if (r != 0) { | ||||
| 		FormatStatus = ext2_last_winerror(ERROR_INVALID_DATA); | ||||
| 		SET_EXT2_FORMAT_ERROR(ERROR_INVALID_DATA); | ||||
| 		uprintf("Could not initialize %s features: %s", FSName, error_message(r)); | ||||
| 		goto out; | ||||
| 	} | ||||
|  | @ -352,7 +353,7 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP | |||
| 	r = io_channel_write_blk64(ext2fs->io, 0, 16, buf); | ||||
| 	safe_free(buf); | ||||
| 	if (r != 0) { | ||||
| 		FormatStatus = ext2_last_winerror(ERROR_WRITE_FAULT); | ||||
| 		SET_EXT2_FORMAT_ERROR(ERROR_WRITE_FAULT); | ||||
| 		uprintf("Could not zero %s superblock area: %s", FSName, error_message(r)); | ||||
| 		goto out; | ||||
| 	} | ||||
|  | @ -370,7 +371,7 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP | |||
| 
 | ||||
| 	r = ext2fs_allocate_tables(ext2fs); | ||||
| 	if (r != 0) { | ||||
| 		FormatStatus = ext2_last_winerror(ERROR_INVALID_DATA); | ||||
| 		SET_EXT2_FORMAT_ERROR(ERROR_INVALID_DATA); | ||||
| 		uprintf("Could not allocate %s tables: %s", FSName, error_message(r)); | ||||
| 		goto out; | ||||
| 	} | ||||
|  | @ -392,7 +393,7 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP | |||
| 			* EXT2_INODE_SIZE(ext2fs->super), EXT2_BLOCK_SIZE(ext2fs->super)); | ||||
| 		r = ext2fs_zero_blocks2(ext2fs, cur, count, &cur, &count); | ||||
| 		if (r != 0) { | ||||
| 			FormatStatus = ext2_last_winerror(ERROR_WRITE_FAULT); | ||||
| 			SET_EXT2_FORMAT_ERROR(ERROR_WRITE_FAULT); | ||||
| 			uprintf("\r\nCould not zero inode set at position %llu (%d blocks): %s", cur, count, error_message(r)); | ||||
| 			goto out; | ||||
| 		} | ||||
|  | @ -402,14 +403,14 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP | |||
| 	// Create root and lost+found dirs
 | ||||
| 	r = ext2fs_mkdir(ext2fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0); | ||||
| 	if (r != 0) { | ||||
| 		FormatStatus = ext2_last_winerror(ERROR_DIR_NOT_ROOT); | ||||
| 		SET_EXT2_FORMAT_ERROR(ERROR_DIR_NOT_ROOT); | ||||
| 		uprintf("Failed to create %s root dir: %s", FSName, error_message(r)); | ||||
| 		goto out; | ||||
| 	} | ||||
| 	ext2fs->umask = 077; | ||||
| 	r = ext2fs_mkdir(ext2fs, EXT2_ROOT_INO, 0, "lost+found"); | ||||
| 	if (r != 0) { | ||||
| 		FormatStatus = ext2_last_winerror(ERROR_DIR_NOT_ROOT); | ||||
| 		SET_EXT2_FORMAT_ERROR(ERROR_DIR_NOT_ROOT); | ||||
| 		uprintf("Failed to create %s 'lost+found' dir: %s", FSName, error_message(r)); | ||||
| 		goto out; | ||||
| 	} | ||||
|  | @ -421,14 +422,14 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP | |||
| 
 | ||||
| 	r = ext2fs_mark_inode_bitmap2(ext2fs->inode_map, EXT2_BAD_INO); | ||||
| 	if (r != 0) { | ||||
| 		FormatStatus = ext2_last_winerror(ERROR_WRITE_FAULT); | ||||
| 		SET_EXT2_FORMAT_ERROR(ERROR_WRITE_FAULT); | ||||
| 		uprintf("Could not set inode bitmaps: %s", error_message(r)); | ||||
| 		goto out; | ||||
| 	} | ||||
| 	ext2fs_inode_alloc_stats(ext2fs, EXT2_BAD_INO, 1); | ||||
| 	r = ext2fs_update_bb_inode(ext2fs, NULL); | ||||
| 	if (r != 0) { | ||||
| 		FormatStatus = ext2_last_winerror(ERROR_WRITE_FAULT); | ||||
| 		SET_EXT2_FORMAT_ERROR(ERROR_WRITE_FAULT); | ||||
| 		uprintf("Could not set inode stats: %s", error_message(r)); | ||||
| 		goto out; | ||||
| 	} | ||||
|  | @ -444,7 +445,7 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP | |||
| 		r = ext2fs_add_journal_inode(ext2fs, journal_size, EXT2_MKJOURNAL_NO_MNT_CHECK | ((Flags & FP_QUICK) ? EXT2_MKJOURNAL_LAZYINIT : 0)); | ||||
| 		uprintfs("\r\n"); | ||||
| 		if (r != 0) { | ||||
| 			FormatStatus = ext2_last_winerror(ERROR_WRITE_FAULT); | ||||
| 			SET_EXT2_FORMAT_ERROR(ERROR_WRITE_FAULT); | ||||
| 			uprintf("Could not create %s journal: %s", FSName, error_message(r)); | ||||
| 			goto out; | ||||
| 		} | ||||
|  | @ -482,7 +483,7 @@ BOOL FormatExtFs(DWORD DriveIndex, uint64_t PartitionOffset, DWORD BlockSize, LP | |||
| 	// Finally we can call close() to get the file system gets created
 | ||||
| 	r = ext2fs_close(ext2fs); | ||||
| 	if (r != 0) { | ||||
| 		FormatStatus = ext2_last_winerror(ERROR_WRITE_FAULT); | ||||
| 		SET_EXT2_FORMAT_ERROR(ERROR_WRITE_FAULT); | ||||
| 		uprintf("Could not create %s volume: %s", FSName, error_message(r)); | ||||
| 		goto out; | ||||
| 	} | ||||
|  |  | |||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | |||
| IDD_DIALOG DIALOGEX 12, 12, 232, 326 | ||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||
| EXSTYLE WS_EX_ACCEPTFILES | ||||
| CAPTION "Rufus 3.13.1719" | ||||
| CAPTION "Rufus 3.13.1720" | ||||
| FONT 9, "Segoe UI Symbol", 400, 0, 0x0 | ||||
| BEGIN | ||||
|     LTEXT           "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP | ||||
|  | @ -395,8 +395,8 @@ END | |||
| // | ||||
| 
 | ||||
| VS_VERSION_INFO VERSIONINFO | ||||
|  FILEVERSION 3,13,1719,0 | ||||
|  PRODUCTVERSION 3,13,1719,0 | ||||
|  FILEVERSION 3,13,1720,0 | ||||
|  PRODUCTVERSION 3,13,1720,0 | ||||
|  FILEFLAGSMASK 0x3fL | ||||
| #ifdef _DEBUG | ||||
|  FILEFLAGS 0x1L | ||||
|  | @ -414,13 +414,13 @@ BEGIN | |||
|             VALUE "Comments", "https://rufus.ie" | ||||
|             VALUE "CompanyName", "Akeo Consulting" | ||||
|             VALUE "FileDescription", "Rufus" | ||||
|             VALUE "FileVersion", "3.13.1719" | ||||
|             VALUE "FileVersion", "3.13.1720" | ||||
|             VALUE "InternalName", "Rufus" | ||||
|             VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)" | ||||
|             VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" | ||||
|             VALUE "OriginalFilename", "rufus-3.13.exe" | ||||
|             VALUE "ProductName", "Rufus" | ||||
|             VALUE "ProductVersion", "3.13.1719" | ||||
|             VALUE "ProductVersion", "3.13.1720" | ||||
|         END | ||||
|     END | ||||
|     BLOCK "VarFileInfo" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue