| 164 | } |
| 165 | |
| 166 | int HFS_HFSP_boot_sector(disk_t *disk, partition_t *partition, const int verbose, char **current_cmd) |
| 167 | { |
| 168 | unsigned char *buffer_bs; |
| 169 | unsigned char *buffer_backup_bs; |
| 170 | const char *options; |
| 171 | int rescan=1; |
| 172 | #ifdef HAVE_NCURSES |
| 173 | const struct MenuItem menu_hfsp[]= |
| 174 | { |
| 175 | { 'P', "Previous",""}, |
| 176 | { 'N', "Next","" }, |
| 177 | { 'Q', "Quit","Return to Advanced menu"}, |
| 178 | { 'O', "Org. BS","Copy superblock over backup sector"}, |
| 179 | { 'B', "Backup BS","Copy backup superblock over superblock"}, |
| 180 | { 'D', "Dump","Dump superblock and backup superblock"}, |
| 181 | { 0, NULL, NULL } |
| 182 | }; |
| 183 | #endif |
| 184 | buffer_bs=(unsigned char*)MALLOC(HFSP_BOOT_SECTOR_SIZE); |
| 185 | buffer_backup_bs=(unsigned char*)MALLOC(HFSP_BOOT_SECTOR_SIZE); |
| 186 | |
| 187 | while(1) |
| 188 | { |
| 189 | #ifdef HAVE_NCURSES |
| 190 | unsigned int menu=0; |
| 191 | #endif |
| 192 | int command; |
| 193 | screen_buffer_reset(); |
| 194 | if(rescan==1) |
| 195 | { |
| 196 | options=HFS_HFSP_boot_sector_rescan(disk, partition, buffer_bs, buffer_backup_bs, verbose); |
| 197 | rescan=0; |
| 198 | } |
| 199 | screen_buffer_to_log(); |
| 200 | if(*current_cmd!=NULL) |
| 201 | { |
| 202 | command=HFS_HFSP_boot_sector_command(current_cmd, options); |
| 203 | } |
| 204 | else |
| 205 | { |
| 206 | log_flush(); |
| 207 | #ifdef HAVE_NCURSES |
| 208 | wredrawln(stdscr,0,getmaxy(stdscr)); |
| 209 | command=screen_buffer_display_ext(stdscr, options, menu_hfsp, &menu); |
| 210 | #else |
| 211 | command=0; |
| 212 | #endif |
| 213 | } |
| 214 | switch(command) |
| 215 | { |
| 216 | case 0: |
| 217 | free(buffer_bs); |
| 218 | free(buffer_backup_bs); |
| 219 | return 0; |
| 220 | case 'O': /* O : copy original superblock over backup boot */ |
| 221 | #ifdef HAVE_NCURSES |
| 222 | if(ask_confirmation("Copy original HFS/HFS+ volume header over backup, confirm ? (Y/N)")!=0) |
| 223 | #endif |
no test coverage detected