MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / HFS_HFSP_boot_sector_rescan

Function HFS_HFSP_boot_sector_rescan

src/thfs.c:97–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97static 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)
98{
99 int opt_B=0;
100 int opt_O=0;
101#ifdef HAVE_NCURSES
102 aff_copy(stdscr);
103 wmove(stdscr,4,0);
104 wprintw(stdscr,"%s",disk_car->description(disk_car));
105 mvwaddstr(stdscr,5,0,msg_PART_HEADER_LONG);
106 wmove(stdscr,6,0);
107 aff_part(stdscr,AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
108#endif
109 log_info("\nHFS_HFSP_boot_sector\n");
110 log_partition(disk_car,partition);
111 screen_buffer_add("Volume header\n");
112 if(disk_car->pread(disk_car, buffer_bs, HFSP_BOOT_SECTOR_SIZE, partition->part_offset + 0x400) != HFSP_BOOT_SECTOR_SIZE)
113 {
114 screen_buffer_add("Bad: can't read HFS/HFS+ volume header.\n");
115 memset(buffer_bs,0,HFSP_BOOT_SECTOR_SIZE);
116 }
117 else if(test_HFSP(disk_car,(const struct hfsp_vh*)buffer_bs,partition,verbose,0)==0)
118 {
119 screen_buffer_add("HFS+ OK\n");
120 opt_O=1;
121 }
122 else if(test_HFS(disk_car,(const hfs_mdb_t*)buffer_bs,partition,verbose,0)==0)
123 {
124 screen_buffer_add("HFS Ok\n");
125 opt_O=1;
126 }
127 else
128 screen_buffer_add("Bad\n");
129 screen_buffer_add("\nBackup volume header\n");
130 if(disk_car->pread(disk_car, buffer_backup_bs, HFSP_BOOT_SECTOR_SIZE, partition->part_offset + partition->part_size - 0x400) != HFSP_BOOT_SECTOR_SIZE)
131 {
132 screen_buffer_add("Bad: can't read HFS/HFS+ backup volume header.\n");
133 memset(buffer_backup_bs,0,HFSP_BOOT_SECTOR_SIZE);
134 }
135 else if(test_HFSP(disk_car,(const struct hfsp_vh*)buffer_backup_bs,partition,verbose,0)==0)
136 {
137 screen_buffer_add("HFS+ OK\n");
138 opt_B=1;
139 }
140 else if(test_HFS(disk_car,(const hfs_mdb_t*)buffer_backup_bs,partition,verbose,0)==0)
141 {
142 screen_buffer_add("HFS Ok\n");
143 opt_B=1;
144 }
145 else
146 screen_buffer_add("Bad\n");
147 screen_buffer_add("\n");
148 if(memcmp(buffer_bs,buffer_backup_bs,HFSP_BOOT_SECTOR_SIZE)==0)
149 {
150 screen_buffer_add("Sectors are identical.\n");
151 return "D";
152 }
153 else
154 {

Callers 1

HFS_HFSP_boot_sectorFunction · 0.85

Calls 6

aff_partFunction · 0.85
log_partitionFunction · 0.85
screen_buffer_addFunction · 0.85
test_HFSPFunction · 0.85
test_HFSFunction · 0.85
aff_copyFunction · 0.70

Tested by

no test coverage detected