Lines Matching refs:dinfo
94 load_partitions(cnode *root, struct disk_info *dinfo)
98 dinfo->num_parts = 0;
100 struct part_info *pinfo = &dinfo->part_lst[dinfo->num_parts];
134 ++dinfo->num_parts;
143 struct disk_info *dinfo;
149 if (!(dinfo = malloc(sizeof(struct disk_info)))) {
153 memset(dinfo, 0, sizeof(struct disk_info));
155 if (!(dinfo->part_lst = malloc(MAX_NUM_PARTS * sizeof(struct part_info)))) {
159 memset(dinfo->part_lst, 0,
178 dinfo->device = strdup(tmp);
185 dinfo->scheme = PART_SCHEME_MBR;
196 dinfo->sect_size = strtol(tmp, NULL, 0);
197 if (!dinfo->sect_size) {
208 if (!(dinfo->skip_lba = strtol(tmp, NULL, 0))) {
218 dinfo->num_lba = strtoul(tmp, NULL, 0);
225 if (load_partitions(partnode, dinfo))
228 return dinfo;
231 if (dinfo->part_lst)
232 free(dinfo->part_lst);
233 if (dinfo->device)
234 free(dinfo->device);
235 free(dinfo);
272 validate(struct disk_info *dinfo)
281 if (!dinfo)
284 if ((fd = open(dinfo->device, O_RDWR)) < 0) {
285 ALOGE("Cannot open device '%s' (errno=%d)", dinfo->device, errno);
290 ALOGE("Cannot stat file '%s', errno=%d.", dinfo->device, errno);
307 if (!sect_sz || sect_sz != dinfo->sect_size) {
313 if (!dinfo->num_lba) {
319 dinfo->num_lba = (uint32_t)(disk_size / (uint64_t)dinfo->sect_size);
321 disk_size = (uint64_t)dinfo->num_lba * (uint64_t)dinfo->sect_size;
324 if (!dinfo->sect_size) {
328 if (dinfo->num_lba)
329 disk_size = (uint64_t)dinfo->num_lba * (uint64_t)dinfo->sect_size;
331 dinfo->num_lba = (uint32_t)(stat.st_size / dinfo->sect_size);
341 dinfo->device, disk_size, dinfo->num_lba, dinfo->sect_size);
346 total_size = dinfo->skip_lba * dinfo->sect_size;
349 for (cnt = 0; cnt < dinfo->num_parts; ++cnt) {
350 struct part_info *part = &dinfo->part_lst[cnt];
358 if (cnt + 1 != dinfo->num_parts) {
388 validate_and_config(struct disk_info *dinfo, int *fd, struct write_list **lst)
393 if ((*fd = validate(dinfo)) < 0)
396 switch (dinfo->scheme) {
398 *lst = config_mbr(dinfo);
420 process_disk_config(struct disk_info *dinfo)
425 if (validate_and_config(dinfo, &fd, &lst) != 0)
435 apply_disk_config(struct disk_info *dinfo, int test)
441 if (validate_and_config(dinfo, &fd, &wr_lst) != 0) {
461 dump_disk_config(struct disk_info *dinfo)
466 printf("Device: %s\n", dinfo->device);
468 switch (dinfo->scheme) {
481 printf("Sector size: %d\n", dinfo->sect_size);
482 printf("Skip leading LBAs: %u\n", dinfo->skip_lba);
483 printf("Number of LBAs: %u\n", dinfo->num_lba);
486 for (cnt = 0; cnt < dinfo->num_parts; ++cnt) {
487 part = &dinfo->part_lst[cnt];
505 find_part(struct disk_info *dinfo, const char *name)
510 for (cnt = 0; cnt < dinfo->num_parts; ++cnt) {
511 pinfo = &dinfo->part_lst[cnt];
521 find_part_device(struct disk_info *dinfo, const char *name)
523 switch (dinfo->scheme) {
525 return find_mbr_part(dinfo, name);