| 46 | } |
| 47 | |
| 48 | 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) |
| 49 | { |
| 50 | if ((memcmp((const char *)pv->id,LVM_ID,sizeof(pv->id)) == 0) && (le16(pv->version) == 1 || le16(pv->version) == 2)) |
| 51 | { |
| 52 | uint32_t size; |
| 53 | if(verbose>0 || dump_ind!=0) |
| 54 | { |
| 55 | 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)); |
| 56 | } |
| 57 | if(dump_ind!=0) |
| 58 | { |
| 59 | /* There is a little offset ... */ |
| 60 | dump_log(pv,DEFAULT_SECTOR_SIZE); |
| 61 | } |
| 62 | if (le32(pv->pv_size) > LVM_MAX_SIZE) |
| 63 | return (1); |
| 64 | if (le32(pv->pv_status) != 0 && le32(pv->pv_status) != PV_ACTIVE) |
| 65 | return (1); |
| 66 | if (le32(pv->pv_allocatable) != 0 && le32(pv->pv_allocatable) != PV_ALLOCATABLE) |
| 67 | return (1); |
| 68 | if (le32(pv->lv_cur) > MAX_LV) |
| 69 | return (1); |
| 70 | if (strlen((const char *)pv->vg_name) > NAME_LEN / 2) |
| 71 | return (1); |
| 72 | size = le32(pv->pe_size) / LVM_MIN_PE_SIZE * LVM_MIN_PE_SIZE; |
| 73 | if ((le32(pv->pe_size) != size) || |
| 74 | (le32(pv->pe_size) < LVM_MIN_PE_SIZE) || |
| 75 | (le32(pv->pe_size) > LVM_MAX_PE_SIZE)) |
| 76 | return (1); |
| 77 | |
| 78 | if (le32(pv->pe_total) > ( pv->pe_on_disk.size / sizeof ( disk_pe_t))) |
| 79 | return (1); |
| 80 | if (le32(pv->pe_allocated) > le32(pv->pe_total)) |
| 81 | return (1); |
| 82 | return 0; |
| 83 | } |
| 84 | return 1; |
| 85 | } |
| 86 | |
| 87 | int check_LVM(disk_t *disk_car,partition_t *partition,const int verbose) |
| 88 | { |
no test coverage detected