/* * look for DOS partition usable for nested BSD partition table */ static int bsd_assign_dos_partition(struct fdisk_context *cxt) { struct fdisk_bsd_label *l = self_label(cxt); size_t i; for (i = 0; i < 4; i++) { sector_t ss; l->dos_part = fdisk_dos_get_partition(cxt->parent, i); if (!l->dos_part || !is_bsd_partition_type(l->dos_part->sys_ind)) continue; ss = dos_partition_get_start(l->dos_part); if (!ss) { fdisk_warnx(cxt, _("Partition %zd: has invalid starting " "sector 0."), i + 1); return -1; } if (cxt->parent->dev_path) { free(cxt->dev_path); cxt->dev_path = fdisk_partname( cxt->parent->dev_path, i + 1); } DBG(LABEL, ul_debug("partition %zu assigned to BSD", i + 1)); return 0; } fdisk_warnx(cxt, _("There is no *BSD partition on %s."), cxt->parent->dev_path); free(cxt->dev_path); cxt->dev_path = NULL; l->dos_part = NULL; return 1; }
static void bsd_select(void) { #if !defined(__alpha__) int t, ss; struct partition *p; for (t = 0; t < 4; t++) { p = get_part_table(t); if (p && is_bsd_partition_type(p->sys_ind)) { xbsd_part = p; xbsd_part_index = t; ss = get_start_sect(xbsd_part); if (ss == 0) { printf("Partition %s has invalid starting sector 0\n", partname(disk_device, t+1, 0)); return; } printf("Reading disklabel of %s at sector %u\n", partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR); if (xbsd_readlabel(xbsd_part) == 0) { if (xbsd_create_disklabel() == 0) return; break; } } } if (t == 4) { printf("There is no *BSD partition on %s\n", disk_device); return; } #elif defined(__alpha__) if (xbsd_readlabel(NULL) == 0) if (xbsd_create_disklabel() == 0) exit(EXIT_SUCCESS); #endif while (1) { bb_putchar('\n'); switch (tolower(read_nonempty("BSD disklabel command (m for help): "))) { case 'd': xbsd_delete_part(); break; case 'e': xbsd_edit_disklabel(); break; case 'i': xbsd_write_bootstrap(); break; case 'l': xbsd_list_types(); break; case 'n': xbsd_new_part(); break; case 'p': xbsd_print_disklabel(0); break; case 'q': if (ENABLE_FEATURE_CLEAN_UP) close_dev_fd(); exit(EXIT_SUCCESS); case 'r': return; case 's': xbsd_print_disklabel(1); break; case 't': xbsd_change_fstype(); break; case 'u': change_units(); break; case 'w': xbsd_write_disklabel(); break; #if !defined(__alpha__) case 'x': xbsd_link_part(); break; #endif default: bsd_menu(); break; } } }