summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2010-12-16 08:50:58 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2010-12-16 08:50:58 +0100
commit65390765f54fc16f6108269534c1a1ac7a635b8a (patch)
tree2d43f962602847a8004e003bfa4e9a94c198ea79 /src
parent9924c4a5972117333055e15b90045af3ab7211ea (diff)
Set alternate superblock information when available
Diffstat (limited to 'src')
-rw-r--r--src/ext2_sbn.c9
-rw-r--r--src/ext2_sbn.h2
-rw-r--r--src/fat32.c3
-rw-r--r--src/fat_adv.c2
-rw-r--r--src/ntfs_adv.c4
-rw-r--r--src/thfs.c2
-rw-r--r--src/tntfs.c2
7 files changed, 22 insertions, 2 deletions
diff --git a/src/ext2_sbn.c b/src/ext2_sbn.c
index 6cfd3af..87344b1 100644
--- a/src/ext2_sbn.c
+++ b/src/ext2_sbn.c
@@ -70,7 +70,7 @@ static uint64_t next_sb(const uint64_t hd_offset_old)
return hd_offset;
}
-list_part_t *search_superblock(disk_t *disk_car, const partition_t *partition, const int verbose, const int dump_ind, const int interface)
+list_part_t *search_superblock(disk_t *disk_car, partition_t *partition, const int verbose, const int dump_ind, const int interface)
{
unsigned char *buffer=(unsigned char *)MALLOC(2*0x200);
uint64_t hd_offset;
@@ -126,6 +126,13 @@ list_part_t *search_superblock(disk_t *disk_car, const partition_t *partition, c
int insert_error=0;
if(hd_offset<=(EXT2_MIN_BLOCK_SIZE<<2))
new_partition->part_offset-=hd_offset;
+ if(partition->blocksize==0)
+ {
+ partition->sborg_offset=new_partition->sborg_offset;
+ partition->sb_offset =new_partition->sb_offset;
+ partition->sb_size =new_partition->sb_size;
+ partition->blocksize =new_partition->blocksize;
+ }
log_info("Ext2 superblock found at sector %llu (block=%llu, blocksize=%u)\n",
(long long unsigned) hd_offset/DEFAULT_SECTOR_SIZE,
(long long unsigned) hd_offset>>(EXT2_MIN_BLOCK_LOG_SIZE+le32(sb->s_log_block_size)),
diff --git a/src/ext2_sbn.h b/src/ext2_sbn.h
index 8096c08..07deea2 100644
--- a/src/ext2_sbn.h
+++ b/src/ext2_sbn.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-list_part_t *search_superblock(disk_t *disk_car, const partition_t *partition, const int verbose, const int dump_ind, const int interface);
+list_part_t *search_superblock(disk_t *disk_car, partition_t *partition, const int verbose, const int dump_ind, const int interface);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/fat32.c b/src/fat32.c
index 0cb8a08..a921d8d 100644
--- a/src/fat32.c
+++ b/src/fat32.c
@@ -187,6 +187,7 @@ int fat32_boot_sector(disk_t *disk_car, partition_t *partition, const int verbos
options="DOBRL";
else if(opt_B!=0)
{
+ partition->sb_offset=6 * disk_car->sector_size;
menu=5;
options="DBRL";
}
@@ -274,6 +275,8 @@ int fat32_boot_sector(disk_t *disk_car, partition_t *partition, const int verbos
#endif
break;
case 'B': /* B : copy backup boot sector over boot sector */
+ /* Reset information about backup boot sector */
+ partition->sb_offset=0;
#ifdef HAVE_NCURSES
if(ask_confirmation("Copy backup FAT32 boot sector over boot sector, confirm ? (Y/N)")!=0)
{
diff --git a/src/fat_adv.c b/src/fat_adv.c
index b7b2c6c..1636344 100644
--- a/src/fat_adv.c
+++ b/src/fat_adv.c
@@ -1029,6 +1029,8 @@ static void menu_write_fat_boot_sector(disk_t *disk_car, partition_t *partition,
{
int err=0;
log_info("Write new boot!\n");
+ /* Reset information about backup boot sector */
+ partition->sb_offset=0;
/* Write boot sector and backup boot sector */
if(upart_type==UP_FAT32)
{
diff --git a/src/ntfs_adv.c b/src/ntfs_adv.c
index ced779f..721c42d 100644
--- a/src/ntfs_adv.c
+++ b/src/ntfs_adv.c
@@ -141,6 +141,8 @@ static void menu_write_ntfs_boot_sector_cli(disk_t *disk_car, partition_t *parti
)
{
log_info("Write new boot!\n");
+ /* Reset information about backup boot sector */
+ partition->sb_offset=0;
/* Write boot sector and backup boot sector */
if(disk_car->pwrite(disk_car, newboot, NTFS_SECTOR_SIZE, partition->part_offset) != NTFS_SECTOR_SIZE)
{
@@ -210,6 +212,8 @@ static void menu_write_ntfs_boot_sector_ncurses(disk_t *disk_car, partition_t *p
if(strchr(options,'W')!=NULL && ask_confirmation("Write new NTFS boot sector, confirm ? (Y/N)")!=0)
{
log_info("Write new boot!\n");
+ /* Reset information about backup boot sector */
+ partition->sb_offset=0;
/* Write boot sector and backup boot sector */
if(disk_car->pwrite(disk_car, newboot, NTFS_SECTOR_SIZE, partition->part_offset) != NTFS_SECTOR_SIZE)
{
diff --git a/src/thfs.c b/src/thfs.c
index 99a8618..62ac5ed 100644
--- a/src/thfs.c
+++ b/src/thfs.c
@@ -234,6 +234,8 @@ int HFS_HFSP_boot_sector(disk_t *disk_car, partition_t *partition, const int ver
if(ask_confirmation("Copy backup HFS/HFS+ volume header over main volume header, confirm ? (Y/N)")!=0)
{
log_info("copy backup superblock over main superblock\n");
+ /* Reset information about backup boot sector */
+ partition->sb_offset=0;
if(disk_car->pwrite(disk_car, buffer_backup_bs, HFSP_BOOT_SECTOR_SIZE, partition->part_offset + 0x400) != HFSP_BOOT_SECTOR_SIZE)
{
display_message("Write error: Can't overwrite HFS/HFS+ main volume header\n");
diff --git a/src/tntfs.c b/src/tntfs.c
index 5f4baee..6bf89e0 100644
--- a/src/tntfs.c
+++ b/src/tntfs.c
@@ -255,6 +255,8 @@ int ntfs_boot_sector(disk_t *disk_car, partition_t *partition, const int verbose
if(ask_confirmation("Copy backup NTFS boot sector over boot sector, confirm ? (Y/N)")!=0)
{
log_info("copy backup boot sector over boot sector\n");
+ /* Reset information about backup boot sector */
+ partition->sb_offset=0;
if(disk_car->pwrite(disk_car, buffer_backup_bs, NTFS_BOOT_SECTOR_SIZE, partition->part_offset) != NTFS_BOOT_SECTOR_SIZE)
{
display_message("Write error: Can't overwrite NTFS boot sector\n");