Add some synchronisation points, should help to deal with unexpected program termination

This commit is contained in:
Christophe Grenier 2007-12-02 21:21:18 +01:00
parent 50d67341a5
commit 920b5e4ff3
8 changed files with 22 additions and 4 deletions

View file

@ -803,6 +803,7 @@ int fat32_boot_sector(disk_t *disk_car, partition_t *partition, const int verbos
{
display_message("Write error: Can't overwrite FAT32 backup boot sector\n");
}
disk_car->sync(disk_car);
rescan=1;
}
break;
@ -814,6 +815,7 @@ int fat32_boot_sector(disk_t *disk_car, partition_t *partition, const int verbos
{
display_message("Write error: Can't overwrite FAT32 boot sector\n");
}
disk_car->sync(disk_car);
rescan=1;
}
break;
@ -1039,6 +1041,7 @@ int ntfs_boot_sector(disk_t *disk_car, partition_t *partition, const int verbose
{
display_message("Write error: Can't overwrite NTFS backup boot sector\n");
}
disk_car->sync(disk_car);
rescan=1;
}
break;
@ -1050,6 +1053,7 @@ int ntfs_boot_sector(disk_t *disk_car, partition_t *partition, const int verbose
{
display_message("Write error: Can't overwrite NTFS boot sector\n");
}
disk_car->sync(disk_car);
rescan=1;
}
break;
@ -1260,6 +1264,7 @@ int HFS_HFSP_boot_sector(disk_t *disk_car, partition_t *partition, const int ver
{
display_message("Write error: Can't overwrite HFS/HFS+ backup superblock\n");
}
disk_car->sync(disk_car);
rescan=1;
}
break;
@ -1271,6 +1276,7 @@ int HFS_HFSP_boot_sector(disk_t *disk_car, partition_t *partition, const int ver
{
display_message("Write error: Can't overwrite HFS/HFS+ main superblock\n");
}
disk_car->sync(disk_car);
rescan=1;
}
break;

View file

@ -1022,6 +1022,7 @@ static void menu_write_fat_boot_sector(disk_t *disk_car, partition_t *partition,
if(disk_car->write(disk_car,DEFAULT_SECTOR_SIZE, newboot, partition->part_offset)!=0)
err=1;
}
disk_car->sync(disk_car);
if(err==1)
{
display_message("Write error: Can't write new FAT boot sector\n");
@ -2917,6 +2918,10 @@ int repair_FAT_table(disk_t *disk_car, partition_t *partition, const int verbose
{
display_message("FATs seems Ok, nothing to do.\n");
}
else
{
disk_car->sync(disk_car);
}
#ifdef HAVE_NCURSES
delwin(window);
(void) clearok(stdscr, TRUE);

View file

@ -1467,7 +1467,7 @@ static int interface_partition_type_ncurses(disk_t *disk_car)
struct MenuItem menuOptions[]=
{
{ 'I', arch_i386.part_name, "Intel/PC partition" },
{ 'G', arch_gpt.part_name, "EFI GPT partition map (Mac i386, x86_64...)" },
{ 'G', arch_gpt.part_name, "EFI GPT partition map (Mac i386, some x86_64...)" },
{ 'M', arch_mac.part_name, "Apple partition map" },
{ 'N', arch_none.part_name, "Non partitioned media" },
{ 'S', arch_sun.part_name, "Sun Solaris partition"},

View file

@ -141,6 +141,7 @@ static void menu_write_ntfs_boot_sector_cli(disk_t *disk_car, partition_t *parti
{
display_message("Write error: Can't write new NTFS backup boot sector\n");
}
disk_car->sync(disk_car);
}
return ;
}
@ -208,6 +209,7 @@ static void menu_write_ntfs_boot_sector_ncurses(disk_t *disk_car, partition_t *p
{
display_message("Write error: Can't write new NTFS backup boot sector\n");
}
disk_car->sync(disk_car);
}
return;
case 'd':

View file

@ -193,6 +193,7 @@ int repair_MFT(disk_t *disk_car, partition_t *partition, const int verbose, char
}
else
{
disk_car->sync(disk_car);
log_info("MFT mirror fixed.\n");
display_message("MFT mirror fixed.\n");
}
@ -214,6 +215,7 @@ int repair_MFT(disk_t *disk_car, partition_t *partition, const int verbose, char
}
else
{
disk_car->sync(disk_car);
log_info("MFT fixed.\n");
display_message("MFT fixed.\n");
}

View file

@ -119,9 +119,8 @@ static s64 ntfs_device_testdisk_io_write(struct ntfs_device *dev, const void *bu
static int ntfs_device_testdisk_io_sync(struct ntfs_device *dev)
{
log_warning("ntfs_device_testdisk_io_sync() unimplemented\n");
errno = ENOTSUP;
return -1;
my_data_t *my_data=(my_data_t*)dev->d_private;
return my_data->disk_car->sync(my_data->disk_car);
}
static int ntfs_device_testdisk_io_stat(struct ntfs_device *dev, struct stat *buf)

View file

@ -511,6 +511,7 @@ static int write_part_gpt(disk_t *disk_car, const list_part_t *list_part, const
free(gpt);
free(gpt_entries);
write_part_gpt_i386(disk_car, list_part);
disk_car->sync(disk_car);
return 0;
}

View file

@ -626,6 +626,7 @@ int write_part_i386(disk_t *disk_car, const list_part_t *list_part, const int ro
int res=0;
res+=write_mbr_i386(disk_car,list_part,ro,verbose);
res+=write_all_log_i386(disk_car,list_part,ro,verbose,align);
disk_car->sync(disk_car);
return res;
}
@ -890,6 +891,7 @@ static int write_MBR_code_i386(disk_t *disk_car)
{
return 1;
}
disk_car->sync(disk_car);
return 0;
}
@ -1559,6 +1561,7 @@ static int erase_list_part_i386(disk_t *disk_car)
{
return 1;
}
disk_car->sync(disk_car);
return 0;
}