| 35 | #include "log.h" |
| 36 | |
| 37 | 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) |
| 38 | { |
| 39 | unsigned int i; |
| 40 | const uint16_t* cp; |
| 41 | uint16_t crc; |
| 42 | if(le32(bsd_header->d_magic) != DISKMAGIC || le32(bsd_header->d_magic2)!=DISKMAGIC) |
| 43 | return 0; |
| 44 | if(verbose) |
| 45 | log_info("\nBSD offset %lu, nbr_part %u, CHS=(%u,%u,%u) ", |
| 46 | (long unsigned)(partition->part_offset/disk_car->sector_size), |
| 47 | (unsigned int)le16(bsd_header->d_npartitions), |
| 48 | (unsigned int)le32(bsd_header->d_ncylinders), |
| 49 | (unsigned int)le32(bsd_header->d_ntracks), |
| 50 | (unsigned int)le32(bsd_header->d_nsectors)); |
| 51 | if(le16(bsd_header->d_npartitions) > max_partitions) |
| 52 | return 1; |
| 53 | crc=0; |
| 54 | for(cp=(const uint16_t*)bsd_header; |
| 55 | cp<(const uint16_t*)&bsd_header->d_partitions[le16(bsd_header->d_npartitions)];cp++) |
| 56 | crc^=*cp; |
| 57 | if(crc==0) |
| 58 | { |
| 59 | if(verbose>0) |
| 60 | { |
| 61 | log_info("CRC Ok\n"); |
| 62 | } |
| 63 | } |
| 64 | else |
| 65 | log_error("Bad CRC! CRC must be xor'd by %04X\n",crc); |
| 66 | for(i=0;i<le16(bsd_header->d_npartitions);i++) |
| 67 | { |
| 68 | if(bsd_header->d_partitions[i].p_fstype>0) |
| 69 | { |
| 70 | if(verbose>0) |
| 71 | { |
| 72 | /* UFS UFS2 SWAP */ |
| 73 | log_info("BSD %c: ", 'a'+i); |
| 74 | switch(bsd_header->d_partitions[i].p_fstype) |
| 75 | { |
| 76 | case TST_FS_SWAP: |
| 77 | log_info("swap"); |
| 78 | break; |
| 79 | case TST_FS_BSDFFS: |
| 80 | log_info("4.2BSD fast filesystem"); |
| 81 | break; |
| 82 | case TST_FS_BSDLFS: |
| 83 | log_info("4.4BSD log-structured filesystem"); |
| 84 | break; |
| 85 | default: |
| 86 | log_info("type %02X", bsd_header->d_partitions[i].p_fstype); |
| 87 | break; |
| 88 | } |
| 89 | log_info(", offset %9u, size %9u ", |
| 90 | (unsigned int)le32(bsd_header->d_partitions[i].p_offset), |
| 91 | (unsigned int)le32(bsd_header->d_partitions[i].p_size)); |
| 92 | log_CHS_from_LBA(disk_car,le32(bsd_header->d_partitions[i].p_offset)); |
| 93 | log_info(" -> "); |
| 94 | log_CHS_from_LBA(disk_car,le32(bsd_header->d_partitions[i].p_offset)+le32(bsd_header->d_partitions[i].p_size)-1); |
no test coverage detected