Example #1
0
static void
set_label_texts(menudesc *menu, void *arg)
{
	struct ptn_menu_info *pi = arg;
	menu_ent *m;
	int ptn, show_unused_ptn;
	int rawptn = getrawpartition();
	int maxpart = getmaxpartitions();

	msg_display(MSG_fspart);
	msg_table_add(MSG_fspart_header, multname, multname, multname);

	for (show_unused_ptn = 0, ptn = 0; ptn < maxpart; ptn++) {
		m = &menu->opts[ptn];
		m->opt_menu = OPT_NOMENU;
		m->opt_name = NULL;
		m->opt_action = edit_ptn;
		if (ptn == rawptn
#ifdef PART_BOOT
		    || ptn == PART_BOOT
#endif
		    || ptn == PART_C) {
			m->opt_flags = OPT_IGNORE;
		} else {
			m->opt_flags = 0;
			if (pm->bsdlabel[ptn].pi_fstype == FS_UNUSED)
				continue;
		}
		show_unused_ptn = ptn + 2;
	}

	if (!(pi->flags & PIF_SHOW_UNUSED) && ptn > show_unused_ptn) {
		ptn = show_unused_ptn;
		m = &menu->opts[ptn];
		m->opt_name = MSG_show_all_unused_partitions;
		m->opt_action = show_all_unused;
		ptn++;
	}

	m = &menu->opts[ptn];
	m->opt_menu = MENU_sizechoice; 
	m->opt_flags = OPT_SUB; 
	m->opt_action = NULL;
	m->opt_name = MSG_askunits;

	menu->numopts = ptn + 1;
}
Example #2
0
static void
set_ptn_header(menudesc *m, void *arg)
{
	partinfo *p = arg;
	int i;
	int t;

	msg_clear();
	msg_table_add(MSG_edfspart, 'a' + (p - pm->bsdlabel));

	/* Determine which of the properties can be changed */
	for (i = PTN_MENU_START; i <= PTN_MENU_MOUNTPT; i++) {
		/* Default to disabled... */
		m->opts[i].opt_flags |= OPT_IGNORE;
		t = p->pi_fstype;
		if (i == PTN_MENU_END)
			/* The 'end address' is calculated from the size */
			continue;
		if (t == FS_UNUSED || (t == FS_SWAP && i > PTN_MENU_END)) {
			/* Nothing after 'size' can be set for swap/unused */
			p->pi_flags &= ~(PIF_NEWFS | PIF_MOUNT);
			p->pi_mount[0] = 0;
			continue;
		}
		if (i == PTN_MENU_NEWFS && t != FS_BSDFFS && t != FS_BSDLFS
		    && t != FS_APPLEUFS) {
			/* Can only newfs UFS and LFS filesystems */
			p->pi_flags &= ~PIF_NEWFS;
			continue;
		}
		if (i >= PTN_MENU_ISIZE && i <= PTN_MENU_FSIZE) {
			/* Parameters for newfs... */
			if (!(p->pi_flags & PIF_NEWFS))
				/* Not if we aren't going to run newfs */
				continue;
			 if (t == FS_APPLEUFS && i != PTN_MENU_ISIZE)
				/* Can only set # inodes for appleufs */
				continue;
			 if (t == FS_BSDLFS && i != PTN_MENU_BSIZE)
				/* LFS doesn't have fragments */
				continue;
		}
		/* Ok: we want this one */
		m->opts[i].opt_flags &= ~OPT_IGNORE;
	}
}
Example #3
0
/*
 * hook called after writing disklabel to new target disk.
 */
int
md_post_disklabel(void)
{
    struct disklabel updated_label;
    int fd, i, no_match;
    char dev_name[100], buf[80];
    const char *fst[] = {"free", "swap", " v6 ", " v7 ", "sysv", "v71k",
			" v8 ", "ffs ", "dos ", "lfs ", "othr", "hpfs",
			"9660", "boot", "ados", "hfs ", "fcor", "ex2f",
			"ntfs", "raid", "ccd "};

    snprintf(dev_name, sizeof(dev_name), "/dev/r%sc", diskdev);
    /*
     * Open the disk as a raw device
     */
    if ((fd = open(dev_name, O_RDONLY, 0)) < 0)
       return 0;
    /*
     * Get the "new" label to see if we were successful.  If we aren't
     *  we'll return an error to keep from destroying the user's disk.
     */
    ioctl(fd, DIOCGDINFO, &updated_label);
    close(fd);
    /*
     * Make sure the in-core label matches the on-disk one
     */
    no_match = 0;
    for (i=0;i<MAXPARTITIONS;i++) {
        if (i > updated_label.d_npartitions)
           break;
        if (bsdlabel[i].pi_size != updated_label.d_partitions[i].p_size)
           no_match = 1;
        if (bsdlabel[i].pi_size) {
           if (bsdlabel[i].pi_offset != updated_label.d_partitions[i].p_offset)
               no_match = 1;
           if (bsdlabel[i].pi_fstype != updated_label.d_partitions[i].p_fstype)
               no_match = 1;
        }
        if (no_match)
           break;
    }
    /*
     * If the labels don't match, tell the user why
     */
    if (no_match) {
       msg_clear();
       msg_display(MSG_label_error);
       msg_table_add(MSG_dump_line,
           " in-core: offset      size type on-disk: offset      size type");
       for (i=0;i<MAXPARTITIONS;i++) {
           sprintf(buf, " %c:%13.8x%10.8x%5s%16.8x%10.8x%5s", i+'a',
              bsdlabel[i].pi_offset, bsdlabel[i].pi_size,
              fst[bsdlabel[i].pi_fstype],
              updated_label.d_partitions[i].p_offset,
              updated_label.d_partitions[i].p_size,
              fst[updated_label.d_partitions[i].p_fstype]);
           msg_table_add(MSG_dump_line, buf);
       }
       process_menu(MENU_ok2, NULL);
    }
    return no_match;
}