Lines Matching defs:dinfo
93 load_partitions(cnode *root, struct disk_info *dinfo)
97 dinfo->num_parts = 0;
99 struct part_info *pinfo = &dinfo->part_lst[dinfo->num_parts];
133 ++dinfo->num_parts;
142 struct disk_info *dinfo;
148 if (!(dinfo = malloc(sizeof(struct disk_info)))) {
152 memset(dinfo, 0, sizeof(struct disk_info));
154 if (!(dinfo->part_lst = malloc(MAX_NUM_PARTS * sizeof(struct part_info)))) {
158 memset(dinfo->part_lst, 0,
177 dinfo->device = strdup(tmp);
184 dinfo->scheme = PART_SCHEME_MBR;
195 dinfo->sect_size = strtol(tmp, NULL, 0);
196 if (!dinfo->sect_size) {
207 if (!(dinfo->skip_lba = strtol(tmp, NULL, 0))) {
217 dinfo->num_lba = strtoul(tmp, NULL, 0);
224 if (load_partitions(partnode, dinfo))
227 return dinfo;
230 if (dinfo->part_lst)
231 free(dinfo->part_lst);
232 if (dinfo->device)
233 free(dinfo->device);
234 free(dinfo);
271 validate(struct disk_info *dinfo)
280 if (!dinfo)
283 if ((fd = open(dinfo->device, O_RDWR)) < 0) {
284 LOGE("Cannot open device '%s' (errno=%d)", dinfo->device, errno);
289 LOGE("Cannot stat file '%s', errno=%d.", dinfo->device, errno);
306 if (!sect_sz || sect_sz != dinfo->sect_size) {
312 if (!dinfo->num_lba) {
318 dinfo->num_lba = (uint32_t)(disk_size / (uint64_t)dinfo->sect_size);
320 disk_size = (uint64_t)dinfo->num_lba * (uint64_t)dinfo->sect_size;
323 if (!dinfo->sect_size) {
327 if (dinfo->num_lba)
328 disk_size = (uint64_t)dinfo->num_lba * (uint64_t)dinfo->sect_size;
330 dinfo->num_lba = (uint32_t)(stat.st_size / dinfo->sect_size);
340 dinfo->device, disk_size, dinfo->num_lba, dinfo->sect_size);
345 total_size = dinfo->skip_lba * dinfo->sect_size;
348 for (cnt = 0; cnt < dinfo->num_parts; ++cnt) {
349 struct part_info *part = &dinfo->part_lst[cnt];
357 if (cnt + 1 != dinfo->num_parts) {
387 validate_and_config(struct disk_info *dinfo, int *fd, struct write_list **lst)
392 if ((*fd = validate(dinfo)) < 0)
395 switch (dinfo->scheme) {
397 *lst = config_mbr(dinfo);
419 process_disk_config(struct disk_info *dinfo)
424 if (validate_and_config(dinfo, &fd, &lst) != 0)
434 apply_disk_config(struct disk_info *dinfo, int test)
440 if (validate_and_config(dinfo, &fd, &wr_lst) != 0) {
460 dump_disk_config(struct disk_info *dinfo)
465 printf("Device: %s\n", dinfo->device);
467 switch (dinfo->scheme) {
480 printf("Sector size: %d\n", dinfo->sect_size);
481 printf("Skip leading LBAs: %u\n", dinfo->skip_lba);
482 printf("Number of LBAs: %u\n", dinfo->num_lba);
485 for (cnt = 0; cnt < dinfo->num_parts; ++cnt) {
486 part = &dinfo->part_lst[cnt];
504 find_part(struct disk_info *dinfo, const char *name)
509 for (cnt = 0; cnt < dinfo->num_parts; ++cnt) {
510 pinfo = &dinfo->part_lst[cnt];
520 find_part_device(struct disk_info *dinfo, const char *name)
522 switch (dinfo->scheme) {
524 return find_mbr_part(dinfo, name);