Exemple #1
0
/*
 * any additional partition validation
 */
int
md_check_partitions(void)
{
	/* hp300 partitions must be in order of the range. */
	int part, last;
	uint32_t start;

	start = 0;
	last = PART_A - 1;
	for (part = PART_A; part < MAXPARTITIONS; part++) {
		if (part == PART_RAW || part == PART_BOOT)
			continue;
		if (last >= PART_A && bsdlabel[part].pi_size > 0) {
			msg_display(MSG_emptypart, part+'a');
			process_menu(MENU_ok, NULL);
			return 0;
		}
		if (bsdlabel[part].pi_size == 0) {
			if (last < PART_A)
				last = part;
		} else {
			if (start >= bsdlabel[part].pi_offset) {
				msg_display(MSG_ordering, part+'a');
				process_menu(MENU_yesno, NULL);
				if (yesno)
					return 0;
			}
			start = bsdlabel[part].pi_offset;
		}
	}

	return 1;
}
Exemple #2
0
/*
 * any additional partition validation
 */
int
md_check_partitions(void)
{
	/* X68k partitions must be in order of the range. */
	int part, last = PART_A-1;
	uint32_t start = 0;

	for (part = PART_A; part < 8; part++) {
		if (part == PART_C)
			continue;
		if (last >= PART_A && pm->bsdlabel[part].pi_size > 0) {
			msg_display(MSG_emptypart, part+'a');
			process_menu(MENU_ok, NULL);
			return 0;
		}
		if (pm->bsdlabel[part].pi_size == 0) {
			if (last < PART_A)
				last = part;
		} else {
			if (start >= pm->bsdlabel[part].pi_offset) {
				msg_display(MSG_ordering, part+'a');
				if (ask_yesno(NULL))
					return 0;
			}
			start = pm->bsdlabel[part].pi_offset;
		}
	}

	return 1;
}
Exemple #3
0
int
md_check_mbr(mbr_info_t *mbri)
{
    mbr_info_t *ext;
    struct mbr_partition *part;
    int i;

    for (ext = mbri; ext; ext = ext->extended) {
        part = ext->mbr.mbr_parts;
        for (i = 0; i < MBR_PART_COUNT; part++, i++) {
            if (part->mbrp_type == MBR_PTYPE_FAT12) {
                bootstart = part->mbrp_start;
                bootsize = part->mbrp_size;
                break;
            }
        }
    }
    if (bootsize < (MIN_FAT12_BOOT / 512)) {
        msg_display(MSG_boottoosmall);
        msg_display_add(MSG_reeditpart, 0);
        process_menu(MENU_yesno, NULL);
        if (!yesno)
            return 0;
        return 1;
    }
    if (bootstart == 0 || bootsize == 0) {
        msg_display(MSG_nobootpart);
        msg_display_add(MSG_reeditpart, 0);
        process_menu(MENU_yesno, NULL);
        if (!yesno)
            return 0;
        return 1;
    }
    return 2;
}
Exemple #4
0
static int
md_check_partitions(void)
{
	int i, j;
	int preserve;

	/* check existing BSD partitions. */
	for (i = 0; i < NDOSPART; i++) {
		if (md_disklabel.dosparts[i].dp_size == 0)
			break;
		if (memcmp(md_disklabel.dosparts[i].dp_typename, "Human68k", 8)) {
			msg_display(MSG_existing);
			process_menu(MENU_noyes);
			preserve = yesno;
			break;
		}
	}
	emptylabel(bsdlabel);
	bsdlabel[C].pi_fstype = FS_UNUSED;
	bsdlabel[C].pi_offset = 0;
	bsdlabel[C].pi_size = dlsize;
	for (i = 0, j = A; i < NDOSPART;) {
		if (j == C) {
			j++;
			continue;
		}
		if (!preserve &&
		    memcmp(md_disklabel.dosparts[i].dp_typename,
			    "Human68k", 8)) {
			/* discard it. */
			i++;
			continue;
		}
		bsdlabel[j].pi_fstype = (i == 1) ? FS_SWAP : FS_BSDFFS;
		bsdlabel[j].pi_offset = md_disklabel.dosparts[i].dp_start*2;
		bsdlabel[j].pi_size = md_disklabel.dosparts[i].dp_size*2;
		i++;
		j++;
	}
	if (j > 6) {
		msg_display(MSG_nofreepart, diskdev);
		return 0;
	}
	md_nfreepart = 8 - j;

	/* check for free space */
	fsptsize = bsdlabel[A].pi_offset - 64;
	if (fptsize <= 0) {	/* XXX: should not be 0; minfsdb?  */
		msg_display(MSG_notfirst, diskdev);
		process_menu(MENU_ok);
		exit(1);
	}

	/* Partitions should be preserved in md_make_bsdpartitions() */
}
Exemple #5
0
/*
 * hook called before writing new disklabel.
 */
int
md_pre_disklabel(void)
{
	msg_display(MSG_dofdisk);

	/* write edited MBR onto disk. */
	if (write_mbr(diskdev, &mbr, 1) != 0) {
		msg_display(MSG_wmbrfail);
		process_menu(MENU_ok, NULL);
		return 1;
	}
	return 0;
}
Exemple #6
0
int
md_pre_update(void)
{
    struct mbr_partition *part;
    mbr_info_t *ext;
    int i;

    if (get_ramsize() <= 32)
        set_swap(diskdev, NULL);

    read_mbr(diskdev, &mbr);
    /* do a sanity check of the partition table */
    for (ext = &mbr; ext; ext = ext->extended) {
        part = ext->mbr.mbr_parts;
        for (i = 0; i < MBR_PART_COUNT; part++, i++) {
            if (part->mbrp_type != MBR_PTYPE_FAT12)
                continue;
            if (part->mbrp_size < (MIN_FAT12_BOOT / 512)) {
                msg_display(MSG_boottoosmall);
                msg_display_add(MSG_nobootpart, 0);
                process_menu(MENU_yesno, NULL);
                if (!yesno)
                    return 0;
                nobootfs = 1;
            }
        }
    }
    if (md_check_partitions() == 0)
        nobootfs = 1;
    return 1;
}
Exemple #7
0
int
/*ARGSUSED*/
log_flip(menudesc *m, void *arg)
{
	time_t tloc;

	(void)time(&tloc);
	if (logfp) {
		fprintf(logfp, "Log ended at: %s\n", safectime(&tloc));
		fflush(logfp);
		fclose(logfp);
		logfp = NULL;
	} else {
		logfp = fopen("/tmp/sysinst.log", "a");
		if (logfp != NULL) {
			fprintf(logfp,
			    "Log started at: %s\n", safectime(&tloc));
			fflush(logfp);
		} else {
			if (mainwin) {
				msg_display(MSG_openfail, "log file",
				    strerror(errno));
			} else {
				fprintf(stderr, "could not open /tmp/sysinst.log: %s\n",
				    strerror(errno));
				exit(1);
			}
		}
	}
	return(0);
}
Exemple #8
0
/*
 * Save X symlink to X.old so it can be recovered later
 */
static int
save_X(const char *xroot)
{
    char newx[MAXPATHLEN], oldx[MAXPATHLEN];

    strlcpy(newx, xroot, sizeof(newx));
    strlcat(newx, "/bin/X", sizeof(newx));
    strlcpy(oldx, newx, sizeof(oldx));
    strlcat(oldx, ".old", sizeof(oldx));

    /* Only care for X if it's a symlink */
    if (target_symlink_exists_p(newx)) {
        if (target_symlink_exists_p(oldx)) {
            msg_display(MSG_X_oldexists, xroot, xroot, xroot,
                        xroot, xroot, xroot, xroot, xroot, xroot, xroot,
                        xroot);
            process_menu(MENU_ok, NULL);
            return EEXIST;
        }

#ifdef DEBUG
        printf("saving %s as %s ...", newx, oldx);
#endif

        /* Move target .../X to .../X.old.  Abort on error. */
        mv_within_target_or_die(newx, oldx);
    }

    return 0;
}
Exemple #9
0
void display(MSG *rt, char *nick_name, int mode, char *to_name, char *msg, int num)
{
	char buf[MAXLINE] = {0};
	if (-1 == system("clear"))
	{
		perror("system clear error.");
	}
	if (0 == num) num = 8;
	printf("\n\t\t\tWelcome~!\n");
	printf("Recent %d message:\n", num);
	msg_display(rt->next, num, num);
	sprintf(buf, "\n$%s >>>", nick_name);
	if (PRI == mode)
	{
		strcat(buf, "(");
		strcat(buf, to_name);
		strcat(buf, ")");
	}
	if (NULL != msg)
	{
		strcat(buf, msg);
	}
	printf (buf);
	fflush(stdout);
}
Exemple #10
0
void msg_display(MSG *rt, int deep, int num)
{
	static int id = 0;
	if (NULL == rt && num == deep) 
	{
		perror("No Message.");
		id = 0;
		while (id++ < deep) puts ("");
		return ;
	}
	if (deep > 0 && NULL != rt)
	{
		msg_display(rt->next, deep-1, num);
		if (0 == strcmp("System", rt->nick_name))
		{
			printf("\t%d: %s: %s[%s]\n", ++id, rt->nick_name, rt->msg, rt->time);
		}
		else printf("\t%d: %s(%s): %s[%s]\n", ++id, rt->nick_name, rt->ip, rt->msg, rt->time);
		if (num == deep) while (id++ < deep) puts ("");
	}
	else
	{
		id = 0;
	}
}
Exemple #11
0
int
md_check_mbr(mbr_info_t *mbri)
{
	mbr_info_t *ext;
	struct mbr_partition *part;
	int i, hasboot=0;

	if (boardtype == BOARD_TYPE_NORMAL)
		return 2;
	/* raspi code */
	if (boardtype == BOARD_TYPE_RPI) {
		for (ext = mbri; ext; ext = ext->extended) {
			part = ext->mbr.mbr_parts;
			for (i=0, hasboot=0; i < MBR_PART_COUNT; part++, i++) {
				if (part->mbrp_type != MBR_PTYPE_FAT16L &&
				    part->mbrp_type != MBR_PTYPE_FAT32L)
					continue;
				hasboot = 1;
				break;
			}
		}
		if (!hasboot) {
			msg_display(MSG_nomsdospart);
			msg_display_add(MSG_reeditpart, 0);
			if (!ask_yesno(NULL))
				return 0;
			return 1;
		}
	}
	return 2;
}
Exemple #12
0
/*
 * Unpacks sets,  clobbering existing contents.
 */
void
do_reinstall_sets(void)
{
    int retcode = 0;

    unwind_mounts();
    msg_display(MSG_reinstallusure);
    if (!ask_noyes(NULL))
        return;

    if (find_disks(msg_string(MSG_reinstall)) < 0)
        return;

    if (mount_disks() != 0)
        return;

    /* Unpack the distribution. */
    process_menu(MENU_distset, &retcode);
    if (retcode == 0)
        return;
    if (get_and_unpack_sets(0, NULL, MSG_unpackcomplete, MSG_abortunpack) != 0)
        return;

    sanity_check();
}
Exemple #13
0
static int
/*ARGSUSED*/
script_flip(menudesc *m, void *arg)
{
	time_t tloc;

	(void)time(&tloc);
	if (script) {
		scripting_fprintf(NULL, "# Script ended at: %s\n",
		    safectime(&tloc));
		fflush(script);
		fclose(script);
		script = NULL;
	} else {
		script = fopen("/tmp/sysinst.sh", "w");
		if (script != NULL) {
			scripting_fprintf(NULL, "#!/bin/sh\n");
			scripting_fprintf(NULL, "# Script started at: %s\n",
			    safectime(&tloc));
			fflush(script);
		} else {
			msg_display(MSG_openfail, "script file",
			    strerror(errno));
		}
	}
	return(0);
}
Exemple #14
0
/*
 * hook called after upgrade() or install() has finished setting
 * up the target disk but immediately before the user is given the
 * ``disks are now set up'' message.
 *
 * On pmax, we take this opportuinty to update the bootblocks.
 */
int
md_post_newfs(void)
{
	char *bootxx;
	int error;

	/* XXX boot blocks ... */
	if (target_already_root()) {
		/* /usr is empty and we must already have bootblocks? */
		return 0;
	}

	msg_display(MSG_dobootblks, diskdev);
	cp_to_target("/usr/mdec/boot.pmax", "/boot.pmax");
	bootxx = bootxx_name();
	if (bootxx != NULL) {
		error = run_program(RUN_DISPLAY | RUN_NO_CLEAR,
		    "/usr/sbin/installboot /dev/r%sc %s", diskdev, bootxx);
		free(bootxx);
	} else
		error = -1;

	if (error != 0)
		process_menu(MENU_ok,
		    deconst("Warning: disk is probably not bootable"));

	return 0;
}
Exemple #15
0
__dead static void
abort_libupdate(void)
{
	msg_display(MSG_aoutfail);
	process_menu(MENU_ok, NULL);
	exit(1);
}
Exemple #16
0
static int
md_newdisk(void)
{
	msg_display(MSG_newdisk, pm->diskdev, pm->diskdev);

	return run_program(RUN_FATAL|RUN_DISPLAY,
	    "/usr/mdec/newdisk -v %s", pm->diskdev);
}
Exemple #17
0
int
md_post_extract(void)
{
	msg_display(MSG_setbootdevice);
	process_menu(MENU_ok, NULL);

	return 0;
}
Exemple #18
0
void
md_cleanup_install(void)
{
#ifndef DEBUG
    enable_rc_conf();
#endif
    msg_display(MSG_howtoboot);
    process_menu(MENU_ok, NULL);
}
Exemple #19
0
/*
 * hook called after upgrade() or install() has finished setting
 * up the target disk but immediately before the user is given the
 * ``disks are now set up'' message.
 */
int
md_post_newfs(void)
{
    if (!nobootfs) {
        msg_display(msg_string(MSG_copybootloader), diskdev);
        cp_to_target("/usr/mdec/boot", PART_BOOT_FAT12_PI_MOUNT);
    }

    return 0;
}
Exemple #20
0
int
checkoverlap(partinfo *lp, int nparts, int rawpart, int bsdpart)
{
	int i, j;
	if (checklabel(lp, nparts, rawpart, bsdpart, &i, &j)) {
		msg_display(MSG_partitions_overlap,'a'+i,'a'+j);
		return 1;
	}
	return 0;
}
Exemple #21
0
/*
 * hook called after writing disklabel to new target disk.
 */
int
md_post_disklabel(void)
{
	/* Sector forwarding / badblocks ... */
	if (*doessf) {
		msg_display(MSG_dobad144);
		return run_program(RUN_DISPLAY, "/usr/sbin/bad144 %s 0",
		    diskdev);
	}
	return 0;
}
Exemple #22
0
/*
 * hook called after upgrade() or install() has finished setting
 * up the target disk but immediately before the user is given the
 * ``disks are now set up'' message.
 *
 * On hp300, we use this opportunity to install the boot blocks.
 */
int
md_post_newfs(void)
{
	/* boot blocks ... */
	msg_display(MSG_dobootblks, diskdev);
	if (run_program(RUN_DISPLAY | RUN_NO_CLEAR,
	    "/usr/sbin/installboot /dev/r%sc /usr/mdec/uboot.lif", diskdev))
		process_menu(MENU_ok,
		    deconst("Warning: disk is probably not bootable"));
	return 0;
}
Exemple #23
0
/*
 * hook called before writing new disklabel.
 */
int
md_pre_disklabel(void)
{
	char diskpath[MAXPATHLEN];

	if (clear_mbr(pm->diskdev, diskpath, sizeof(diskpath)) == -1) {
		msg_display(MSG_badclearmbr, diskpath);
		process_menu(MENU_ok, NULL);
	}

	return 0;
}
Exemple #24
0
/*
 * hook called after upgrade() or install() has finished setting
 * up the target disk but immediately before the user is given the
 * ``disks are now set up'' message.
 *
 * On the news68k, we use this opportunity to install the boot blocks.
 */
int
md_post_newfs(void)
{
	const char *bootfile = "/boot";

	msg_display(MSG_dobootblks, diskdev);
	cp_to_target("/usr/mdec/boot", bootfile);
	sync();
	run_program(RUN_DISPLAY, "/usr/sbin/installboot /dev/r%sc %s %s",
	    diskdev, "/usr/mdec/bootxx", bootfile);
	return 0;
}
Exemple #25
0
static int
do_config_network(void)
{
	int ret;

	while ((ret = config_network()) <= 0) {
		if (ret < 0)
			return (-1);
		msg_display(MSG_netnotup);
		process_menu(MENU_yesno, NULL);
		if (!yesno) {
			msg_display(MSG_netnotup_continueanyway);
			process_menu(MENU_yesno, NULL);
			if (!yesno)
				return -1;
			network_up = 1;
			break;
		}
	}
	return 0;
}
Exemple #26
0
/*
 * hook called after upgrade() or install() has finished setting
 * up the target disk but immediately before the user is given the
 * ``disks are now set up'' message.
 *
 * On the x68k, we use this opportunity to install the boot blocks.
 */
int
md_post_newfs(void)
{
	/* boot blocks ... */
	msg_display(MSG_dobootblks, pm->diskdev);
	cp_to_target("/usr/mdec/boot", "/boot");
	if (run_program(RUN_DISPLAY | RUN_NO_CLEAR,
	    "/usr/mdec/installboot.new /usr/mdec/sdboot_ufs /dev/r%sa",
	    pm->diskdev))
		process_menu(MENU_ok,
			deconst("Warning: disk is probably not bootable"));
	return 0;
}
Exemple #27
0
static int
change_root_password(struct menudesc *menu, void *arg)
{
	configinfo **confp = arg;

	msg_display(MSG_rootpw);
	process_menu(MENU_yesno, NULL);
	if (yesno)
		run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT,
			"passwd -l root");
	confp[menu->cursel]->setting = MSG_password_set;
	return 0;
}
Exemple #28
0
/*
 * hook called after upgrade() or install() has finished setting
 * up the target disk but immediately before the user is given the
 * ``disks are now set up'' message..
 *
 * On mvme68k, we use this opportunity to install the boot blocks.
 */
int
md_post_newfs(void)
{

	/* boot blocks ... */
	msg_display(MSG_dobootblks, diskdev);
	cp_to_target("/usr/mdec/bootsd", "/.bootsd");
	if (run_program(RUN_DISPLAY | RUN_NO_CLEAR,
	    "/usr/mdec/installboot %s /usr/mdec/bootxx /dev/r%sa",
	    target_expand("/.bootsd"), diskdev))
		process_menu(MENU_ok,
			deconst("Warning: disk is probably not bootable"));
	return 0;
}
Exemple #29
0
static int
set_binpkg(struct menudesc *menu, void *arg)
{
	configinfo **confp = arg;

	char pattern[STRSIZE];

	/* binary pkg config requires network at this point, so if
	   it's not already configured, do it. */
	if (network_up == 0) {
		if (config_network())
			mnt_net_config();
	}

	process_menu(MENU_binpkg, NULL);
	make_url(pkgpath, &pkg, pkg_dir);
	if ( run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT,
		"pkg_add %s/pkgin", pkgpath) != 0) {
		msg_display(MSG_pkgin_failed);
		process_menu(MENU_ok, NULL);
		confp[menu->cursel]->setting = MSG_failed;
		return 0;
	}

	/* configure pkgin to use $pkgpath as a repository */
	snprintf(pattern, STRSIZE, "s,^[^#].*$,%s,", pkgpath);
	replace("/usr/pkg/etc/pkgin/repositories.conf", pattern);

	run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT,
		"/usr/pkg/bin/pkgin -y update");

	msg_display(MSG_binpkg_installed);
	process_menu(MENU_ok, NULL);
	
	confp[menu->cursel]->setting = MSG_DONE;
	return 0;
}
Exemple #30
0
/*
 * Check a disklabel.
 * If there are overlapping active partitions,
 * Ask the user if they want to edit the partition or give up.
 */
int
edit_and_check_label(partinfo *lp, int nparts, int rawpart, int bsdpart)
{
	static struct menu_ent *menu;
	static int menu_no = -1;
	static struct ptn_menu_info pi;
	int maxpart = getmaxpartitions();

	if (menu == NULL) {
		menu = malloc((maxpart + 1) * sizeof *menu);
		if (!menu)
			return 1;
	}

	if (menu_no == -1) {
		menu_no = new_menu(NULL, menu, maxpart + 1,
			0, -1, maxpart + 2, 74,
			MC_ALWAYS_SCROLL | MC_NOBOX | MC_DFLTEXIT,
			set_label_texts, fmt_fspart, NULL, NULL,
			MSG_partition_sizes_ok);
	}

	if (menu_no < 0)
		return 1;

	pi.flags = 0;
	pm->current_cylsize = pm->dlcylsize;

	for (;;) {
		/* first give the user the option to edit the label... */
		process_menu(menu_no, &pi);

		/* User thinks the label is OK. */
		/* check we have a single root fs */
		if (check_one_root(lp, nparts) == 0 && partman_go == 0)
			msg_display(MSG_must_be_one_root);
		else 
			/* Check for overlaps */
			if (checkoverlap(lp, nparts, rawpart, bsdpart) == 0)
				return 1;

		/*XXX ???*/
		msg_display_add(MSG_edit_partitions_again);
		if (!ask_yesno(NULL))
			return(0);
	}

	/*NOTREACHED*/
}