summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/adv.c89
-rw-r--r--src/bfs.c54
-rw-r--r--src/bfs.h2
-rw-r--r--src/bsd.c43
-rw-r--r--src/bsd.h2
-rw-r--r--src/btrfs.c2
-rw-r--r--src/btrfs.h2
-rw-r--r--src/cramfs.c2
-rw-r--r--src/cramfs.h2
-rw-r--r--src/dfxml.c2
-rw-r--r--src/ext2.c2
-rw-r--r--src/ext2.h2
-rw-r--r--src/ext2_dir.c3
-rw-r--r--src/ext2_sb.c2
-rw-r--r--src/ext2_sb.h2
-rw-r--r--src/ext2grp.c4
-rw-r--r--src/ext2grp.h4
-rw-r--r--src/fat.c186
-rw-r--r--src/fat1x.c2
-rw-r--r--src/fat_adv.c2
-rw-r--r--src/fat_cluster.c2
-rw-r--r--src/fat_cluster.h2
-rw-r--r--src/fat_unformat.c2
-rw-r--r--src/file_doc.c2
-rw-r--r--src/filegen.c2
-rw-r--r--src/filegen.h2
-rw-r--r--src/gfs2.c2
-rw-r--r--src/godmode.c15
-rw-r--r--src/godmode.h2
-rw-r--r--src/hfsp.c3
-rw-r--r--src/hfsp.h2
-rw-r--r--src/hpfs.c2
-rw-r--r--src/jfs.c77
-rw-r--r--src/jfs.h2
-rw-r--r--src/luks.c55
-rw-r--r--src/luks.h2
-rw-r--r--src/lvm.c128
-rw-r--r--src/lvm.h4
-rw-r--r--src/md.c358
-rw-r--r--src/md.h2
-rw-r--r--src/netware.c2
-rw-r--r--src/netware.h2
-rw-r--r--src/ntfs_adv.c79
-rw-r--r--src/ntfs_udl.c10
-rw-r--r--src/partgpt.c2
-rw-r--r--src/partgpt.h2
-rw-r--r--src/parthumax.c2
-rw-r--r--src/parthumax.h2
-rw-r--r--src/parti386.c4
-rw-r--r--src/partsun.c2
-rw-r--r--src/partsun.h2
-rw-r--r--src/partxbox.c2
-rw-r--r--src/partxbox.h2
-rw-r--r--src/phbf.c2
-rw-r--r--src/phbs.c2
-rw-r--r--src/photorec.c6
-rw-r--r--src/photorec.h4
-rw-r--r--src/pnext.h8
-rw-r--r--src/psearch.h2
-rw-r--r--src/rfs.c2
-rw-r--r--src/rfs.h2
-rw-r--r--src/savehdr.c6
-rw-r--r--src/savehdr.h4
-rw-r--r--src/sun.c2
-rw-r--r--src/sun.h2
-rw-r--r--src/sysv.c2
-rw-r--r--src/sysv.h2
-rw-r--r--src/texfat.c2
-rw-r--r--src/thfs.c2
-rw-r--r--src/tntfs.c2
-rw-r--r--src/ufs.c2
-rw-r--r--src/ufs.h2
-rw-r--r--src/vmfs.c46
-rw-r--r--src/vmfs.h2
-rw-r--r--src/wbfs.c34
-rw-r--r--src/wbfs.h2
-rw-r--r--src/xfs.c112
-rw-r--r--src/xfs.h2
-rw-r--r--src/zfs.c47
-rw-r--r--src/zfs.h2
80 files changed, 717 insertions, 774 deletions
diff --git a/src/adv.c b/src/adv.c
index 0d53068..163cd68 100644
--- a/src/adv.c
+++ b/src/adv.c
@@ -79,12 +79,43 @@ extern const arch_fnct_t arch_xbox;
#define DEFAULT_IMAGE_NAME "image.dd"
-static int is_exfat(const partition_t *partition);
-static int is_hfs(const partition_t *partition);
-static int is_hfsp(const partition_t *partition);
-static int is_linux(const partition_t *partition);
-static int is_part_hfs(const partition_t *partition);
-static int is_part_hfsp(const partition_t *partition);
+static int is_part_hfs(const partition_t *partition)
+{
+ if( partition->part_type_i386 == P_HFS ||
+ partition->part_type_mac == PMAC_HFS)
+ return 1;
+ if(guid_cmp(partition->part_type_gpt,GPT_ENT_TYPE_MAC_HFS)==0)
+ return 1;
+ return 0;
+}
+
+static int is_part_hfsp(const partition_t *partition)
+{
+ if( partition->part_type_i386 == P_HFSP ||
+ partition->part_type_mac == PMAC_HFS )
+ return 1;
+ if(guid_cmp(partition->part_type_gpt,GPT_ENT_TYPE_MAC_HFS)==0)
+ return 1;
+ return 0;
+}
+
+int is_part_linux(const partition_t *partition)
+{
+ if(partition->arch==&arch_i386 && partition->part_type_i386==P_LINUX)
+ return 1;
+ if(partition->arch==&arch_sun && partition->part_type_sun==PSUN_LINUX)
+ return 1;
+ if(partition->arch==&arch_mac && partition->part_type_mac==PMAC_LINUX)
+ return 1;
+ if(partition->arch==&arch_gpt &&
+ (
+ guid_cmp(partition->part_type_gpt,GPT_ENT_TYPE_LINUX_DATA)==0 ||
+ guid_cmp(partition->part_type_gpt,GPT_ENT_TYPE_LINUX_HOME)==0 ||
+ guid_cmp(partition->part_type_gpt,GPT_ENT_TYPE_LINUX_SRV)==0
+ ))
+ return 1;
+ return 0;
+}
static int is_exfat(const partition_t *partition)
{
@@ -128,46 +159,8 @@ static int is_linux(const partition_t *partition)
return 0;
}
-static int is_part_hfs(const partition_t *partition)
-{
- if( partition->part_type_i386 == P_HFS ||
- partition->part_type_mac == PMAC_HFS)
- return 1;
- if(guid_cmp(partition->part_type_gpt,GPT_ENT_TYPE_MAC_HFS)==0)
- return 1;
- return 0;
-}
-
-static int is_part_hfsp(const partition_t *partition)
-{
- if( partition->part_type_i386 == P_HFSP ||
- partition->part_type_mac == PMAC_HFS )
- return 1;
- if(guid_cmp(partition->part_type_gpt,GPT_ENT_TYPE_MAC_HFS)==0)
- return 1;
- return 0;
-}
-
-int is_part_linux(const partition_t *partition)
-{
- if(partition->arch==&arch_i386 && partition->part_type_i386==P_LINUX)
- return 1;
- if(partition->arch==&arch_sun && partition->part_type_sun==PSUN_LINUX)
- return 1;
- if(partition->arch==&arch_mac && partition->part_type_mac==PMAC_LINUX)
- return 1;
- if(partition->arch==&arch_gpt &&
- (
- guid_cmp(partition->part_type_gpt,GPT_ENT_TYPE_LINUX_DATA)==0 ||
- guid_cmp(partition->part_type_gpt,GPT_ENT_TYPE_LINUX_HOME)==0 ||
- guid_cmp(partition->part_type_gpt,GPT_ENT_TYPE_LINUX_SRV)==0
- ))
- return 1;
- return 0;
-}
-
#ifdef HAVE_NCURSES
-static void interface_adv_ncurses(disk_t *disk, const int rewrite, list_part_t *list_part, list_part_t *current_element, const int offset)
+static void interface_adv_ncurses(disk_t *disk, const int rewrite, list_part_t *list_part, const list_part_t *current_element, const int offset)
{
list_part_t *element;
int i;
@@ -369,7 +362,7 @@ static int adv_menu_boot_selected(disk_t *disk, partition_t *partition, const in
return 0;
}
-static void adv_menu_image_selected(disk_t *disk, partition_t *partition, char **current_cmd)
+static void adv_menu_image_selected(disk_t *disk, const partition_t *partition, char **current_cmd)
{
char *dst_path;
#ifdef HAVE_NCURSES
@@ -398,7 +391,7 @@ static void adv_menu_image_selected(disk_t *disk, partition_t *partition, char *
}
}
-static void adv_menu_undelete_selected(disk_t *disk, partition_t *partition, const int verbose, char **current_cmd)
+static void adv_menu_undelete_selected(disk_t *disk, const partition_t *partition, const int verbose, char **current_cmd)
{
if(partition->sb_offset!=0 && partition->sb_size>0)
{
@@ -424,7 +417,7 @@ static void adv_menu_undelete_selected(disk_t *disk, partition_t *partition, con
}
}
-static void adv_menu_list_selected(disk_t *disk, partition_t *partition, const int verbose, const int expert, char **current_cmd)
+static void adv_menu_list_selected(disk_t *disk, const partition_t *partition, const int verbose, const int expert, char **current_cmd)
{
if(partition->sb_offset!=0 && partition->sb_size>0)
{
diff --git a/src/bfs.c b/src/bfs.c
index 1854ee8..7b740cb 100644
--- a/src/bfs.c
+++ b/src/bfs.c
@@ -34,8 +34,31 @@
#include "fnctdsk.h"
#include "log.h"
-static void set_BeFS_info(const struct disk_super_block *beos_block, partition_t *partition);
-static int test_BeFS(disk_t *disk_car, const struct disk_super_block*beos_block, const partition_t *partition, const int dump_ind);
+static void set_BeFS_info(const struct disk_super_block *beos_block, partition_t *partition)
+{
+ partition->upart_type=UP_BEOS;
+ partition->blocksize= 1 << le32(beos_block->block_shift);
+ partition->info[0]='\0';
+ snprintf(partition->info, sizeof(partition->info), "BeFS blocksize=%u", partition->blocksize);
+ set_part_name(partition,beos_block->name,B_OS_NAME_LENGTH);
+}
+
+static int test_BeFS(const disk_t *disk_car, const struct disk_super_block*beos_block, const partition_t *partition, const int dump_ind)
+{
+ if(beos_block->magic1!=le32(SUPER_BLOCK_MAGIC1) &&
+ beos_block->magic2!=le32(SUPER_BLOCK_MAGIC2) &&
+ beos_block->magic3!=le32(SUPER_BLOCK_MAGIC3))
+ return 1;
+ if(partition==NULL)
+ return 0;
+ if(dump_ind!=0)
+ {
+ log_info("\nBeFS magic value at %u/%u/%u\n", offset2cylinder(disk_car,partition->part_offset),offset2head(disk_car,partition->part_offset),offset2sector(disk_car,partition->part_offset));
+ dump_log(beos_block,DEFAULT_SECTOR_SIZE);
+ }
+ return 0;
+}
+
int check_BeFS(disk_t *disk_car,partition_t *partition)
{
@@ -56,7 +79,7 @@ int check_BeFS(disk_t *disk_car,partition_t *partition)
return 0;
}
-int recover_BeFS(disk_t *disk_car, const struct disk_super_block *beos_block, partition_t *partition, const int dump_ind)
+int recover_BeFS(const disk_t *disk_car, const struct disk_super_block *beos_block, partition_t *partition, const int dump_ind)
{
if(test_BeFS(disk_car,beos_block,partition,dump_ind)!=0)
return 1;
@@ -65,28 +88,3 @@ int recover_BeFS(disk_t *disk_car, const struct disk_super_block *beos_block, pa
partition->part_type_i386=(unsigned char)P_BEOS;
return 0;
}
-
-static int test_BeFS(disk_t *disk_car, const struct disk_super_block*beos_block, const partition_t *partition, const int dump_ind)
-{
- if(beos_block->magic1!=le32(SUPER_BLOCK_MAGIC1) &&
- beos_block->magic2!=le32(SUPER_BLOCK_MAGIC2) &&
- beos_block->magic3!=le32(SUPER_BLOCK_MAGIC3))
- return 1;
- if(partition==NULL)
- return 0;
- if(dump_ind!=0)
- {
- log_info("\nBeFS magic value at %u/%u/%u\n", offset2cylinder(disk_car,partition->part_offset),offset2head(disk_car,partition->part_offset),offset2sector(disk_car,partition->part_offset));
- dump_log(beos_block,DEFAULT_SECTOR_SIZE);
- }
- return 0;
-}
-
-static void set_BeFS_info(const struct disk_super_block *beos_block, partition_t *partition)
-{
- partition->upart_type=UP_BEOS;
- partition->blocksize= 1 << le32(beos_block->block_shift);
- partition->info[0]='\0';
- snprintf(partition->info, sizeof(partition->info), "BeFS blocksize=%u", partition->blocksize);
- set_part_name(partition,beos_block->name,B_OS_NAME_LENGTH);
-}
diff --git a/src/bfs.h b/src/bfs.h
index 14087a2..9e78446 100644
--- a/src/bfs.h
+++ b/src/bfs.h
@@ -83,7 +83,7 @@ struct disk_super_block /* super block as it is on disk */
#define BFS_BIG_ENDIAN 0x42494745 /* BIGE */
/* int test_beos(struct disk_super_block *,partition_t); */
int check_BeFS(disk_t *disk_car, partition_t *partition);
-int recover_BeFS(disk_t *disk_car, const struct disk_super_block *beos_block, partition_t *partition, const int dump_ind);
+int recover_BeFS(const disk_t *disk_car, const struct disk_super_block *beos_block, partition_t *partition, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/bsd.c b/src/bsd.c
index e67d9b0..13dd9b9 100644
--- a/src/bsd.c
+++ b/src/bsd.c
@@ -33,28 +33,8 @@
#include "bsd.h"
#include "intrf.h"
#include "log.h"
-static int test_BSD(disk_t *disk_car, const struct disklabel*bsd_header, const partition_t *partition, const int verbose, const int dump_ind, const unsigned int max_partitions);
-int check_BSD(disk_t *disk_car,partition_t *partition,const int verbose, const unsigned int max_partitions)
-{
- unsigned char *buffer;
- buffer=(unsigned char*)MALLOC(BSD_DISKLABEL_SIZE);
- if(disk_car->pread(disk_car, buffer, BSD_DISKLABEL_SIZE, partition->part_offset + 0x200) != BSD_DISKLABEL_SIZE)
- {
- free(buffer);
- return 1;
- }
- if(test_BSD(disk_car,(const struct disklabel*)buffer,partition,verbose,0,max_partitions))
- {
- free(buffer);
- return 1;
- }
- set_part_name(partition,((const struct disklabel*)buffer)->d_packname,16);
- free(buffer);
- return 0;
-}
-
-static int test_BSD(disk_t *disk_car, const struct disklabel*bsd_header, const partition_t *partition,const int verbose, const int dump_ind, const unsigned int max_partitions)
+static int test_BSD(const disk_t *disk_car, const struct disklabel*bsd_header, const partition_t *partition,const int verbose, const int dump_ind, const unsigned int max_partitions)
{
unsigned int i;
const uint16_t* cp;
@@ -125,7 +105,26 @@ static int test_BSD(disk_t *disk_car, const struct disklabel*bsd_header, const p
return 0;
}
-int recover_BSD(disk_t *disk_car, const struct disklabel*bsd_header,partition_t *partition,const int verbose, const int dump_ind)
+int check_BSD(disk_t *disk_car,partition_t *partition,const int verbose, const unsigned int max_partitions)
+{
+ unsigned char *buffer;
+ buffer=(unsigned char*)MALLOC(BSD_DISKLABEL_SIZE);
+ if(disk_car->pread(disk_car, buffer, BSD_DISKLABEL_SIZE, partition->part_offset + 0x200) != BSD_DISKLABEL_SIZE)
+ {
+ free(buffer);
+ return 1;
+ }
+ if(test_BSD(disk_car,(const struct disklabel*)buffer,partition,verbose,0,max_partitions))
+ {
+ free(buffer);
+ return 1;
+ }
+ set_part_name(partition,((const struct disklabel*)buffer)->d_packname,16);
+ free(buffer);
+ return 0;
+}
+
+int recover_BSD(const disk_t *disk_car, const struct disklabel*bsd_header,partition_t *partition,const int verbose, const int dump_ind)
{
int i;
int i_max_p_offset=-1;
diff --git a/src/bsd.h b/src/bsd.h
index 1a14807..bd94e54 100644
--- a/src/bsd.h
+++ b/src/bsd.h
@@ -169,7 +169,7 @@ struct disklabel {
#define TST_FS_RAID 15 /* RAIDFrame drive */
#define TST_FS_JFS2 21 /* IBM JFS2 */
int check_BSD(disk_t *disk_car,partition_t *partition,const int verbose,const unsigned int max_partitions);
-int recover_BSD(disk_t *disk_car, const struct disklabel*bsd_header,partition_t *partition,const int verbose, const int dump_ind);
+int recover_BSD(const disk_t *disk_car, const struct disklabel*bsd_header,partition_t *partition,const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif
diff --git a/src/btrfs.c b/src/btrfs.c
index 062b52e..4eef0bb 100644
--- a/src/btrfs.c
+++ b/src/btrfs.c
@@ -74,7 +74,7 @@ int check_btrfs(disk_t *disk_car,partition_t *partition)
Primary superblock is at 1024 (SUPERBLOCK_OFFSET)
Group 0 begin at s_first_data_block
*/
-int recover_btrfs(disk_t *disk, const struct btrfs_super_block *sb, partition_t *partition, const int verbose, const int dump_ind)
+int recover_btrfs(const disk_t *disk, const struct btrfs_super_block *sb, partition_t *partition, const int verbose, const int dump_ind)
{
if(test_btrfs(sb)!=0)
return 1;
diff --git a/src/btrfs.h b/src/btrfs.h
index d28c590..83ad564 100644
--- a/src/btrfs.h
+++ b/src/btrfs.h
@@ -139,7 +139,7 @@ struct btrfs_super_block {
} __attribute__ ((gcc_struct, __packed__));
int check_btrfs(disk_t *disk_car,partition_t *partition);
-int recover_btrfs(disk_t *disk_car, const struct btrfs_super_block *sb,partition_t *partition,const int verbose, const int dump_ind);
+int recover_btrfs(const disk_t *disk_car, const struct btrfs_super_block *sb,partition_t *partition,const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/cramfs.c b/src/cramfs.c
index c547fb5..e5afeb0 100644
--- a/src/cramfs.c
+++ b/src/cramfs.c
@@ -76,7 +76,7 @@ static int test_cramfs(const disk_t *disk_car, const struct cramfs_super *sb, co
return 0;
}
-int recover_cramfs(disk_t *disk_car, const struct cramfs_super *sb,partition_t *partition,const int verbose, const int dump_ind)
+int recover_cramfs(const disk_t *disk_car, const struct cramfs_super *sb, partition_t *partition, const int verbose, const int dump_ind)
{
if(test_cramfs(disk_car, sb, partition, verbose)!=0)
return 1;
diff --git a/src/cramfs.h b/src/cramfs.h
index c525234..4b9b57f 100644
--- a/src/cramfs.h
+++ b/src/cramfs.h
@@ -83,7 +83,7 @@ struct cramfs_super {
int check_cramfs(disk_t *disk_car,partition_t *partition,const int verbose);
-int recover_cramfs(disk_t *disk_car, const struct cramfs_super *sb,partition_t *partition,const int verbose, const int dump_ind);
+int recover_cramfs(const disk_t *disk_car, const struct cramfs_super *sb, partition_t *partition, const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/dfxml.c b/src/dfxml.c
index a101f02..142d066 100644
--- a/src/dfxml.c
+++ b/src/dfxml.c
@@ -317,7 +317,7 @@ static const char *relative_name(const char *fname)
/* See filegen.h for the definition of file_recovery_struct */
void xml_log_file_recovered(const file_recovery_t *file_recovery)
{
- struct td_list_head *tmp;
+ const struct td_list_head *tmp;
uint64_t file_size=0;
if(xml_handle==NULL)
return;
diff --git a/src/ext2.c b/src/ext2.c
index 2cd6a07..cb81316 100644
--- a/src/ext2.c
+++ b/src/ext2.c
@@ -109,7 +109,7 @@ static void set_EXT2_info(const struct ext2_super_block *sb, partition_t *partit
Primary superblock is at 1024 (SUPERBLOCK_OFFSET)
Group 0 begin at s_first_data_block
*/
-int recover_EXT2(disk_t *disk, const struct ext2_super_block *sb,partition_t *partition,const int verbose, const int dump_ind)
+int recover_EXT2(const disk_t *disk, const struct ext2_super_block *sb, partition_t *partition, const int verbose, const int dump_ind)
{
if(test_EXT2(sb, partition)!=0)
return 1;
diff --git a/src/ext2.h b/src/ext2.h
index 68bffea..47ef0a7 100644
--- a/src/ext2.h
+++ b/src/ext2.h
@@ -202,7 +202,7 @@ struct ext2_super_block {
uint32_t s_checksum; /* crc32c(superblock) */
};
int check_EXT2(disk_t *disk_car,partition_t *partition,const int verbose);
-int recover_EXT2(disk_t *disk_car, const struct ext2_super_block *sb,partition_t *partition,const int verbose, const int dump_ind);
+int recover_EXT2(const disk_t *disk_car, const struct ext2_super_block *sb, partition_t *partition, const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/ext2_dir.c b/src/ext2_dir.c
index 87d8a20..82106c1 100644
--- a/src/ext2_dir.c
+++ b/src/ext2_dir.c
@@ -73,7 +73,6 @@ static errcode_t my_flush(io_channel channel);
static errcode_t my_read_blk64(io_channel channel, unsigned long long block, int count, void *buf);
static errcode_t my_write_blk64(io_channel channel, unsigned long long block, int count, const void *buf);
-static io_channel alloc_io_channel(disk_t *disk_car,my_data_t *my_data);
static void dir_partition_ext2_close(dir_data_t *dir_data);
static int ext2_copy(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, const file_info_t *file);
@@ -111,7 +110,7 @@ static io_channel shared_ioch=NULL;
/*
* Allocate libext2fs structures associated with I/O manager
*/
-static io_channel alloc_io_channel(disk_t *disk_car,my_data_t *my_data)
+static io_channel alloc_io_channel(const disk_t *disk_car,my_data_t *my_data)
{
io_channel ioch;
#ifdef DEBUG_EXT2
diff --git a/src/ext2_sb.c b/src/ext2_sb.c
index 8a72ed3..e0e9763 100644
--- a/src/ext2_sb.c
+++ b/src/ext2_sb.c
@@ -38,7 +38,7 @@
#include "guid_cmp.h"
#include "ext2_sb.h"
-int interface_superblock(disk_t *disk_car,list_part_t *list_part, char**current_cmd)
+int interface_superblock(disk_t *disk_car, const list_part_t *list_part, char**current_cmd)
{
const list_part_t *parts;
const partition_t *old_part=NULL;
diff --git a/src/ext2_sb.h b/src/ext2_sb.h
index fae7c31..b527b8e 100644
--- a/src/ext2_sb.h
+++ b/src/ext2_sb.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-int interface_superblock(disk_t *disk_car,list_part_t *list_part,char**current_cmd);
+int interface_superblock(disk_t *disk_car, const list_part_t *list_part, char**current_cmd);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/ext2grp.c b/src/ext2grp.c
index c48ec2b..96db73f 100644
--- a/src/ext2grp.c
+++ b/src/ext2grp.c
@@ -36,7 +36,7 @@
#include "log.h"
#include "photorec.h"
-unsigned int ext2_fix_group(alloc_data_t *list_search_space, disk_t *disk, partition_t *partition)
+unsigned int ext2_fix_group(alloc_data_t *list_search_space, disk_t *disk, const partition_t *partition)
{
struct td_list_head *search_walker = NULL;
unsigned char *buffer;
@@ -73,7 +73,7 @@ unsigned int ext2_fix_group(alloc_data_t *list_search_space, disk_t *disk, parti
return blocksize;
}
-unsigned int ext2_fix_inode(alloc_data_t *list_search_space, disk_t *disk, partition_t *partition)
+unsigned int ext2_fix_inode(alloc_data_t *list_search_space, disk_t *disk, const partition_t *partition)
{
struct td_list_head *search_walker = NULL;
unsigned char *buffer;
diff --git a/src/ext2grp.h b/src/ext2grp.h
index ad854fe..ed5e9db 100644
--- a/src/ext2grp.h
+++ b/src/ext2grp.h
@@ -23,8 +23,8 @@
extern "C" {
#endif
-unsigned int ext2_fix_group(alloc_data_t *list_search_space, disk_t *disk, partition_t *partition);
-unsigned int ext2_fix_inode(alloc_data_t *list_search_space, disk_t *disk, partition_t *partition);
+unsigned int ext2_fix_group(alloc_data_t *list_search_space, disk_t *disk, const partition_t *partition);
+unsigned int ext2_fix_inode(alloc_data_t *list_search_space, disk_t *disk, const partition_t *partition);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/fat.c b/src/fat.c
index f1f3a65..cc41a9e 100644
--- a/src/fat.c
+++ b/src/fat.c
@@ -50,14 +50,102 @@
extern const arch_fnct_t arch_i386;
extern const arch_fnct_t arch_mac;
-static void set_FAT_info(disk_t *disk_car, const struct fat_boot_sector *fat_header, partition_t *partition);
-static int fat32_set_part_name(disk_t *disk_car, partition_t *partition, const struct fat_boot_sector*fat_header);
static int log_fat_info(const struct fat_boot_sector*fh1, const upart_type_t upart_type, const unsigned int sector_size);
static int test_OS2MB(const disk_t *disk, const struct fat_boot_sector *fat_header, const partition_t *partition, const int verbose, const int dump_ind);
static int is_fat12(const partition_t *partition);
static int is_fat16(const partition_t *partition);
static int is_fat32(const partition_t *partition);
+static int fat32_set_part_name(disk_t *disk_car, partition_t *partition, const struct fat_boot_sector*fat_header)
+{
+ partition->fsname[0]='\0';
+ if((fat_header->sectors_per_cluster>0)&&(fat_header->sectors_per_cluster<=128))
+ {
+ const unsigned int cluster_size=fat_header->sectors_per_cluster*disk_car->sector_size;
+ unsigned char *buffer=(unsigned char*)MALLOC(cluster_size);
+ if((unsigned)disk_car->pread(disk_car, buffer, cluster_size,
+ partition->part_offset + (le16(fat_header->reserved) + fat_header->fats * le32(fat_header->fat32_length) + (uint64_t)(le32(fat_header->root_cluster) - 2) * fat_header->sectors_per_cluster) * disk_car->sector_size) != cluster_size)
+ {
+ log_error("fat32_set_part_name() cannot read FAT32 root cluster.\n");
+ }
+ else
+ {
+ int i;
+ int stop=0;
+ for(i=0;(i<16*fat_header->sectors_per_cluster)&&(stop==0);i++)
+ { /* Test attribut volume name and check if the volume name is erased or not */
+ if(((buffer[i*0x20+0xB] & ATTR_EXT) !=ATTR_EXT) && ((buffer[i*0x20+0xB] & ATTR_VOLUME) !=0) && (buffer[i*0x20]!=0xE5))
+ {
+ set_part_name_chomp(partition,&buffer[i*0x20],11);
+ if(check_VFAT_volume_name(partition->fsname, 11))
+ partition->fsname[0]='\0';
+ }
+ if(buffer[i*0x20]==0)
+ {
+ stop=1;
+ }
+ }
+ }
+ free(buffer);
+ }
+ if(partition->fsname[0]=='\0')
+ {
+ log_info("set_FAT_info: name from BS used\n");
+ set_part_name_chomp(partition,((const unsigned char*)fat_header)+FAT32_PART_NAME,11);
+ if(check_VFAT_volume_name(partition->fsname, 11))
+ partition->fsname[0]='\0';
+ }
+ return 0;
+}
+
+static void set_FAT_info(disk_t *disk_car, const struct fat_boot_sector *fat_header, partition_t *partition)
+{
+ uint64_t start_fat1;
+ uint64_t start_data;
+ uint64_t part_size;
+ unsigned long int no_of_cluster;
+ unsigned long int fat_length;
+ const char *buffer=(const char*)fat_header;
+ partition->fsname[0]='\0';
+ partition->blocksize=fat_sector_size(fat_header)* fat_header->sectors_per_cluster;
+ fat_length=le16(fat_header->fat_length)>0?le16(fat_header->fat_length):le32(fat_header->fat32_length);
+ part_size=(fat_sectors(fat_header)>0?fat_sectors(fat_header):le32(fat_header->total_sect));
+ start_fat1=le16(fat_header->reserved);
+ start_data=start_fat1+fat_header->fats*fat_length+(get_dir_entries(fat_header)*32+fat_sector_size(fat_header)-1)/fat_sector_size(fat_header);
+ no_of_cluster=(part_size-start_data)/fat_header->sectors_per_cluster;
+ if(no_of_cluster<4085)
+ {
+ partition->upart_type=UP_FAT12;
+ snprintf(partition->info, sizeof(partition->info), "FAT12, blocksize=%u", partition->blocksize);
+ if(buffer[38]==0x29) /* BS_BootSig */
+ {
+ set_part_name_chomp(partition,((const unsigned char*)fat_header)+FAT1X_PART_NAME,11);
+ if(check_VFAT_volume_name(partition->fsname, 11))
+ partition->fsname[0]='\0';
+ }
+ }
+ else if(no_of_cluster<65525)
+ {
+ partition->upart_type=UP_FAT16;
+ snprintf(partition->info, sizeof(partition->info), "FAT16, blocksize=%u", partition->blocksize);
+ if(buffer[38]==0x29) /* BS_BootSig */
+ {
+ set_part_name_chomp(partition,((const unsigned char*)fat_header)+FAT1X_PART_NAME,11);
+ if(check_VFAT_volume_name(partition->fsname, 11))
+ partition->fsname[0]='\0';
+ }
+ }
+ else
+ {
+ partition->upart_type=UP_FAT32;
+ if(partition->sb_offset==0)
+ snprintf(partition->info, sizeof(partition->info), "FAT32, blocksize=%u", partition->blocksize);
+ else
+ snprintf(partition->info, sizeof(partition->info), "FAT32 found using backup sector, blocksize=%u", partition->blocksize);
+ fat32_set_part_name(disk_car,partition,fat_header);
+ }
+}
+
static int log_fat_info(const struct fat_boot_sector*fh1, const upart_type_t upart_type, const unsigned int sector_size)
{
log_info("sector_size %u\n", fat_sector_size(fh1));
@@ -150,7 +238,7 @@ int log_fat2_info(const struct fat_boot_sector*fh1, const struct fat_boot_sector
return 0;
}
-int check_FAT(disk_t *disk_car,partition_t *partition,const int verbose)
+int check_FAT(disk_t *disk_car, partition_t *partition, const int verbose)
{
unsigned char *buffer;
buffer=(unsigned char *)MALLOC(3*disk_car->sector_size);
@@ -178,54 +266,6 @@ int check_FAT(disk_t *disk_car,partition_t *partition,const int verbose)
return 0;
}
-static void set_FAT_info(disk_t *disk_car, const struct fat_boot_sector *fat_header, partition_t *partition)
-{
- uint64_t start_fat1;
- uint64_t start_data;
- uint64_t part_size;
- unsigned long int no_of_cluster;
- unsigned long int fat_length;
- const char *buffer=(const char*)fat_header;
- partition->fsname[0]='\0';
- partition->blocksize=fat_sector_size(fat_header)* fat_header->sectors_per_cluster;
- fat_length=le16(fat_header->fat_length)>0?le16(fat_header->fat_length):le32(fat_header->fat32_length);
- part_size=(fat_sectors(fat_header)>0?fat_sectors(fat_header):le32(fat_header->total_sect));
- start_fat1=le16(fat_header->reserved);
- start_data=start_fat1+fat_header->fats*fat_length+(get_dir_entries(fat_header)*32+fat_sector_size(fat_header)-1)/fat_sector_size(fat_header);
- no_of_cluster=(part_size-start_data)/fat_header->sectors_per_cluster;
- if(no_of_cluster<4085)
- {
- partition->upart_type=UP_FAT12;
- snprintf(partition->info, sizeof(partition->info), "FAT12, blocksize=%u", partition->blocksize);
- if(buffer[38]==0x29) /* BS_BootSig */
- {
- set_part_name_chomp(partition,((const unsigned char*)fat_header)+FAT1X_PART_NAME,11);
- if(check_VFAT_volume_name(partition->fsname, 11))
- partition->fsname[0]='\0';
- }
- }
- else if(no_of_cluster<65525)
- {
- partition->upart_type=UP_FAT16;
- snprintf(partition->info, sizeof(partition->info), "FAT16, blocksize=%u", partition->blocksize);
- if(buffer[38]==0x29) /* BS_BootSig */
- {
- set_part_name_chomp(partition,((const unsigned char*)fat_header)+FAT1X_PART_NAME,11);
- if(check_VFAT_volume_name(partition->fsname, 11))
- partition->fsname[0]='\0';
- }
- }
- else
- {
- partition->upart_type=UP_FAT32;
- if(partition->sb_offset==0)
- snprintf(partition->info, sizeof(partition->info), "FAT32, blocksize=%u", partition->blocksize);
- else
- snprintf(partition->info, sizeof(partition->info), "FAT32 found using backup sector, blocksize=%u", partition->blocksize);
- fat32_set_part_name(disk_car,partition,fat_header);
- }
-}
-
static unsigned int get_next_cluster_fat12(disk_t *disk, const partition_t *partition, const int offset, const unsigned int cluster)
{
unsigned int next_cluster;
@@ -764,7 +804,7 @@ unsigned long int fat32_get_next_free(const unsigned char *boot_fat32, const uns
return le32(fsinfo->nextfree);
}
-static int fat_has_EFI_entry(disk_t *disk, partition_t *partition, const int verbose)
+static int fat_has_EFI_entry(disk_t *disk, const partition_t *partition, const int verbose)
{
dir_data_t dir_data;
struct td_list_head *file_walker = NULL;
@@ -866,48 +906,6 @@ int recover_FAT(disk_t *disk_car, const struct fat_boot_sector*fat_header, parti
return 0;
}
-static int fat32_set_part_name(disk_t *disk_car, partition_t *partition, const struct fat_boot_sector*fat_header)
-{
- partition->fsname[0]='\0';
- if((fat_header->sectors_per_cluster>0)&&(fat_header->sectors_per_cluster<=128))
- {
- const unsigned int cluster_size=fat_header->sectors_per_cluster*disk_car->sector_size;
- unsigned char *buffer=(unsigned char*)MALLOC(cluster_size);
- if((unsigned)disk_car->pread(disk_car, buffer, cluster_size,
- partition->part_offset + (le16(fat_header->reserved) + fat_header->fats * le32(fat_header->fat32_length) + (uint64_t)(le32(fat_header->root_cluster) - 2) * fat_header->sectors_per_cluster) * disk_car->sector_size) != cluster_size)
- {
- log_error("fat32_set_part_name() cannot read FAT32 root cluster.\n");
- }
- else
- {
- int i;
- int stop=0;
- for(i=0;(i<16*fat_header->sectors_per_cluster)&&(stop==0);i++)
- { /* Test attribut volume name and check if the volume name is erased or not */
- if(((buffer[i*0x20+0xB] & ATTR_EXT) !=ATTR_EXT) && ((buffer[i*0x20+0xB] & ATTR_VOLUME) !=0) && (buffer[i*0x20]!=0xE5))
- {
- set_part_name_chomp(partition,&buffer[i*0x20],11);
- if(check_VFAT_volume_name(partition->fsname, 11))
- partition->fsname[0]='\0';
- }
- if(buffer[i*0x20]==0)
- {
- stop=1;
- }
- }
- }
- free(buffer);
- }
- if(partition->fsname[0]=='\0')
- {
- log_info("set_FAT_info: name from BS used\n");
- set_part_name_chomp(partition,((const unsigned char*)fat_header)+FAT32_PART_NAME,11);
- if(check_VFAT_volume_name(partition->fsname, 11))
- partition->fsname[0]='\0';
- }
- return 0;
-}
-
int check_OS2MB(disk_t *disk, partition_t *partition, const int verbose)
{
unsigned char *buffer=(unsigned char *)MALLOC(disk->sector_size);
diff --git a/src/fat1x.c b/src/fat1x.c
index 90ab49b..baa6b94 100644
--- a/src/fat1x.c
+++ b/src/fat1x.c
@@ -43,7 +43,7 @@
#include "fat1x.h"
#ifdef HAVE_NCURSES
-static void dump_fat1x_ncurses(disk_t *disk_car, partition_t *partition, const unsigned char *buffer_bs)
+static void dump_fat1x_ncurses(disk_t *disk_car, const partition_t *partition, const unsigned char *buffer_bs)
{
WINDOW *window=newwin(LINES, COLS, 0, 0); /* full screen */
keypad(window, TRUE); /* Need it to get arrow key */
diff --git a/src/fat_adv.c b/src/fat_adv.c
index 5fcfe77..c6f6790 100644
--- a/src/fat_adv.c
+++ b/src/fat_adv.c
@@ -173,7 +173,7 @@ static unsigned long int get_subdirectory(disk_t *disk_car,const uint64_t hd_off
#ifdef HAVE_NCURSES
#define INTER_DIR 16
-static int ask_root_directory(disk_t *disk_car, const partition_t *partition, const file_info_t*dir_list, const unsigned long int cluster)
+static int ask_root_directory(const disk_t *disk_car, const partition_t *partition, const file_info_t*dir_list, const unsigned long int cluster)
{
/* Return value
* -1: quit
diff --git a/src/fat_cluster.c b/src/fat_cluster.c
index 1384202..a009e7f 100644
--- a/src/fat_cluster.c
+++ b/src/fat_cluster.c
@@ -42,7 +42,7 @@
/* Using a couple of inodes of "." directory entries, get the cluster size and where the first cluster begins.
* */
-int find_sectors_per_cluster(disk_t *disk_car, partition_t *partition, const int verbose, const int dump_ind, unsigned int *sectors_per_cluster, uint64_t *offset_org, const upart_type_t upart_type)
+int find_sectors_per_cluster(disk_t *disk_car, const partition_t *partition, const int verbose, const int dump_ind, unsigned int *sectors_per_cluster, uint64_t *offset_org, const upart_type_t upart_type)
{
unsigned int nbr_subdir=0;
sector_cluster_t sector_cluster[10];
diff --git a/src/fat_cluster.h b/src/fat_cluster.h
index a5b3d2f..9bc53fe 100644
--- a/src/fat_cluster.h
+++ b/src/fat_cluster.h
@@ -42,7 +42,7 @@ struct cluster_offset_struct
unsigned int first_sol;
};
-int find_sectors_per_cluster(disk_t *disk_car, partition_t *partition, const int verbose, const int dump_ind, unsigned int *sectors_per_cluster, uint64_t *offset, const upart_type_t upart_type);
+int find_sectors_per_cluster(disk_t *disk_car, const partition_t *partition, const int verbose, const int dump_ind, unsigned int *sectors_per_cluster, uint64_t *offset, const upart_type_t upart_type);
upart_type_t no_of_cluster2part_type(const unsigned long int no_of_cluster);
int find_sectors_per_cluster_aux(const sector_cluster_t *sector_cluster, const unsigned int nbr_sector_cluster,unsigned int *sectors_per_cluster, uint64_t *offset, const int verbose, const unsigned long int part_size_in_sectors, const upart_type_t upart_type);
diff --git a/src/fat_unformat.c b/src/fat_unformat.c
index a31883c..885ecda 100644
--- a/src/fat_unformat.c
+++ b/src/fat_unformat.c
@@ -58,7 +58,7 @@
extern int need_to_stop;
#define READ_SIZE 4*1024*1024
-static int pfind_sectors_per_cluster(disk_t *disk, partition_t *partition, const int verbose, unsigned int *sectors_per_cluster, uint64_t *offset_org, alloc_data_t *list_search_space)
+static int pfind_sectors_per_cluster(disk_t *disk, const partition_t *partition, const int verbose, unsigned int *sectors_per_cluster, uint64_t *offset_org, alloc_data_t *list_search_space)
{
uint64_t offset=0;
uint64_t next_offset=0;
diff --git a/src/file_doc.c b/src/file_doc.c
index 4c25d08..a0361f9 100644
--- a/src/file_doc.c
+++ b/src/file_doc.c
@@ -1264,7 +1264,7 @@ static void OLE_parse_summary_aux(const unsigned char *dataPt, const unsigned in
@ requires 48 <= len <= 1024*1024;
@ ensures \result!=\null ==> \valid((char *)\result + (0 .. len-1));
@*/
-static void *OLE_read_ministream(unsigned char *ministream,
+static void *OLE_read_ministream(const unsigned char *ministream,
const uint32_t *minifat, const unsigned int minifat_entries, const unsigned int uMiniSectorShift,
const unsigned int miniblock_start, const unsigned int len, const unsigned int ministream_size)
{
diff --git a/src/filegen.c b/src/filegen.c
index 8e010f8..4952ee9 100644
--- a/src/filegen.c
+++ b/src/filegen.c
@@ -811,7 +811,7 @@ void header_ignored(const file_recovery_t *file_recovery_new)
offset_skipped_header=file_recovery_new->location.start;
}
-void get_prev_location_smart(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const uint64_t prev_location)
+void get_prev_location_smart(const alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const uint64_t prev_location)
{
alloc_data_t *file_space=*current_search_space;
if(offset_skipped_header==0)
diff --git a/src/filegen.h b/src/filegen.h
index 5521ef2..573997c 100644
--- a/src/filegen.h
+++ b/src/filegen.h
@@ -310,7 +310,7 @@ time_t get_time_from_YYYYMMDD_HHMMSS(const char *date_asc);
@ requires \valid(current_search_space);
@ requires \valid(offset);
@*/
-void get_prev_location_smart(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const uint64_t prev_location);
+void get_prev_location_smart(const alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const uint64_t prev_location);
#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif
diff --git a/src/gfs2.c b/src/gfs2.c
index e710dd2..9784c9c 100644
--- a/src/gfs2.c
+++ b/src/gfs2.c
@@ -40,7 +40,7 @@ static void set_gfs2_info(partition_t *partition)
partition->info[0]='\0';
}
-static int test_gfs2(disk_t *disk, const struct gfs2_sb *sb, const partition_t *partition, const int dump_ind)
+static int test_gfs2(const disk_t *disk, const struct gfs2_sb *sb, const partition_t *partition, const int dump_ind)
{
if(sb->sb_header.mh_magic != be32(GFS2_MAGIC))
return 1;
diff --git a/src/godmode.c b/src/godmode.c
index 0b41b0e..fc15c77 100644
--- a/src/godmode.c
+++ b/src/godmode.c
@@ -60,22 +60,13 @@ extern const arch_fnct_t arch_mac;
extern const arch_fnct_t arch_none;
extern const arch_fnct_t arch_sun;
extern const arch_fnct_t arch_xbox;
-static int use_backup(disk_t *disk_car, const list_part_t *list_part, const int verbose,const int dump_ind, const unsigned int expert, char**current_cmd);
-static int interface_part_bad_log(disk_t *disk_car,list_part_t *list_part_bad);
#ifdef HAVE_NCURSES
-static int interface_part_bad_ncurses(disk_t *disk_car, list_part_t *list_part_bad);
-static void ask_mbr_order_i386(disk_t *disk_car,list_part_t *list_part);
#define ANALYSE_X 0
#define ANALYSE_Y 5
#define INTER_BAD_PART 10
#endif
-static list_part_t *add_ext_part_i386(disk_t *disk_car, list_part_t *list_part, const int max_ext, const int verbose);
-static void hint_insert(uint64_t *tab, const uint64_t offset, unsigned int *tab_nbr);
-/* Optimization */
-static inline uint64_t CHS2offset_inline(const disk_t *disk_car,const CHS_t*CHS);
-static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_org, const int verbose, const int dump_ind, const int fast_mode, char **current_cmd);
-static inline void offset2CHS_inline(const disk_t *disk_car,const uint64_t offset, CHS_t*CHS);
+/* Optimization */
static inline void offset2CHS_inline(const disk_t *disk_car,const uint64_t offset, CHS_t*CHS)
{
uint64_t pos=offset/disk_car->sector_size;
@@ -160,7 +151,7 @@ static void align_structure(list_part_t *list_part, const disk_t *disk, const un
}
}
-void only_one_bootable( list_part_t *list_part, list_part_t *part_boot)
+void only_one_bootable( list_part_t *list_part, const list_part_t *part_boot)
{
list_part_t *element;
if(part_boot->part->status==STATUS_PRIM_BOOT)
@@ -1124,7 +1115,7 @@ static list_part_t *reduce_structure(const list_part_t *list_part_org)
return list_part;
}
-static list_part_t *add_ext_part_i386(disk_t *disk, list_part_t *list_part, const int max_ext, const int verbose)
+static list_part_t *add_ext_part_i386(const disk_t *disk, list_part_t *list_part, const int max_ext, const int verbose)
{
/* list_part need to be sorted! */
/* All extended partitions of an P_EXTENDX are P_EXTENDED */
diff --git a/src/godmode.h b/src/godmode.h
index 1af7448..d93081b 100644
--- a/src/godmode.h
+++ b/src/godmode.h
@@ -25,7 +25,7 @@ extern "C" {
typedef enum part_offset part_offset_t;
int interface_recovery(disk_t *disk_car, const list_part_t * list_part_org, const int verbose, const int dump_ind, const int align, const int ask_part_order, const unsigned int expert, char **current_cmd);
-void only_one_bootable( list_part_t *list_part, list_part_t *part_boot);
+void only_one_bootable( list_part_t *list_part, const list_part_t *part_boot);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/hfsp.c b/src/hfsp.c
index 040a859..bfdab80 100644
--- a/src/hfsp.c
+++ b/src/hfsp.c
@@ -52,7 +52,6 @@ static void set_HFSP_info(partition_t *partition, const struct hfsp_vh *vh)
}
}
-
int check_HFSP(disk_t *disk_car,partition_t *partition,const int verbose)
{
unsigned char *buffer=(unsigned char*)MALLOC(HFSP_BOOT_SECTOR_SIZE);
@@ -116,7 +115,7 @@ int recover_HFSP(disk_t *disk_car, const struct hfsp_vh *vh,partition_t *partiti
return 0;
}
-int test_HFSP(disk_t *disk_car, const struct hfsp_vh *vh, const partition_t *partition, const int verbose, const int dump_ind)
+int test_HFSP(const disk_t *disk_car, const struct hfsp_vh *vh, const partition_t *partition, const int verbose, const int dump_ind)
{
if (be32(vh->free_blocks) > be32(vh->total_blocks))
return 1;
diff --git a/src/hfsp.h b/src/hfsp.h
index 4cbb928..daad758 100644
--- a/src/hfsp.h
+++ b/src/hfsp.h
@@ -149,7 +149,7 @@ typedef struct hfsp_vh {
int check_HFSP(disk_t *disk_car,partition_t *partition,const int verbose);
-int test_HFSP(disk_t *disk_car, const struct hfsp_vh *vh, const partition_t *partition, const int verbose, const int dump_ind);
+int test_HFSP(const disk_t *disk_car, const struct hfsp_vh *vh, const partition_t *partition, const int verbose, const int dump_ind);
int recover_HFSP(disk_t *disk_car, const struct hfsp_vh *vh,partition_t *partition,const int verbose, const int dump_ind, const int backup);
#ifdef __cplusplus
diff --git a/src/hpfs.c b/src/hpfs.c
index 8524491..43877f0 100644
--- a/src/hpfs.c
+++ b/src/hpfs.c
@@ -46,7 +46,7 @@ static void set_HPFS_info(partition_t *partition)
partition->upart_type=UP_HPFS;
}
-static int test_HPFS(disk_t *disk_car, const struct fat_boot_sector *hpfs_header, const partition_t *partition, const int verbose, const int dump_ind)
+static int test_HPFS(const disk_t *disk_car, const struct fat_boot_sector *hpfs_header, const partition_t *partition, const int verbose, const int dump_ind)
{
const char*buffer=(const char*)hpfs_header;
if(le16(hpfs_header->marker)==0xAA55)
diff --git a/src/jfs.c b/src/jfs.c
index 4dfc4f4..fc702da 100644
--- a/src/jfs.c
+++ b/src/jfs.c
@@ -37,8 +37,42 @@
#include "log.h"
#include "guid_cpy.h"
-static int test_JFS(disk_t *disk_car, const struct jfs_superblock *sb, const partition_t *partition, const int dump_ind);
-static void set_JFS_info(const struct jfs_superblock *sb, partition_t *partition);
+static void set_JFS_info(const struct jfs_superblock *sb, partition_t *partition)
+{
+ partition->upart_type=UP_JFS;
+ partition->blocksize=le32(sb->s_bsize);
+ snprintf(partition->info, sizeof(partition->info), "JFS %u, blocksize=%u",
+ (unsigned int)le32(sb->s_version), partition->blocksize);
+ partition->fsname[0]='\0';
+ if(le32(sb->s_version)==1)
+ {
+ set_part_name(partition,sb->s_fpack,11);
+ }
+}
+
+static int test_JFS(const disk_t *disk_car, const struct jfs_superblock *sb, const partition_t *partition, const int dump_ind)
+{
+ if(memcmp(sb->s_magic,"JFS1",4)!=0)
+ return 1;
+ /* Blocksize must be a multiple of 512 */
+ if(le32(sb->s_bsize)<512 ||
+ ((le32(sb->s_bsize)-1) & le32(sb->s_bsize))!=0)
+ return 1;
+ if(dump_ind!=0)
+ {
+ log_info("\nJFS magic value at %u/%u/%u\n", offset2cylinder(disk_car,partition->part_offset),offset2head(disk_car,partition->part_offset),offset2sector(disk_car,partition->part_offset));
+ /* There is a little offset ... */
+ dump_log(sb,DEFAULT_SECTOR_SIZE);
+ }
+ /*
+ if( le32(sb->s_agsize) >= (1 << L2BPERDMAP) ) {
+ return 2;
+ }
+ if(partition->part_size!=0 && (partition->part_size<le64(sb->s_size)))
+ return 8;
+ */
+ return 0;
+}
int check_JFS(disk_t *disk_car, partition_t *partition)
{
@@ -58,23 +92,10 @@ int check_JFS(disk_t *disk_car, partition_t *partition)
return 0;
}
-static void set_JFS_info(const struct jfs_superblock *sb, partition_t *partition)
-{
- partition->upart_type=UP_JFS;
- partition->blocksize=le32(sb->s_bsize);
- snprintf(partition->info, sizeof(partition->info), "JFS %u, blocksize=%u",
- (unsigned int)le32(sb->s_version), partition->blocksize);
- partition->fsname[0]='\0';
- if(le32(sb->s_version)==1)
- {
- set_part_name(partition,sb->s_fpack,11);
- }
-}
-
/*
Primary superblock is at 0x8000
*/
-int recover_JFS(disk_t *disk_car, const struct jfs_superblock *sb,partition_t *partition,const int verbose, const int dump_ind)
+int recover_JFS(const disk_t *disk_car, const struct jfs_superblock *sb,partition_t *partition,const int verbose, const int dump_ind)
{
if(test_JFS(disk_car, sb, partition, dump_ind)!=0)
return 1;
@@ -100,27 +121,3 @@ int recover_JFS(disk_t *disk_car, const struct jfs_superblock *sb,partition_t *p
}
return 0;
}
-
-static int test_JFS(disk_t *disk_car, const struct jfs_superblock *sb, const partition_t *partition, const int dump_ind)
-{
- if(memcmp(sb->s_magic,"JFS1",4)!=0)
- return 1;
- /* Blocksize must be a multiple of 512 */
- if(le32(sb->s_bsize)<512 ||
- ((le32(sb->s_bsize)-1) & le32(sb->s_bsize))!=0)
- return 1;
- if(dump_ind!=0)
- {
- log_info("\nJFS magic value at %u/%u/%u\n", offset2cylinder(disk_car,partition->part_offset),offset2head(disk_car,partition->part_offset),offset2sector(disk_car,partition->part_offset));
- /* There is a little offset ... */
- dump_log(sb,DEFAULT_SECTOR_SIZE);
- }
- /*
- if( le32(sb->s_agsize) >= (1 << L2BPERDMAP) ) {
- return 2;
- }
- if(partition->part_size!=0 && (partition->part_size<le64(sb->s_size)))
- return 8;
- */
- return 0;
-}
diff --git a/src/jfs.h b/src/jfs.h
index 74d38d7..12b53dd 100644
--- a/src/jfs.h
+++ b/src/jfs.h
@@ -27,7 +27,7 @@ extern "C" {
#define L2BPERDMAP 13 /* l2 num of blks per dmap */
int check_JFS(disk_t *disk_car, partition_t *partition);
-int recover_JFS(disk_t *disk_car, const struct jfs_superblock *sb,partition_t *partition,const int verbose, const int dump_ind);
+int recover_JFS(const disk_t *disk_car, const struct jfs_superblock *sb,partition_t *partition,const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/luks.c b/src/luks.c
index 9704839..53b0660 100644
--- a/src/luks.c
+++ b/src/luks.c
@@ -36,8 +36,31 @@
#include "log.h"
#include "guid_cpy.h"
-static int test_LUKS(disk_t *disk_car, const struct luks_phdr *sb, const partition_t *partition, const int dump_ind);
-static void set_LUKS_info(const struct luks_phdr *sb, partition_t *partition);
+static void set_LUKS_info(const struct luks_phdr *sb, partition_t *partition)
+{
+ partition->upart_type=UP_LUKS;
+ if(partition->part_size > 0)
+ sprintf(partition->info,"LUKS %u", be16(sb->version));
+ else
+ sprintf(partition->info,"LUKS %u (Data size unknown)", be16(sb->version));
+}
+
+static int test_LUKS(const disk_t *disk_car, const struct luks_phdr *sb, const partition_t *partition, const int dump_ind)
+{
+ static const uint8_t LUKS_MAGIC[LUKS_MAGIC_L] = {'L','U','K','S', 0xba, 0xbe};
+ if(memcmp(sb->magic, LUKS_MAGIC, LUKS_MAGIC_L)!=0)
+ return 1;
+ if(dump_ind!=0)
+ {
+ if(partition!=NULL && disk_car!=NULL)
+ log_info("\nLUKS magic value at %u/%u/%u\n",
+ offset2cylinder(disk_car,partition->part_offset),
+ offset2head(disk_car,partition->part_offset),
+ offset2sector(disk_car,partition->part_offset));
+ dump_log(sb,DEFAULT_SECTOR_SIZE);
+ }
+ return 0;
+}
int check_LUKS(disk_t *disk_car,partition_t *partition)
{
@@ -57,16 +80,7 @@ int check_LUKS(disk_t *disk_car,partition_t *partition)
return 0;
}
-static void set_LUKS_info(const struct luks_phdr *sb, partition_t *partition)
-{
- partition->upart_type=UP_LUKS;
- if(partition->part_size > 0)
- sprintf(partition->info,"LUKS %u", be16(sb->version));
- else
- sprintf(partition->info,"LUKS %u (Data size unknown)", be16(sb->version));
-}
-
-int recover_LUKS(disk_t *disk_car, const struct luks_phdr *sb,partition_t *partition,const int verbose, const int dump_ind)
+int recover_LUKS(const disk_t *disk_car, const struct luks_phdr *sb,partition_t *partition,const int verbose, const int dump_ind)
{
if(test_LUKS(disk_car, sb, partition, dump_ind)!=0)
return 1;
@@ -89,20 +103,3 @@ int recover_LUKS(disk_t *disk_car, const struct luks_phdr *sb,partition_t *parti
}
return 0;
}
-
-static int test_LUKS(disk_t *disk_car, const struct luks_phdr *sb, const partition_t *partition, const int dump_ind)
-{
- static const uint8_t LUKS_MAGIC[LUKS_MAGIC_L] = {'L','U','K','S', 0xba, 0xbe};
- if(memcmp(sb->magic, LUKS_MAGIC, LUKS_MAGIC_L)!=0)
- return 1;
- if(dump_ind!=0)
- {
- if(partition!=NULL && disk_car!=NULL)
- log_info("\nLUKS magic value at %u/%u/%u\n",
- offset2cylinder(disk_car,partition->part_offset),
- offset2head(disk_car,partition->part_offset),
- offset2sector(disk_car,partition->part_offset));
- dump_log(sb,DEFAULT_SECTOR_SIZE);
- }
- return 0;
-}
diff --git a/src/luks.h b/src/luks.h
index de67e4b..514c7d7 100644
--- a/src/luks.h
+++ b/src/luks.h
@@ -57,7 +57,7 @@ struct luks_phdr {
};
int check_LUKS(disk_t *disk_car, partition_t *partition);
-int recover_LUKS(disk_t *disk_car, const struct luks_phdr *sb,partition_t *partition,const int verbose, const int dump_ind);
+int recover_LUKS(const disk_t *disk_car, const struct luks_phdr *sb,partition_t *partition,const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/lvm.c b/src/lvm.c
index f8375d6..7e62261 100644
--- a/src/lvm.c
+++ b/src/lvm.c
@@ -37,11 +37,52 @@
#include "log.h"
#include "guid_cpy.h"
-static void set_LVM_info(partition_t *partition);
-static int test_LVM(disk_t *disk_car, const pv_disk_t *pv, const partition_t *partition,const int verbose, const int dump_ind);
+static void set_LVM_info(partition_t *partition)
+{
+ partition->upart_type=UP_LVM;
+ partition->fsname[0]='\0';
+ partition->info[0]='\0';
+ snprintf(partition->info,sizeof(partition->info),"LVM");
+}
+
+static int test_LVM(const disk_t *disk_car, const pv_disk_t *pv, const partition_t *partition, const int verbose, const int dump_ind)
+{
+ if ((memcmp((const char *)pv->id,LVM_ID,sizeof(pv->id)) == 0) && (le16(pv->version) == 1 || le16(pv->version) == 2))
+ {
+ uint32_t size;
+ if(verbose>0 || dump_ind!=0)
+ {
+ log_info("\nLVM magic value at %u/%u/%u\n", offset2cylinder(disk_car,partition->part_offset),offset2head(disk_car,partition->part_offset),offset2sector(disk_car,partition->part_offset));
+ }
+ if(dump_ind!=0)
+ {
+ /* There is a little offset ... */
+ dump_log(pv,DEFAULT_SECTOR_SIZE);
+ }
+ if (le32(pv->pv_size) > LVM_MAX_SIZE)
+ return (1);
+ if (le32(pv->pv_status) != 0 && le32(pv->pv_status) != PV_ACTIVE)
+ return (1);
+ if (le32(pv->pv_allocatable) != 0 && le32(pv->pv_allocatable) != PV_ALLOCATABLE)
+ return (1);
+ if (le32(pv->lv_cur) > MAX_LV)
+ return (1);
+ if (strlen((const char *)pv->vg_name) > NAME_LEN / 2)
+ return (1);
+ size = le32(pv->pe_size) / LVM_MIN_PE_SIZE * LVM_MIN_PE_SIZE;
+ if ((le32(pv->pe_size) != size) ||
+ (le32(pv->pe_size) < LVM_MIN_PE_SIZE) ||
+ (le32(pv->pe_size) > LVM_MAX_PE_SIZE))
+ return (1);
-static void set_LVM2_info(partition_t*partition);
-static int test_LVM2(disk_t *disk_car, const struct lvm2_label_header *lh, const partition_t *partition, const int verbose, const int dump_ind);
+ if (le32(pv->pe_total) > ( pv->pe_on_disk.size / sizeof ( disk_pe_t)))
+ return (1);
+ if (le32(pv->pe_allocated) > le32(pv->pe_total))
+ return (1);
+ return 0;
+ }
+ return 1;
+}
int check_LVM(disk_t *disk_car,partition_t *partition,const int verbose)
{
@@ -61,7 +102,7 @@ int check_LVM(disk_t *disk_car,partition_t *partition,const int verbose)
return 0;
}
-int recover_LVM(disk_t *disk_car, const pv_disk_t *pv,partition_t *partition,const int verbose, const int dump_ind)
+int recover_LVM(const disk_t *disk_car, const pv_disk_t *pv,partition_t *partition,const int verbose, const int dump_ind)
{
if(test_LVM(disk_car,pv,partition,verbose,dump_ind)!=0)
return 1;
@@ -79,53 +120,34 @@ int recover_LVM(disk_t *disk_car, const pv_disk_t *pv,partition_t *partition,con
return 0;
}
-static int test_LVM(disk_t *disk_car, const pv_disk_t *pv, const partition_t *partition, const int verbose, const int dump_ind)
+static void set_LVM2_info(partition_t*partition)
{
- if ((memcmp((const char *)pv->id,LVM_ID,sizeof(pv->id)) == 0) && (le16(pv->version) == 1 || le16(pv->version) == 2))
+ partition->upart_type=UP_LVM2;
+ partition->fsname[0]='\0';
+ partition->info[0]='\0';
+ snprintf(partition->info,sizeof(partition->info),"LVM2");
+}
+
+static int test_LVM2(const disk_t *disk_car, const struct lvm2_label_header *lh, const partition_t *partition, const int verbose, const int dump_ind)
+{
+ if (memcmp((const char *)lh->type,LVM2_LABEL,sizeof(lh->type)) == 0)
{
- uint32_t size;
if(verbose>0 || dump_ind!=0)
{
- log_info("\nLVM magic value at %u/%u/%u\n", offset2cylinder(disk_car,partition->part_offset),offset2head(disk_car,partition->part_offset),offset2sector(disk_car,partition->part_offset));
+ log_info("\nLVM2 magic value at %u/%u/%u\n", offset2cylinder(disk_car,partition->part_offset),offset2head(disk_car,partition->part_offset),offset2sector(disk_car,partition->part_offset));
}
+ if(le32(lh->offset_xl)>400)
+ return 1;
if(dump_ind!=0)
{
/* There is a little offset ... */
- dump_log(pv,DEFAULT_SECTOR_SIZE);
+ dump_log(lh,DEFAULT_SECTOR_SIZE);
}
- if (le32(pv->pv_size) > LVM_MAX_SIZE)
- return (1);
- if (le32(pv->pv_status) != 0 && le32(pv->pv_status) != PV_ACTIVE)
- return (1);
- if (le32(pv->pv_allocatable) != 0 && le32(pv->pv_allocatable) != PV_ALLOCATABLE)
- return (1);
- if (le32(pv->lv_cur) > MAX_LV)
- return (1);
- if (strlen((const char *)pv->vg_name) > NAME_LEN / 2)
- return (1);
- size = le32(pv->pe_size) / LVM_MIN_PE_SIZE * LVM_MIN_PE_SIZE;
- if ((le32(pv->pe_size) != size) ||
- (le32(pv->pe_size) < LVM_MIN_PE_SIZE) ||
- (le32(pv->pe_size) > LVM_MAX_PE_SIZE))
- return (1);
-
- if (le32(pv->pe_total) > ( pv->pe_on_disk.size / sizeof ( disk_pe_t)))
- return (1);
- if (le32(pv->pe_allocated) > le32(pv->pe_total))
- return (1);
return 0;
}
return 1;
}
-static void set_LVM_info(partition_t *partition)
-{
- partition->upart_type=UP_LVM;
- partition->fsname[0]='\0';
- partition->info[0]='\0';
- snprintf(partition->info,sizeof(partition->info),"LVM");
-}
-
int check_LVM2(disk_t *disk_car,partition_t *partition,const int verbose)
{
unsigned char *buffer=(unsigned char *)MALLOC(DEFAULT_SECTOR_SIZE);
@@ -144,7 +166,7 @@ int check_LVM2(disk_t *disk_car,partition_t *partition,const int verbose)
return 0;
}
-int recover_LVM2(disk_t *disk_car, const unsigned char *buf,partition_t *partition,const int verbose, const int dump_ind)
+int recover_LVM2(const disk_t *disk_car, const unsigned char *buf,partition_t *partition,const int verbose, const int dump_ind)
{
const struct lvm2_label_header *lh=(const struct lvm2_label_header *)buf;
if(test_LVM2(disk_car,lh,partition,verbose,dump_ind)!=0)
@@ -164,31 +186,3 @@ int recover_LVM2(disk_t *disk_car, const unsigned char *buf,partition_t *partiti
}
return 0;
}
-
-static int test_LVM2(disk_t *disk_car, const struct lvm2_label_header *lh, const partition_t *partition, const int verbose, const int dump_ind)
-{
- if (memcmp((const char *)lh->type,LVM2_LABEL,sizeof(lh->type)) == 0)
- {
- if(verbose>0 || dump_ind!=0)
- {
- log_info("\nLVM2 magic value at %u/%u/%u\n", offset2cylinder(disk_car,partition->part_offset),offset2head(disk_car,partition->part_offset),offset2sector(disk_car,partition->part_offset));
- }
- if(le32(lh->offset_xl)>400)
- return 1;
- if(dump_ind!=0)
- {
- /* There is a little offset ... */
- dump_log(lh,DEFAULT_SECTOR_SIZE);
- }
- return 0;
- }
- return 1;
-}
-
-static void set_LVM2_info(partition_t*partition)
-{
- partition->upart_type=UP_LVM2;
- partition->fsname[0]='\0';
- partition->info[0]='\0';
- snprintf(partition->info,sizeof(partition->info),"LVM2");
-}
diff --git a/src/lvm.h b/src/lvm.h
index 65a92b5..2ca728d 100644
--- a/src/lvm.h
+++ b/src/lvm.h
@@ -91,7 +91,7 @@ typedef struct {
#define pv_disk_t pv_disk_v2_t
int check_LVM(disk_t *disk_car,partition_t *partition,const int verbose);
-int recover_LVM(disk_t *disk_car, const pv_disk_t *pv,partition_t *partition,const int verbose, const int dump_ind);
+int recover_LVM(const disk_t *disk_car, const pv_disk_t *pv,partition_t *partition,const int verbose, const int dump_ind);
#define LVM2_LABEL "LVM2 001"
#define LABEL_ID "LABELONE"
@@ -119,7 +119,7 @@ struct lvm2_pv_header {
} __attribute__ ((packed));
int check_LVM2(disk_t *disk_car,partition_t *partition,const int verbose);
-int recover_LVM2(disk_t *disk_car, const unsigned char *buf,partition_t *partition,const int verbose, const int dump_ind);
+int recover_LVM2(const disk_t *disk_car, const unsigned char *buf,partition_t *partition,const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/md.c b/src/md.c
index 5d25331..2f43bc6 100644
--- a/src/md.c
+++ b/src/md.c
@@ -35,10 +35,182 @@
#include "md.h"
#include "fnctdsk.h"
#include "log.h"
-static int test_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, const partition_t *partition, const int dump_ind);
-static int test_MD_be(disk_t *disk_car, const struct mdp_superblock_s *sb, const partition_t *partition, const int dump_ind);
-static void set_MD_info(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose);
-static void set_MD_info_be(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose);
+
+static int test_MD(const disk_t *disk_car, const struct mdp_superblock_s *sb, const partition_t *partition, const int dump_ind)
+{
+ if(le32(sb->md_magic)!=(unsigned int)MD_SB_MAGIC)
+ return 1;
+ log_info("\nRaid magic value at %u/%u/%u\n",
+ offset2cylinder(disk_car,partition->part_offset),
+ offset2head(disk_car,partition->part_offset),
+ offset2sector(disk_car,partition->part_offset));
+ log_info("Raid apparent size: %llu sectors\n", (long long unsigned)(sb->size<<1));
+ if(le32(sb->major_version)==0)
+ {
+ /* chunk_size may be 0 */
+ log_info("Raid chunk size: %llu bytes\n", (long long unsigned)le32(sb->chunk_size));
+ }
+ if(le32(sb->major_version)>1)
+ return 1;
+ if(dump_ind!=0)
+ {
+ /* There is a little offset ... */
+ dump_log(sb,DEFAULT_SECTOR_SIZE);
+ }
+ return 0;
+}
+
+static int test_MD_be(const disk_t *disk_car, const struct mdp_superblock_s *sb, const partition_t *partition, const int dump_ind)
+{
+ if(be32(sb->md_magic)!=(unsigned int)MD_SB_MAGIC)
+ return 1;
+ log_info("\nRaid magic value at %u/%u/%u\n",
+ offset2cylinder(disk_car,partition->part_offset),
+ offset2head(disk_car,partition->part_offset),
+ offset2sector(disk_car,partition->part_offset));
+ log_info("Raid apparent size: %llu sectors\n", (long long unsigned)(sb->size<<1));
+ if(be32(sb->major_version)==0)
+ {
+ /* chunk_size may be 0 */
+ log_info("Raid chunk size: %llu bytes\n",(long long unsigned)be32(sb->chunk_size));
+ }
+ if(be32(sb->major_version)>1)
+ return 1;
+ if(dump_ind!=0)
+ {
+ /* There is a little offset ... */
+ dump_log(sb,DEFAULT_SECTOR_SIZE);
+ }
+ return 0;
+}
+
+static void set_MD_info(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose)
+{
+ if(le32(sb->major_version)==0)
+ {
+ unsigned int i;
+ partition->upart_type=UP_MD;
+ sprintf(partition->fsname,"md%u",(unsigned int)le32(sb->md_minor));
+ sprintf(partition->info,"md %u.%u.%u L.Endian Raid %u: devices",
+ (unsigned int)le32(sb->major_version),
+ (unsigned int)le32(sb->minor_version),
+ (unsigned int)le32(sb->patch_version),
+ (unsigned int)le32(sb->level));
+ for(i=0;i<MD_SB_DISKS;i++)
+ {
+ if(le32(sb->disks[i].major)!=0 && le32(sb->disks[i].minor)!=0)
+ {
+ if(strlen(partition->info)<sizeof(partition->info)-26)
+ {
+ sprintf(&partition->info[strlen(partition->info)]," %u(%u,%u)",
+ (unsigned int)le32(sb->disks[i].number),
+ (unsigned int)le32(sb->disks[i].major),
+ (unsigned int)le32(sb->disks[i].minor));
+ if(le32(sb->disks[i].major)==le32(sb->this_disk.major) &&
+ le32(sb->disks[i].minor)==le32(sb->this_disk.minor))
+ sprintf(&partition->info[strlen(partition->info)],"*");
+ }
+ }
+ }
+ }
+ else
+ {
+ const struct mdp_superblock_1 *sb1=(const struct mdp_superblock_1 *)sb;
+ partition->upart_type=UP_MD1;
+ set_part_name(partition,sb1->set_name,32);
+ sprintf(partition->info,"md %u.x L.Endian Raid %u - Array Slot : %lu",
+ (unsigned int)le32(sb1->major_version),
+ (unsigned int)le32(sb1->level),
+ (long unsigned)le32(sb1->dev_number));
+ if(le32(sb1->max_dev) <= 384)
+ {
+ unsigned int i,d;
+ for (i= le32(sb1->max_dev); i> 0 ; i--)
+ if (le16(sb1->dev_roles[i-1]) != 0xffff)
+ break;
+ strcat(partition->info, " (");
+ for (d=0; d < i && strlen(partition->info) < sizeof(partition->info) - 9; d++)
+ {
+ const int role = le16(sb1->dev_roles[d]);
+ if (d)
+ strcat(partition->info, ", ");
+ if (role == 0xffff)
+ strcat(partition->info, "empty");
+ else if(role == 0xfffe)
+ strcat(partition->info, "failed");
+ else
+ sprintf(&partition->info[strlen(partition->info)], "%d", role);
+ }
+ strcat(partition->info, ")");
+ }
+ }
+ if(verbose>0)
+ log_info("%s %s\n", partition->fsname, partition->info);
+}
+
+static void set_MD_info_be(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose)
+{
+ if(be32(sb->major_version)==0)
+ {
+ unsigned int i;
+ partition->upart_type=UP_MD;
+ sprintf(partition->fsname,"md%u",(unsigned int)be32(sb->md_minor));
+ sprintf(partition->info,"md %u.%u.%u B.Endian Raid %u: devices",
+ (unsigned int)be32(sb->major_version),
+ (unsigned int)be32(sb->minor_version),
+ (unsigned int)be32(sb->patch_version),
+ (unsigned int)be32(sb->level));
+ for(i=0;i<MD_SB_DISKS;i++)
+ {
+ if(be32(sb->disks[i].major)!=0 && be32(sb->disks[i].minor)!=0)
+ {
+ if(strlen(partition->info)<sizeof(partition->info)-26)
+ {
+ sprintf(&partition->info[strlen(partition->info)]," %u(%u,%u)",
+ (unsigned int)be32(sb->disks[i].number),
+ (unsigned int)be32(sb->disks[i].major),
+ (unsigned int)be32(sb->disks[i].minor));
+ if(be32(sb->disks[i].major)==be32(sb->this_disk.major) &&
+ be32(sb->disks[i].minor)==be32(sb->this_disk.minor))
+ sprintf(&partition->info[strlen(partition->info)],"*");
+ }
+ }
+ }
+ }
+ else
+ {
+ const struct mdp_superblock_1 *sb1=(const struct mdp_superblock_1 *)sb;
+ partition->upart_type=UP_MD1;
+ set_part_name(partition,sb1->set_name,32);
+ sprintf(partition->info,"md %u.x B.Endian Raid %u - Array Slot : %lu",
+ (unsigned int)be32(sb1->major_version),
+ (unsigned int)be32(sb1->level),
+ (long unsigned)be32(sb1->dev_number));
+ if(be32(sb1->max_dev) <= 384)
+ {
+ unsigned int i,d;
+ for (i= be32(sb1->max_dev); i> 0 ; i--)
+ if (be16(sb1->dev_roles[i-1]) != 0xffff)
+ break;
+ strcat(partition->info, " (");
+ for (d=0; d < i && strlen(partition->info) < sizeof(partition->info) - 9; d++)
+ {
+ const int role = be16(sb1->dev_roles[d]);
+ if (d)
+ strcat(partition->info, ", ");
+ if (role == 0xffff)
+ strcat(partition->info, "empty");
+ else if(role == 0xfffe)
+ strcat(partition->info, "failed");
+ else
+ sprintf(&partition->info[strlen(partition->info)], "%d", role);
+ }
+ strcat(partition->info, ")");
+ }
+ }
+ if(verbose>0)
+ log_info("%s %s\n", partition->fsname, partition->info);
+}
int check_MD(disk_t *disk_car, partition_t *partition, const int verbose)
{
@@ -196,7 +368,7 @@ int recover_MD_from_partition(disk_t *disk_car, partition_t *partition, const in
return 1;
}
-int recover_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t *partition, const int verbose, const int dump_ind)
+int recover_MD(const disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t *partition, const int verbose, const int dump_ind)
{
if(test_MD(disk_car, sb, partition, dump_ind)==0)
{
@@ -240,179 +412,3 @@ int recover_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t
}
return 1;
}
-
-static void set_MD_info(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose)
-{
- if(le32(sb->major_version)==0)
- {
- unsigned int i;
- partition->upart_type=UP_MD;
- sprintf(partition->fsname,"md%u",(unsigned int)le32(sb->md_minor));
- sprintf(partition->info,"md %u.%u.%u L.Endian Raid %u: devices",
- (unsigned int)le32(sb->major_version),
- (unsigned int)le32(sb->minor_version),
- (unsigned int)le32(sb->patch_version),
- (unsigned int)le32(sb->level));
- for(i=0;i<MD_SB_DISKS;i++)
- {
- if(le32(sb->disks[i].major)!=0 && le32(sb->disks[i].minor)!=0)
- {
- if(strlen(partition->info)<sizeof(partition->info)-26)
- {
- sprintf(&partition->info[strlen(partition->info)]," %u(%u,%u)",
- (unsigned int)le32(sb->disks[i].number),
- (unsigned int)le32(sb->disks[i].major),
- (unsigned int)le32(sb->disks[i].minor));
- if(le32(sb->disks[i].major)==le32(sb->this_disk.major) &&
- le32(sb->disks[i].minor)==le32(sb->this_disk.minor))
- sprintf(&partition->info[strlen(partition->info)],"*");
- }
- }
- }
- }
- else
- {
- const struct mdp_superblock_1 *sb1=(const struct mdp_superblock_1 *)sb;
- partition->upart_type=UP_MD1;
- set_part_name(partition,sb1->set_name,32);
- sprintf(partition->info,"md %u.x L.Endian Raid %u - Array Slot : %lu",
- (unsigned int)le32(sb1->major_version),
- (unsigned int)le32(sb1->level),
- (long unsigned)le32(sb1->dev_number));
- if(le32(sb1->max_dev) <= 384)
- {
- unsigned int i,d;
- for (i= le32(sb1->max_dev); i> 0 ; i--)
- if (le16(sb1->dev_roles[i-1]) != 0xffff)
- break;
- strcat(partition->info, " (");
- for (d=0; d < i && strlen(partition->info) < sizeof(partition->info) - 9; d++)
- {
- const int role = le16(sb1->dev_roles[d]);
- if (d)
- strcat(partition->info, ", ");
- if (role == 0xffff)
- strcat(partition->info, "empty");
- else if(role == 0xfffe)
- strcat(partition->info, "failed");
- else
- sprintf(&partition->info[strlen(partition->info)], "%d", role);
- }
- strcat(partition->info, ")");
- }
- }
- if(verbose>0)
- log_info("%s %s\n", partition->fsname, partition->info);
-}
-
-static void set_MD_info_be(const struct mdp_superblock_s *sb, partition_t *partition, const int verbose)
-{
- if(be32(sb->major_version)==0)
- {
- unsigned int i;
- partition->upart_type=UP_MD;
- sprintf(partition->fsname,"md%u",(unsigned int)be32(sb->md_minor));
- sprintf(partition->info,"md %u.%u.%u B.Endian Raid %u: devices",
- (unsigned int)be32(sb->major_version),
- (unsigned int)be32(sb->minor_version),
- (unsigned int)be32(sb->patch_version),
- (unsigned int)be32(sb->level));
- for(i=0;i<MD_SB_DISKS;i++)
- {
- if(be32(sb->disks[i].major)!=0 && be32(sb->disks[i].minor)!=0)
- {
- if(strlen(partition->info)<sizeof(partition->info)-26)
- {
- sprintf(&partition->info[strlen(partition->info)]," %u(%u,%u)",
- (unsigned int)be32(sb->disks[i].number),
- (unsigned int)be32(sb->disks[i].major),
- (unsigned int)be32(sb->disks[i].minor));
- if(be32(sb->disks[i].major)==be32(sb->this_disk.major) &&
- be32(sb->disks[i].minor)==be32(sb->this_disk.minor))
- sprintf(&partition->info[strlen(partition->info)],"*");
- }
- }
- }
- }
- else
- {
- const struct mdp_superblock_1 *sb1=(const struct mdp_superblock_1 *)sb;
- partition->upart_type=UP_MD1;
- set_part_name(partition,sb1->set_name,32);
- sprintf(partition->info,"md %u.x B.Endian Raid %u - Array Slot : %lu",
- (unsigned int)be32(sb1->major_version),
- (unsigned int)be32(sb1->level),
- (long unsigned)be32(sb1->dev_number));
- if(be32(sb1->max_dev) <= 384)
- {
- unsigned int i,d;
- for (i= be32(sb1->max_dev); i> 0 ; i--)
- if (be16(sb1->dev_roles[i-1]) != 0xffff)
- break;
- strcat(partition->info, " (");
- for (d=0; d < i && strlen(partition->info) < sizeof(partition->info) - 9; d++)
- {
- const int role = be16(sb1->dev_roles[d]);
- if (d)
- strcat(partition->info, ", ");
- if (role == 0xffff)
- strcat(partition->info, "empty");
- else if(role == 0xfffe)
- strcat(partition->info, "failed");
- else
- sprintf(&partition->info[strlen(partition->info)], "%d", role);
- }
- strcat(partition->info, ")");
- }
- }
- if(verbose>0)
- log_info("%s %s\n", partition->fsname, partition->info);
-}
-
-static int test_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, const partition_t *partition, const int dump_ind)
-{
- if(le32(sb->md_magic)!=(unsigned int)MD_SB_MAGIC)
- return 1;
- log_info("\nRaid magic value at %u/%u/%u\n",
- offset2cylinder(disk_car,partition->part_offset),
- offset2head(disk_car,partition->part_offset),
- offset2sector(disk_car,partition->part_offset));
- log_info("Raid apparent size: %llu sectors\n", (long long unsigned)(sb->size<<1));
- if(le32(sb->major_version)==0)
- {
- /* chunk_size may be 0 */
- log_info("Raid chunk size: %llu bytes\n", (long long unsigned)le32(sb->chunk_size));
- }
- if(le32(sb->major_version)>1)
- return 1;
- if(dump_ind!=0)
- {
- /* There is a little offset ... */
- dump_log(sb,DEFAULT_SECTOR_SIZE);
- }
- return 0;
-}
-
-static int test_MD_be(disk_t *disk_car, const struct mdp_superblock_s *sb, const partition_t *partition, const int dump_ind)
-{
- if(be32(sb->md_magic)!=(unsigned int)MD_SB_MAGIC)
- return 1;
- log_info("\nRaid magic value at %u/%u/%u\n",
- offset2cylinder(disk_car,partition->part_offset),
- offset2head(disk_car,partition->part_offset),
- offset2sector(disk_car,partition->part_offset));
- log_info("Raid apparent size: %llu sectors\n", (long long unsigned)(sb->size<<1));
- if(be32(sb->major_version)==0)
- {
- /* chunk_size may be 0 */
- log_info("Raid chunk size: %llu bytes\n",(long long unsigned)be32(sb->chunk_size));
- }
- if(be32(sb->major_version)>1)
- return 1;
- if(dump_ind!=0)
- {
- /* There is a little offset ... */
- dump_log(sb,DEFAULT_SECTOR_SIZE);
- }
- return 0;
-}
diff --git a/src/md.h b/src/md.h
index fa2f680..6cedc58 100644
--- a/src/md.h
+++ b/src/md.h
@@ -254,7 +254,7 @@ static inline uint64_t md_event(mdp_super_t *sb) {
/* TestDisk */
int check_MD(disk_t *disk_car,partition_t *partition,const int verbose);
-int recover_MD(disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t *partition, const int verbose, const int dump_ind);
+int recover_MD(const disk_t *disk_car, const struct mdp_superblock_s *sb, partition_t *partition, const int verbose, const int dump_ind);
int recover_MD_from_partition(disk_t *disk_car, partition_t *partition, const int verbose);
#ifdef __cplusplus
diff --git a/src/netware.c b/src/netware.c
index eef5dab..37aa25a 100644
--- a/src/netware.c
+++ b/src/netware.c
@@ -60,7 +60,7 @@ int check_netware(disk_t *disk_car, partition_t *partition)
return 0;
}
-int recover_netware(disk_t *disk_car, const struct disk_netware *netware_block,partition_t *partition)
+int recover_netware(const disk_t *disk_car, const struct disk_netware *netware_block,partition_t *partition)
{
if(test_netware(netware_block)!=0)
return 1;
diff --git a/src/netware.h b/src/netware.h
index 8e52679..d2c8dcc 100644
--- a/src/netware.h
+++ b/src/netware.h
@@ -33,7 +33,7 @@ struct disk_netware
};
int check_netware(disk_t *disk_car, partition_t *partition);
-int recover_netware(disk_t *disk_car, const struct disk_netware *netware_block, partition_t *partition);
+int recover_netware(const disk_t *disk_car, const struct disk_netware *netware_block, partition_t *partition);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/ntfs_adv.c b/src/ntfs_adv.c
index 4bf9e0a..e4f6fd6 100644
--- a/src/ntfs_adv.c
+++ b/src/ntfs_adv.c
@@ -42,11 +42,6 @@
#include "log.h"
#include "log_part.h"
-#define INTER_NTFS_X 0
-#define INTER_NTFS_Y 23
-#define INTER_NTFSBS_X 0
-#define INTER_NTFSBS_Y 22
-
#define MAX_INFO_MFT 10
#define NTFS_SECTOR_SIZE 0x200
@@ -58,14 +53,42 @@ struct s_info_mft
uint64_t mftmirr_lcn;
};
-#ifdef HAVE_NCURSES
-static int ncurses_ntfs2_info(const struct ntfs_boot_sector *nh1, const struct ntfs_boot_sector *nh2);
-static int ncurses_ntfs_info(const struct ntfs_boot_sector *ntfs_header);
-#endif
static int testdisk_ffs(int x);
-static int read_mft_info(disk_t *disk_car, partition_t *partition, const uint64_t mft_sector, const int verbose, unsigned int *sectors_per_cluster, uint64_t *mft_lcn, uint64_t *mftmirr_lcn, unsigned int *mft_record_size);
#ifdef HAVE_NCURSES
+#define INTER_NTFS_X 0
+#define INTER_NTFS_Y 23
+#define INTER_NTFSBS_X 0
+#define INTER_NTFSBS_Y 22
+
+static int ncurses_ntfs_info(const struct ntfs_boot_sector *ntfs_header)
+{
+ wprintw(stdscr,"filesystem size %llu\n", (long long unsigned)(le64(ntfs_header->sectors_nbr)+1));
+ wprintw(stdscr,"sectors_per_cluster %u\n",ntfs_header->sectors_per_cluster);
+ wprintw(stdscr,"mft_lcn %lu\n",(long unsigned int)le64(ntfs_header->mft_lcn));
+ wprintw(stdscr,"mftmirr_lcn %lu\n",(long unsigned int)le64(ntfs_header->mftmirr_lcn));
+ wprintw(stdscr,"clusters_per_mft_record %d\n",ntfs_header->clusters_per_mft_record);
+ wprintw(stdscr,"clusters_per_index_record %d\n",ntfs_header->clusters_per_index_record);
+ return 0;
+}
+
+static int ncurses_ntfs2_info(const struct ntfs_boot_sector *nh1, const struct ntfs_boot_sector *nh2)
+{
+ wprintw(stdscr,"filesystem size %llu %llu\n",
+ (long long unsigned)(le64(nh1->sectors_nbr)+1),
+ (long long unsigned)(le64(nh2->sectors_nbr)+1));
+ wprintw(stdscr,"sectors_per_cluster %u %u\n",nh1->sectors_per_cluster,nh2->sectors_per_cluster);
+ wprintw(stdscr,"mft_lcn %lu %lu\n",
+ (long unsigned int)le64(nh1->mft_lcn),
+ (long unsigned int)le64(nh2->mft_lcn));
+ wprintw(stdscr,"mftmirr_lcn %lu %lu\n",
+ (long unsigned int)le64(nh1->mftmirr_lcn),
+ (long unsigned int)le64(nh2->mftmirr_lcn));
+ wprintw(stdscr,"clusters_per_mft_record %d %d\n",nh1->clusters_per_mft_record,nh2->clusters_per_mft_record);
+ wprintw(stdscr,"clusters_per_index_record %d %d\n",nh1->clusters_per_index_record,nh2->clusters_per_index_record);
+ return 0;
+}
+
static void ntfs_dump_ncurses(disk_t *disk_car, const partition_t *partition, const unsigned char *orgboot, const unsigned char *newboot)
{
WINDOW *window=newwin(LINES, COLS, 0, 0); /* full screen */
@@ -114,7 +137,7 @@ static void ntfs_write_boot_sector(disk_t *disk, partition_t *partition, const u
disk->sync(disk);
}
-static void ntfs_list(disk_t *disk, partition_t *partition, const unsigned char *newboot, char **current_cmd, const int expert)
+static void ntfs_list(disk_t *disk, const partition_t *partition, const unsigned char *newboot, char **current_cmd, const int expert)
{
io_redir_add_redir(disk,partition->part_offset,NTFS_SECTOR_SIZE,0,newboot);
dir_partition(disk, partition, 0, expert, current_cmd);
@@ -308,7 +331,7 @@ static void create_ntfs_boot_sector(disk_t *disk_car, partition_t *partition, co
#endif
}
-static int read_mft_info(disk_t *disk_car, partition_t *partition, const uint64_t mft_sector, const int verbose, unsigned int *sectors_per_cluster, uint64_t *mft_lcn, uint64_t *mftmirr_lcn, unsigned int *mft_record_size)
+static int read_mft_info(disk_t *disk_car, const partition_t *partition, const uint64_t mft_sector, const int verbose, unsigned int *sectors_per_cluster, uint64_t *mft_lcn, uint64_t *mftmirr_lcn, unsigned int *mft_record_size)
{
char buffer[8*DEFAULT_SECTOR_SIZE];
const struct ntfs_mft_record *record=(const struct ntfs_mft_record *)buffer;
@@ -667,36 +690,6 @@ static int testdisk_ffs(int x)
return r;
}
-#ifdef HAVE_NCURSES
-static int ncurses_ntfs_info(const struct ntfs_boot_sector *ntfs_header)
-{
- wprintw(stdscr,"filesystem size %llu\n", (long long unsigned)(le64(ntfs_header->sectors_nbr)+1));
- wprintw(stdscr,"sectors_per_cluster %u\n",ntfs_header->sectors_per_cluster);
- wprintw(stdscr,"mft_lcn %lu\n",(long unsigned int)le64(ntfs_header->mft_lcn));
- wprintw(stdscr,"mftmirr_lcn %lu\n",(long unsigned int)le64(ntfs_header->mftmirr_lcn));
- wprintw(stdscr,"clusters_per_mft_record %d\n",ntfs_header->clusters_per_mft_record);
- wprintw(stdscr,"clusters_per_index_record %d\n",ntfs_header->clusters_per_index_record);
- return 0;
-}
-
-static int ncurses_ntfs2_info(const struct ntfs_boot_sector *nh1, const struct ntfs_boot_sector *nh2)
-{
- wprintw(stdscr,"filesystem size %llu %llu\n",
- (long long unsigned)(le64(nh1->sectors_nbr)+1),
- (long long unsigned)(le64(nh2->sectors_nbr)+1));
- wprintw(stdscr,"sectors_per_cluster %u %u\n",nh1->sectors_per_cluster,nh2->sectors_per_cluster);
- wprintw(stdscr,"mft_lcn %lu %lu\n",
- (long unsigned int)le64(nh1->mft_lcn),
- (long unsigned int)le64(nh2->mft_lcn));
- wprintw(stdscr,"mftmirr_lcn %lu %lu\n",
- (long unsigned int)le64(nh1->mftmirr_lcn),
- (long unsigned int)le64(nh2->mftmirr_lcn));
- wprintw(stdscr,"clusters_per_mft_record %d %d\n",nh1->clusters_per_mft_record,nh2->clusters_per_mft_record);
- wprintw(stdscr,"clusters_per_index_record %d %d\n",nh1->clusters_per_index_record,nh2->clusters_per_index_record);
- return 0;
-}
-#endif
-
int log_ntfs2_info(const struct ntfs_boot_sector *nh1, const struct ntfs_boot_sector *nh2)
{
log_info("filesystem size %llu %llu\n",
@@ -709,5 +702,3 @@ int log_ntfs2_info(const struct ntfs_boot_sector *nh1, const struct ntfs_boot_se
log_info("clusters_per_index_record %d %d\n",nh1->clusters_per_index_record,nh2->clusters_per_index_record);
return 0;
}
-
-
diff --git a/src/ntfs_udl.c b/src/ntfs_udl.c
index d96867f..e7c1770 100644
--- a/src/ntfs_udl.c
+++ b/src/ntfs_udl.c
@@ -215,7 +215,7 @@ static void free_file(struct ufile *file)
* Return: @rec's filename, either same name space as @name or lowest space.
* NULL if can't determine parenthood or on error.
*/
-static FILE_NAME_ATTR* verify_parent(struct filename* name, MFT_RECORD* rec)
+static FILE_NAME_ATTR* verify_parent(const struct filename* name, MFT_RECORD* rec)
{
ATTR_RECORD *attr30;
FILE_NAME_ATTR *filename_attr = NULL, *lowest_space_name = NULL;
@@ -450,7 +450,7 @@ static int get_filenames(struct ufile *file, ntfs_volume* vol)
* Return: n The number of $FILENAME attributes found
* -1 Error
*/
-static int get_data(struct ufile *file, ntfs_volume *vol)
+static int get_data(struct ufile *file, const ntfs_volume *vol)
{
ATTR_RECORD *rec;
ntfs_attr_search_ctx *ctx;
@@ -1222,7 +1222,7 @@ static struct td_list_head *ntfs_prev_non_deleted(struct td_list_head *current_f
return current_file;
}
-static void ntfs_undelete_menu_ncurses(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, file_info_t *dir_list)
+static void ntfs_undelete_menu_ncurses(const disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, file_info_t *dir_list)
{
struct ntfs_dir_struct *ls=(struct ntfs_dir_struct *)dir_data->private_dir_data;
WINDOW *window=(WINDOW*)dir_data->display;
@@ -1597,8 +1597,8 @@ static void ntfs_undelete_cli(dir_data_t *dir_data, file_info_t *dir_list)
{
unsigned int file_ok=0;
unsigned int file_bad=0;
- struct td_list_head *file_walker = NULL;
- struct ntfs_dir_struct *ls=(struct ntfs_dir_struct *)dir_data->private_dir_data;
+ const struct td_list_head *file_walker = NULL;
+ const struct ntfs_dir_struct *ls=(const struct ntfs_dir_struct *)dir_data->private_dir_data;
char *dst_path;
dst_path=get_default_location();
dir_data->local_dir=dst_path;
diff --git a/src/partgpt.c b/src/partgpt.c
index 19cc8b0..89d51ba 100644
--- a/src/partgpt.c
+++ b/src/partgpt.c
@@ -344,7 +344,7 @@ static list_part_t *init_part_order_gpt(const disk_t *disk_car, list_part_t *lis
return list_part;
}
-list_part_t *add_partition_gpt_cli(disk_t *disk_car,list_part_t *list_part, char **current_cmd)
+list_part_t *add_partition_gpt_cli(const disk_t *disk_car, list_part_t *list_part, char **current_cmd)
{
partition_t *new_partition;
assert(current_cmd!=NULL);
diff --git a/src/partgpt.h b/src/partgpt.h
index 7bbcc61..c3994c6 100644
--- a/src/partgpt.h
+++ b/src/partgpt.h
@@ -62,7 +62,7 @@ struct systypes_gtp {
const char *name;
};
-list_part_t *add_partition_gpt_cli(disk_t *disk_car,list_part_t *list_part, char **current_cmd);
+list_part_t *add_partition_gpt_cli(const disk_t *disk_car,list_part_t *list_part, char **current_cmd);
int write_part_gpt(disk_t *disk_car, const list_part_t *list_part, const int ro, const int verbose);
#ifdef __cplusplus
diff --git a/src/parthumax.c b/src/parthumax.c
index 86b3cd4..ded1c38 100644
--- a/src/parthumax.c
+++ b/src/parthumax.c
@@ -183,7 +183,7 @@ static list_part_t *init_part_order_humax(const disk_t *disk_car, list_part_t *l
return list_part;
}
-list_part_t *add_partition_humax_cli(disk_t *disk_car,list_part_t *list_part, char **current_cmd)
+list_part_t *add_partition_humax_cli(const disk_t *disk_car,list_part_t *list_part, char **current_cmd)
{
CHS_t start,end;
partition_t *new_partition=partition_new(&arch_humax);
diff --git a/src/parthumax.h b/src/parthumax.h
index c186fec..c6fcddf 100644
--- a/src/parthumax.h
+++ b/src/parthumax.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-list_part_t *add_partition_humax_cli(disk_t *disk_car,list_part_t *list_part, char **current_cmd);
+list_part_t *add_partition_humax_cli(const disk_t *disk_car,list_part_t *list_part, char **current_cmd);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/parti386.c b/src/parti386.c
index 2c334b1..586eccd 100644
--- a/src/parti386.c
+++ b/src/parti386.c
@@ -91,7 +91,7 @@ static void log_dos_entry(const struct partition_dos*);
static int get_geometry_from_i386mbr(const unsigned char *buffer, const int verbose, CHSgeometry_t *geometry);
static list_part_t *get_ext_data_i386(disk_t *disk_car, list_part_t *list_part, const int verbose, const int saveheader);
static void test_MBR_data(list_part_t *list_part);
-static int test_MBR_over(disk_t *disk_car,list_part_t *list_part);
+static int test_MBR_over(const disk_t *disk_car,list_part_t *list_part);
static int write_mbr_i386(disk_t *disk_car, const list_part_t *list_part, const int ro, const int verbose);
static int write_all_log_i386(disk_t *disk_car, const list_part_t *list_part, const int ro , const int verbose);
static int diff(const unsigned char buffer[DEFAULT_SECTOR_SIZE], const unsigned char buffer_org[DEFAULT_SECTOR_SIZE]);
@@ -651,7 +651,7 @@ int recover_i386_logical(disk_t *disk, const unsigned char *buffer, partition_t
return 0;
}
-static int test_MBR_over(disk_t *disk_car,list_part_t *list_part)
+static int test_MBR_over(const disk_t *disk_car,list_part_t *list_part)
{/* Test if partitions overlap */
int res=0;
list_part_t *element;
diff --git a/src/partsun.c b/src/partsun.c
index 113cbe6..2d7d89a 100644
--- a/src/partsun.c
+++ b/src/partsun.c
@@ -216,7 +216,7 @@ static list_part_t *init_part_order_sun(const disk_t *disk_car, list_part_t *lis
return list_part;
}
-list_part_t *add_partition_sun_cli(disk_t *disk_car,list_part_t *list_part, char **current_cmd)
+list_part_t *add_partition_sun_cli(const disk_t *disk_car,list_part_t *list_part, char **current_cmd)
{
CHS_t start,end;
partition_t *new_partition;
diff --git a/src/partsun.h b/src/partsun.h
index 47183b1..b25ba66 100644
--- a/src/partsun.h
+++ b/src/partsun.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-list_part_t *add_partition_sun_cli(disk_t *disk_car,list_part_t *list_part, char **current_cmd);
+list_part_t *add_partition_sun_cli(const disk_t *disk_car,list_part_t *list_part, char **current_cmd);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/partxbox.c b/src/partxbox.c
index 4cd1817..6efa3a6 100644
--- a/src/partxbox.c
+++ b/src/partxbox.c
@@ -145,7 +145,7 @@ static list_part_t *init_part_order_xbox(const disk_t *disk_car, list_part_t *li
return list_part;
}
-list_part_t *add_partition_xbox_cli(disk_t *disk_car,list_part_t *list_part, char **current_cmd)
+list_part_t *add_partition_xbox_cli(const disk_t *disk_car,list_part_t *list_part, char **current_cmd)
{
partition_t *new_partition=partition_new(&arch_xbox);
assert(current_cmd!=NULL);
diff --git a/src/partxbox.h b/src/partxbox.h
index 0ae6570..1db6f1e 100644
--- a/src/partxbox.h
+++ b/src/partxbox.h
@@ -31,7 +31,7 @@ struct xbox_partition
uint32_t bootnbr;
} __attribute__ ((gcc_struct, __packed__));
-list_part_t *add_partition_xbox_cli(disk_t *disk_car,list_part_t *list_part, char **current_cmd);
+list_part_t *add_partition_xbox_cli(const disk_t *disk_car,list_part_t *list_part, char **current_cmd);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/phbf.c b/src/phbf.c
index f5e1103..0c7a916 100644
--- a/src/phbf.c
+++ b/src/phbf.c
@@ -83,7 +83,7 @@ typedef enum { BF_OK=0, BF_STOP=1, BF_EACCES=2, BF_ENOSPC=3, BF_FRAG_FOUND=4, BF
static pstatus_t photorec_bf_aux(struct ph_param *params, file_recovery_t *file_recovery, alloc_data_t *list_search_space, const int phase);
static bf_status_t photorec_bf_frag(struct ph_param *params, file_recovery_t *file_recovery, alloc_data_t *list_search_space, alloc_data_t *start_search_space, const int phase, alloc_data_t **current_search_space, uint64_t *offset, unsigned char *buffer, unsigned char *block_buffer, const unsigned int frag);
-static inline void file_recovery_cpy(file_recovery_t *dst, file_recovery_t *src)
+static inline void file_recovery_cpy(file_recovery_t *dst, const file_recovery_t *src)
{
memcpy(dst, src, sizeof(*dst));
dst->location.list.prev=&dst->location.list;
diff --git a/src/phbs.c b/src/phbs.c
index dbc63d5..1962d09 100644
--- a/src/phbs.c
+++ b/src/phbs.c
@@ -58,7 +58,7 @@ extern const file_hint_t file_hint_tar;
extern file_check_list_t file_check_list;
extern int need_to_stop;
-static inline void file_recovery_cpy(file_recovery_t *dst, file_recovery_t *src)
+static inline void file_recovery_cpy(file_recovery_t *dst, const file_recovery_t *src)
{
memcpy(dst, src, sizeof(*dst));
dst->location.list.prev=&dst->location.list;
diff --git a/src/photorec.c b/src/photorec.c
index bc0cb95..b946d9b 100644
--- a/src/photorec.c
+++ b/src/photorec.c
@@ -290,7 +290,7 @@ unsigned int photorec_mkdir(const char *recup_dir, const unsigned int initial_di
return dir_num;
}
-int get_prev_file_header(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset)
+int get_prev_file_header(const alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset)
{
int nbr;
alloc_data_t *file_space=*current_search_space;
@@ -313,7 +313,7 @@ int get_prev_file_header(alloc_data_t *list_search_space, alloc_data_t **current
return -1;
}
-void forget(alloc_data_t *list_search_space, alloc_data_t *current_search_space)
+void forget(const alloc_data_t *list_search_space, alloc_data_t *current_search_space)
{
struct td_list_head *search_walker = NULL;
struct td_list_head *prev= NULL;
@@ -938,6 +938,8 @@ static inline void file_block_remove_from_sp(alloc_data_t *list_search_space, al
}
}
log_critical("file_block_remove_from_sp(list_search_space, alloc_data_t **new_current_search_space, uint64_t *offset, const unsigned int blocksize) failed\n");
+ log_flush();
+ exit(1);
}
static inline void file_block_add_to_file(alloc_list_t *list, const uint64_t offset, const uint64_t blocksize, const unsigned int data)
diff --git a/src/photorec.h b/src/photorec.h
index a6ab7ed..07bb345 100644
--- a/src/photorec.h
+++ b/src/photorec.h
@@ -64,7 +64,7 @@ struct ph_param
uint64_t offset;
};
-int get_prev_file_header(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset);
+int get_prev_file_header(const alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset);
int file_finish_bf(file_recovery_t *file_recovery, struct ph_param *params,
alloc_data_t *list_search_space);
void file_recovery_aborted(file_recovery_t *file_recovery, struct ph_param *params, alloc_data_t *list_search_space);
@@ -74,7 +74,7 @@ void update_stats(file_stat_t *file_stats, alloc_data_t *list_search_space);
partition_t *new_whole_disk(const disk_t *disk_car);
unsigned int find_blocksize(alloc_data_t *list_file, const unsigned int default_blocksize, uint64_t *offset);
void update_blocksize(const unsigned int blocksize, alloc_data_t *list_search_space, const uint64_t offset);
-void forget(alloc_data_t *list_search_space, alloc_data_t *current_search_space);
+void forget(const alloc_data_t *list_search_space, alloc_data_t *current_search_space);
void init_search_space(alloc_data_t *list_search_space, const disk_t *disk_car, const partition_t *partition);
unsigned int remove_used_space(disk_t *disk_car, const partition_t *partition, alloc_data_t *list_search_space);
void free_list_search_space(alloc_data_t *list_search_space);
diff --git a/src/pnext.h b/src/pnext.h
index 20088d6..856ed9f 100644
--- a/src/pnext.h
+++ b/src/pnext.h
@@ -25,7 +25,7 @@ static
#ifndef DEBUG_GET_NEXT_SECTOR
inline
#endif
-void get_next_header(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset)
+void get_next_header(const alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset)
{
#ifdef DEBUG_GET_NEXT_SECTOR
log_trace(" get_next_header %llu (%llu-%llu)\n",
@@ -42,7 +42,7 @@ static
#ifndef DEBUG_GET_NEXT_SECTOR
inline
#endif
-void get_next_sector(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const unsigned int blocksize)
+void get_next_sector(const alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const unsigned int blocksize)
{
#ifdef DEBUG_GET_NEXT_SECTOR
log_debug(" get_next_sector %llu (%llu-%llu)\n",
@@ -72,14 +72,14 @@ void get_next_sector(alloc_data_t *list_search_space, alloc_data_t **current_sea
get_next_header(list_search_space, current_search_space, offset);
}
-static inline void get_prev_header(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const unsigned int blocksize)
+static inline void get_prev_header(const alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const unsigned int blocksize)
{
if((*current_search_space) != list_search_space)
*current_search_space=td_list_entry((*current_search_space)->list.prev, alloc_data_t, list);
*offset=(*current_search_space)->end + 1 - blocksize;
}
-static inline void get_prev_sector(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const unsigned int blocksize)
+static inline void get_prev_sector(const alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const unsigned int blocksize)
{
if((*current_search_space) == list_search_space)
{
diff --git a/src/psearch.h b/src/psearch.h
index 1f6c860..fb4bf92 100644
--- a/src/psearch.h
+++ b/src/psearch.h
@@ -24,7 +24,7 @@ static inline alloc_data_t *file_add_data(alloc_data_t *data, const uint64_t off
}
}
-static inline void file_recovery_cpy(file_recovery_t *dst, file_recovery_t *src)
+static inline void file_recovery_cpy(file_recovery_t *dst, const file_recovery_t *src)
{
memcpy(dst, src, sizeof(*dst));
dst->location.list.prev=&dst->location.list;
diff --git a/src/rfs.c b/src/rfs.c
index aae923e..8026248 100644
--- a/src/rfs.c
+++ b/src/rfs.c
@@ -130,7 +130,7 @@ static int test_rfs4(const disk_t *disk_car, const struct reiser4_master_sb *sb,
return 0;
}
-int recover_rfs(disk_t *disk_car, const struct reiserfs_super_block *sb,partition_t *partition,const int verbose, const int dump_ind)
+int recover_rfs(const disk_t *disk_car, const struct reiserfs_super_block *sb,partition_t *partition,const int verbose, const int dump_ind)
{
const struct reiser4_master_sb *sb4=(const struct reiser4_master_sb *)sb;
if(test_rfs(disk_car, sb, partition, verbose)==0)
diff --git a/src/rfs.h b/src/rfs.h
index 0a52567..4cbedab 100644
--- a/src/rfs.h
+++ b/src/rfs.h
@@ -106,7 +106,7 @@ struct format40_super {
} __attribute__((packed));
int check_rfs(disk_t *disk_car,partition_t *partition,const int verbose);
-int recover_rfs(disk_t *disk_car, const struct reiserfs_super_block *sb,partition_t *partition,const int verbose, const int dump_ind);
+int recover_rfs(const disk_t *disk_car, const struct reiserfs_super_block *sb,partition_t *partition,const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/savehdr.c b/src/savehdr.c
index 11aa25a..601eeee 100644
--- a/src/savehdr.c
+++ b/src/savehdr.c
@@ -44,7 +44,7 @@
#include "log.h"
#define BACKUP_MAXSIZE 5120
-int save_header(disk_t *disk_car,partition_t *partition, const int verbose)
+int save_header(disk_t *disk_car, const partition_t *partition, const int verbose)
{
unsigned char *buffer;
FILE *f_backup;
@@ -202,9 +202,9 @@ backup_disk_t *partition_load(const disk_t *disk_car, const int verbose)
return list_backup;
}
-int partition_save(disk_t *disk_car, list_part_t *list_part, const int verbose)
+int partition_save(disk_t *disk_car, const list_part_t *list_part, const int verbose)
{
- list_part_t *parts;
+ const list_part_t *parts;
FILE *f_backup;
if(verbose>0)
{
diff --git a/src/savehdr.h b/src/savehdr.h
index 9b13a34..75f75af 100644
--- a/src/savehdr.h
+++ b/src/savehdr.h
@@ -32,8 +32,8 @@ typedef struct
list_part_t *list_part;
} backup_disk_t;
-int save_header(disk_t *disk_car,partition_t *partition, const int verbose);
-int partition_save(disk_t *disk_car, list_part_t *list_part, const int verbose);
+int save_header(disk_t *disk_car, const partition_t *partition, const int verbose);
+int partition_save(disk_t *disk_car, const list_part_t *list_part, const int verbose);
backup_disk_t *partition_load(const disk_t *disk_car, const int verbose);
#ifdef __cplusplus
diff --git a/src/sun.c b/src/sun.c
index fd81e62..88e1b48 100644
--- a/src/sun.c
+++ b/src/sun.c
@@ -96,7 +96,7 @@ static int test_sun_i386(const disk_t *disk_car, const sun_partition_i386 *sunla
return 0;
}
-int recover_sun_i386(disk_t *disk_car, const sun_partition_i386 *sunlabel, partition_t *partition,const int verbose, const int dump_ind)
+int recover_sun_i386(const disk_t *disk_car, const sun_partition_i386 *sunlabel, partition_t *partition,const int verbose, const int dump_ind)
{
if(test_sun_i386(disk_car, sunlabel, partition, verbose)!=0)
return 1;
diff --git a/src/sun.h b/src/sun.h
index 92a0c03..b747b46 100644
--- a/src/sun.h
+++ b/src/sun.h
@@ -77,7 +77,7 @@ typedef struct struct_sun_partition_i386 sun_partition_i386;
#define SUN_LABEL_MAGIC 0xDABE
#define SUN_LABEL_MAGIC_START 0x600DDEEE
-int recover_sun_i386(disk_t *disk_car, const sun_partition_i386 *sunlabel, partition_t *partition,const int verbose, const int dump_ind);
+int recover_sun_i386(const disk_t *disk_car, const sun_partition_i386 *sunlabel, partition_t *partition,const int verbose, const int dump_ind);
int check_sun_i386(disk_t *disk_car,partition_t *partition,const int verbose);
#ifdef __cplusplus
diff --git a/src/sysv.c b/src/sysv.c
index 41864e6..e8ecdb2 100644
--- a/src/sysv.c
+++ b/src/sysv.c
@@ -91,7 +91,7 @@ static int test_sysv4(const disk_t *disk_car, const struct sysv4_super_block *sb
return 0;
}
-int recover_sysv(disk_t *disk_car, const struct sysv4_super_block *sbd, partition_t *partition,const int verbose, const int dump_ind)
+int recover_sysv(const disk_t *disk_car, const struct sysv4_super_block *sbd, partition_t *partition,const int verbose, const int dump_ind)
{
if(test_sysv4(disk_car, sbd,partition, verbose)!=0)
return 1;
diff --git a/src/sysv.h b/src/sysv.h
index 52b10af..7272251 100644
--- a/src/sysv.h
+++ b/src/sysv.h
@@ -201,7 +201,7 @@ struct coh_super_block {
};
int check_sysv(disk_t *disk_car,partition_t *partition,const int verbose);
-int recover_sysv(disk_t *disk_car, const struct sysv4_super_block *sbd, partition_t *partition,const int verbose, const int dump_ind);
+int recover_sysv(const disk_t *disk_car, const struct sysv4_super_block *sbd, partition_t *partition,const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/texfat.c b/src/texfat.c
index f626117..c1a673c 100644
--- a/src/texfat.c
+++ b/src/texfat.c
@@ -93,7 +93,7 @@ static int exFAT_boot_sector_command(char **current_cmd, const char *options)
return 0;
}
-static const char *exFAT_boot_sector_rescan(disk_t *disk, partition_t *partition, unsigned char *buffer_bs, unsigned char *buffer_backup_bs)
+static const char *exFAT_boot_sector_rescan(disk_t *disk, const partition_t *partition, unsigned char *buffer_bs, unsigned char *buffer_backup_bs)
{
const int size_bs=12 * disk->sector_size;
int opt_B=0;
diff --git a/src/thfs.c b/src/thfs.c
index c3bada2..b7496ba 100644
--- a/src/thfs.c
+++ b/src/thfs.c
@@ -94,7 +94,7 @@ static int HFS_HFSP_boot_sector_command(char **current_cmd, const char *options)
return 0;
}
-static const char *HFS_HFSP_boot_sector_rescan(disk_t *disk_car, partition_t *partition, unsigned char *buffer_bs, unsigned char *buffer_backup_bs, const int verbose)
+static const char *HFS_HFSP_boot_sector_rescan(disk_t *disk_car, const partition_t *partition, unsigned char *buffer_bs, unsigned char *buffer_backup_bs, const int verbose)
{
int opt_B=0;
int opt_O=0;
diff --git a/src/tntfs.c b/src/tntfs.c
index a1ae87d..11eda73 100644
--- a/src/tntfs.c
+++ b/src/tntfs.c
@@ -115,7 +115,7 @@ static int is_no_confirm_command(char **current_cmd)
return 0;
}
-static const char *ntfs_boot_sector_scan(disk_t *disk, partition_t *partition, unsigned char *buffer_bs, unsigned char *buffer_backup_bs, unsigned int *menu, const int verbose, const unsigned int expert)
+static const char *ntfs_boot_sector_scan(disk_t *disk, const partition_t *partition, unsigned char *buffer_bs, unsigned char *buffer_backup_bs, unsigned int *menu, const int verbose, const unsigned int expert)
{
int identical_sectors;
int opt_B=0;
diff --git a/src/ufs.c b/src/ufs.c
index ebcf448..c033eb4 100644
--- a/src/ufs.c
+++ b/src/ufs.c
@@ -94,7 +94,7 @@ static int test_ufs(const disk_t *disk_car, const struct ufs_super_block *sb, co
return 1;
}
-int recover_ufs(disk_t *disk_car, const struct ufs_super_block *sb, partition_t *partition,const int verbose, const int dump_ind)
+int recover_ufs(const disk_t *disk_car, const struct ufs_super_block *sb, partition_t *partition,const int verbose, const int dump_ind)
{
if(test_ufs(disk_car, sb, partition, verbose)!=0)
return 1;
diff --git a/src/ufs.h b/src/ufs.h
index bbdf391..3b3bf47 100644
--- a/src/ufs.h
+++ b/src/ufs.h
@@ -471,7 +471,7 @@ struct ufs_super_block {
int check_ufs(disk_t *disk_car,partition_t *partition,const int verbose);
-int recover_ufs(disk_t *disk_car, const struct ufs_super_block *sb, partition_t *partition,const int verbose, const int dump_ind);
+int recover_ufs(const disk_t *disk_car, const struct ufs_super_block *sb, partition_t *partition,const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/vmfs.c b/src/vmfs.c
index 73d1488..165ff07 100644
--- a/src/vmfs.c
+++ b/src/vmfs.c
@@ -35,9 +35,27 @@
#include "log.h"
#include "vmfs.h"
-static int test_VMFS(disk_t *disk, const struct vmfs_volume *sb, const partition_t *partition, const int dump_ind);
-static void set_VMFS_info(const struct vmfs_volume *sb, partition_t *partition);
+static void set_VMFS_info(const struct vmfs_volume *sb, partition_t *partition)
+{
+ partition->upart_type=UP_VMFS;
+ sprintf(partition->info,"VMFS %lu", (long unsigned)le32(sb->version));
+}
+static int test_VMFS(const disk_t *disk, const struct vmfs_volume *sb, const partition_t *partition, const int dump_ind)
+{
+ if(le32(sb->magic)!=0xc001d00d || le32(sb->version)>20)
+ return 1;
+ if(dump_ind!=0)
+ {
+ if(partition!=NULL && disk!=NULL)
+ log_info("\nVMFS magic value at %u/%u/%u\n",
+ offset2cylinder(disk,partition->part_offset),
+ offset2head(disk,partition->part_offset),
+ offset2sector(disk,partition->part_offset));
+ dump_log(sb,DEFAULT_SECTOR_SIZE);
+ }
+ return 0;
+}
int check_VMFS(disk_t *disk,partition_t *partition)
{
unsigned char *buffer=(unsigned char*)MALLOC(2*DEFAULT_SECTOR_SIZE);
@@ -56,13 +74,7 @@ int check_VMFS(disk_t *disk,partition_t *partition)
return 0;
}
-static void set_VMFS_info(const struct vmfs_volume *sb, partition_t *partition)
-{
- partition->upart_type=UP_VMFS;
- sprintf(partition->info,"VMFS %lu", (long unsigned)le32(sb->version));
-}
-
-int recover_VMFS(disk_t *disk, const struct vmfs_volume *sb, partition_t *partition, const int verbose, const int dump_ind)
+int recover_VMFS(const disk_t *disk, const struct vmfs_volume *sb, partition_t *partition, const int verbose, const int dump_ind)
{
const struct vmfs_lvm* lvm=(const struct vmfs_lvm*)(((const char *)sb)+0x200);
if(test_VMFS(disk, sb, partition, dump_ind)!=0)
@@ -81,19 +93,3 @@ int recover_VMFS(disk_t *disk, const struct vmfs_volume *sb, partition_t *partit
}
return 0;
}
-
-static int test_VMFS(disk_t *disk, const struct vmfs_volume *sb, const partition_t *partition, const int dump_ind)
-{
- if(le32(sb->magic)!=0xc001d00d || le32(sb->version)>20)
- return 1;
- if(dump_ind!=0)
- {
- if(partition!=NULL && disk!=NULL)
- log_info("\nVMFS magic value at %u/%u/%u\n",
- offset2cylinder(disk,partition->part_offset),
- offset2head(disk,partition->part_offset),
- offset2sector(disk,partition->part_offset));
- dump_log(sb,DEFAULT_SECTOR_SIZE);
- }
- return 0;
-}
diff --git a/src/vmfs.h b/src/vmfs.h
index 497c29c..46024a6 100644
--- a/src/vmfs.h
+++ b/src/vmfs.h
@@ -42,7 +42,7 @@ struct vmfs_lvm
} __attribute__ ((gcc_struct, __packed__));
int check_VMFS(disk_t *disk,partition_t *partition);
-int recover_VMFS(disk_t *disk, const struct vmfs_volume *sb, partition_t *partition, const int verbose, const int dump_ind);
+int recover_VMFS(const disk_t *disk, const struct vmfs_volume *sb, partition_t *partition, const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif
diff --git a/src/wbfs.c b/src/wbfs.c
index 046cc5f..f9051e8 100644
--- a/src/wbfs.c
+++ b/src/wbfs.c
@@ -35,7 +35,21 @@
#include "log.h"
#include "wbfs.h"
-static int test_WBFS(disk_t *disk, const struct wbfs_head *sb, const partition_t *partition, const int dump_ind);
+static int test_WBFS(const disk_t *disk, const struct wbfs_head *sb, const partition_t *partition, const int dump_ind)
+{
+ if(be32(sb->magic)!=WBFS_MAGIC)
+ return 1;
+ if(dump_ind!=0)
+ {
+ if(partition!=NULL && disk!=NULL)
+ log_info("\nWBFS magic value at %u/%u/%u\n",
+ offset2cylinder(disk,partition->part_offset),
+ offset2head(disk,partition->part_offset),
+ offset2sector(disk,partition->part_offset));
+ dump_log(sb,DEFAULT_SECTOR_SIZE);
+ }
+ return 0;
+}
static void set_WBFS_info(partition_t *partition)
{
@@ -61,7 +75,7 @@ int check_WBFS(disk_t *disk,partition_t *partition)
return 0;
}
-int recover_WBFS(disk_t *disk, const struct wbfs_head *sb, partition_t *partition, const int verbose, const int dump_ind)
+int recover_WBFS(const disk_t *disk, const struct wbfs_head *sb, partition_t *partition, const int verbose, const int dump_ind)
{
if(test_WBFS(disk, sb, partition, dump_ind)!=0)
return 1;
@@ -79,19 +93,3 @@ int recover_WBFS(disk_t *disk, const struct wbfs_head *sb, partition_t *partitio
}
return 0;
}
-
-static int test_WBFS(disk_t *disk, const struct wbfs_head *sb, const partition_t *partition, const int dump_ind)
-{
- if(be32(sb->magic)!=WBFS_MAGIC)
- return 1;
- if(dump_ind!=0)
- {
- if(partition!=NULL && disk!=NULL)
- log_info("\nWBFS magic value at %u/%u/%u\n",
- offset2cylinder(disk,partition->part_offset),
- offset2head(disk,partition->part_offset),
- offset2sector(disk,partition->part_offset));
- dump_log(sb,DEFAULT_SECTOR_SIZE);
- }
- return 0;
-}
diff --git a/src/wbfs.h b/src/wbfs.h
index fdfbd3f..1f784e1 100644
--- a/src/wbfs.h
+++ b/src/wbfs.h
@@ -39,7 +39,7 @@ struct wbfs_head
} __attribute__ ((gcc_struct, __packed__));
int check_WBFS(disk_t *disk,partition_t *partition);
-int recover_WBFS(disk_t *disk, const struct wbfs_head *sb, partition_t *partition, const int verbose, const int dump_ind);
+int recover_WBFS(const disk_t *disk, const struct wbfs_head *sb, partition_t *partition, const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif
diff --git a/src/xfs.c b/src/xfs.c
index 07db3f9..9d17ded 100644
--- a/src/xfs.c
+++ b/src/xfs.c
@@ -38,25 +38,44 @@
#include "log.h"
#include "guid_cpy.h"
-static void set_xfs_info(const struct xfs_sb *sb, partition_t *partition);
-static int test_xfs(const disk_t *disk_car, const struct xfs_sb *sb, const partition_t *partition, const int verbose);
-
-int check_xfs(disk_t *disk_car,partition_t *partition,const int verbose)
+static void set_xfs_info(const struct xfs_sb *sb, partition_t *partition)
{
- unsigned char *buffer=(unsigned char*)MALLOC(XFS_SUPERBLOCK_SIZE);
- if(disk_car->pread(disk_car, buffer, XFS_SUPERBLOCK_SIZE, partition->part_offset) != XFS_SUPERBLOCK_SIZE)
- {
- free(buffer);
- return 1;
- }
- if(test_xfs(disk_car, (struct xfs_sb*)buffer, partition, verbose)!=0)
+ partition->blocksize=be32(sb->sb_blocksize);
+ partition->fsname[0]='\0';
+ partition->info[0]='\0';
+ switch(be16(sb->sb_versionnum) & XFS_SB_VERSION_NUMBITS)
{
- free(buffer);
- return 1;
+ case XFS_SB_VERSION_1:
+ partition->upart_type = UP_XFS;
+ snprintf(partition->info, sizeof(partition->info),
+ "XFS <=6.1, blocksize=%u", partition->blocksize);
+ break;
+ case XFS_SB_VERSION_2:
+ partition->upart_type = UP_XFS2;
+ snprintf(partition->info, sizeof(partition->info),
+ "XFS 6.2 - attributes, blocksize=%u", partition->blocksize);
+ break;
+ case XFS_SB_VERSION_3:
+ partition->upart_type = UP_XFS3;
+ snprintf(partition->info, sizeof(partition->info),
+ "XFS 6.2 - new inode version, blocksize=%u", partition->blocksize);
+ break;
+ case XFS_SB_VERSION_4:
+ partition->upart_type = UP_XFS4;
+ snprintf(partition->info, sizeof(partition->info),
+ "XFS 6.2+ - bitmap version, blocksize=%u", partition->blocksize);
+ break;
+ case XFS_SB_VERSION_5:
+ partition->upart_type = UP_XFS5;
+ snprintf(partition->info, sizeof(partition->info),
+ "XFS CRC enabled, blocksize=%u", partition->blocksize);
+ break;
+ default:
+ snprintf(partition->info, sizeof(partition->info),
+ "XFS unknown version %u\n", be16(sb->sb_versionnum)& XFS_SB_VERSION_NUMBITS);
+ break;
}
- set_xfs_info((struct xfs_sb*)buffer, partition);
- free(buffer);
- return 0;
+ set_part_name(partition,sb->sb_fname,12);
}
static int test_xfs(const disk_t *disk_car, const struct xfs_sb *sb, const partition_t *partition, const int verbose)
@@ -83,7 +102,26 @@ static int test_xfs(const disk_t *disk_car, const struct xfs_sb *sb, const parti
return 0;
}
-int recover_xfs(disk_t *disk_car, const struct xfs_sb *sb,partition_t *partition,const int verbose, const int dump_ind)
+
+int check_xfs(disk_t *disk_car,partition_t *partition,const int verbose)
+{
+ unsigned char *buffer=(unsigned char*)MALLOC(XFS_SUPERBLOCK_SIZE);
+ if(disk_car->pread(disk_car, buffer, XFS_SUPERBLOCK_SIZE, partition->part_offset) != XFS_SUPERBLOCK_SIZE)
+ {
+ free(buffer);
+ return 1;
+ }
+ if(test_xfs(disk_car, (struct xfs_sb*)buffer, partition, verbose)!=0)
+ {
+ free(buffer);
+ return 1;
+ }
+ set_xfs_info((struct xfs_sb*)buffer, partition);
+ free(buffer);
+ return 0;
+}
+
+int recover_xfs(const disk_t *disk_car, const struct xfs_sb *sb, partition_t *partition, const int verbose, const int dump_ind)
{
if(test_xfs(disk_car, sb, partition, verbose)!=0)
return 1;
@@ -104,43 +142,3 @@ int recover_xfs(disk_t *disk_car, const struct xfs_sb *sb,partition_t *partition
guid_cpy(&partition->part_uuid, (const efi_guid_t *)&sb->sb_uuid);
return 0;
}
-
-static void set_xfs_info(const struct xfs_sb *sb, partition_t *partition)
-{
- partition->blocksize=be32(sb->sb_blocksize);
- partition->fsname[0]='\0';
- partition->info[0]='\0';
- switch(be16(sb->sb_versionnum) & XFS_SB_VERSION_NUMBITS)
- {
- case XFS_SB_VERSION_1:
- partition->upart_type = UP_XFS;
- snprintf(partition->info, sizeof(partition->info),
- "XFS <=6.1, blocksize=%u", partition->blocksize);
- break;
- case XFS_SB_VERSION_2:
- partition->upart_type = UP_XFS2;
- snprintf(partition->info, sizeof(partition->info),
- "XFS 6.2 - attributes, blocksize=%u", partition->blocksize);
- break;
- case XFS_SB_VERSION_3:
- partition->upart_type = UP_XFS3;
- snprintf(partition->info, sizeof(partition->info),
- "XFS 6.2 - new inode version, blocksize=%u", partition->blocksize);
- break;
- case XFS_SB_VERSION_4:
- partition->upart_type = UP_XFS4;
- snprintf(partition->info, sizeof(partition->info),
- "XFS 6.2+ - bitmap version, blocksize=%u", partition->blocksize);
- break;
- case XFS_SB_VERSION_5:
- partition->upart_type = UP_XFS5;
- snprintf(partition->info, sizeof(partition->info),
- "XFS CRC enabled, blocksize=%u", partition->blocksize);
- break;
- default:
- snprintf(partition->info, sizeof(partition->info),
- "XFS unknown version %u\n", be16(sb->sb_versionnum)& XFS_SB_VERSION_NUMBITS);
- break;
- }
- set_part_name(partition,sb->sb_fname,12);
-}
diff --git a/src/xfs.h b/src/xfs.h
index 2a6b511..25838db 100644
--- a/src/xfs.h
+++ b/src/xfs.h
@@ -108,7 +108,7 @@ struct xfs_sb
} __attribute__ ((gcc_struct, __packed__));
int check_xfs(disk_t *disk_car,partition_t *partition,const int verbose);
-int recover_xfs(disk_t *disk_car, const struct xfs_sb *sb,partition_t *partition,const int verbose, const int dump_ind);
+int recover_xfs(const disk_t *disk_car, const struct xfs_sb *sb, partition_t *partition, const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/zfs.c b/src/zfs.c
index 94280ca..3144dfb 100644
--- a/src/zfs.c
+++ b/src/zfs.c
@@ -36,8 +36,27 @@
#include "log.h"
#include "guid_cpy.h"
-static int test_ZFS(disk_t *disk, const struct vdev_boot_header *sb, const partition_t *partition, const int dump_ind);
-static void set_ZFS_info(const struct vdev_boot_header *sb, partition_t *partition);
+static void set_ZFS_info(const struct vdev_boot_header *sb, partition_t *partition)
+{
+ partition->upart_type=UP_ZFS;
+ sprintf(partition->info,"ZFS %lu (Data size unknown)", (long unsigned)le64(sb->vb_version));
+}
+
+static int test_ZFS(const disk_t *disk, const struct vdev_boot_header *sb, const partition_t *partition, const int dump_ind)
+{
+ if(le64(sb->vb_magic)!=VDEV_BOOT_MAGIC)
+ return 1;
+ if(dump_ind!=0)
+ {
+ if(partition!=NULL && disk!=NULL)
+ log_info("\nZFS magic value at %u/%u/%u\n",
+ offset2cylinder(disk,partition->part_offset),
+ offset2head(disk,partition->part_offset),
+ offset2sector(disk,partition->part_offset));
+ dump_log(sb,DEFAULT_SECTOR_SIZE);
+ }
+ return 0;
+}
int check_ZFS(disk_t *disk,partition_t *partition)
{
@@ -57,13 +76,7 @@ int check_ZFS(disk_t *disk,partition_t *partition)
return 0;
}
-static void set_ZFS_info(const struct vdev_boot_header *sb, partition_t *partition)
-{
- partition->upart_type=UP_ZFS;
- sprintf(partition->info,"ZFS %lu (Data size unknown)", (long unsigned)le64(sb->vb_version));
-}
-
-int recover_ZFS(disk_t *disk, const struct vdev_boot_header *sb,partition_t *partition,const int verbose, const int dump_ind)
+int recover_ZFS(const disk_t *disk, const struct vdev_boot_header *sb,partition_t *partition,const int verbose, const int dump_ind)
{
if(test_ZFS(disk, sb, partition, dump_ind)!=0)
return 1;
@@ -84,19 +97,3 @@ int recover_ZFS(disk_t *disk, const struct vdev_boot_header *sb,partition_t *par
}
return 0;
}
-
-static int test_ZFS(disk_t *disk, const struct vdev_boot_header *sb, const partition_t *partition, const int dump_ind)
-{
- if(le64(sb->vb_magic)!=VDEV_BOOT_MAGIC)
- return 1;
- if(dump_ind!=0)
- {
- if(partition!=NULL && disk!=NULL)
- log_info("\nZFS magic value at %u/%u/%u\n",
- offset2cylinder(disk,partition->part_offset),
- offset2head(disk,partition->part_offset),
- offset2sector(disk,partition->part_offset));
- dump_log(sb,DEFAULT_SECTOR_SIZE);
- }
- return 0;
-}
diff --git a/src/zfs.h b/src/zfs.h
index 8d242ea..b7f2b26 100644
--- a/src/zfs.h
+++ b/src/zfs.h
@@ -38,7 +38,7 @@ struct vdev_boot_header {
char vb_pad[VDEV_BOOT_HEADER_SIZE - 4 * sizeof (uint64_t)];
};
int check_ZFS(disk_t *disk,partition_t *partition);
-int recover_ZFS(disk_t *disk, const struct vdev_boot_header *ZFS_header,partition_t *partition,const int verbose, const int dump_ind);
+int recover_ZFS(const disk_t *disk, const struct vdev_boot_header *ZFS_header,partition_t *partition,const int verbose, const int dump_ind);
#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif