Exemple #1
0
int
Xwrite(char *args, struct disk *disk, struct mbr *mbr, struct mbr *tt,
    int offset)
{
	struct dos_mbr dos_mbr;
	int fd, i, n;

	for (i = 0, n = 0; i < NDOSPART; i++)
		if (mbr->part[i].id == 0xA6)
			n++;
	if (n >= 2) {
		warnx("MBR contains more than one OpenBSD partition!");
		if (!ask_yn("Write MBR anyway?"))
			return (CMD_CONT);
	}

	fd = DISK_open(disk->name, O_RDWR);
	MBR_make(mbr, &dos_mbr);

	printf("Writing MBR at offset %d.\n", offset);
	if (MBR_write(fd, offset, &dos_mbr) == -1) {
		int saved_errno = errno;
		warn("error writing MBR");
		close(fd);
		errno = saved_errno;
		return (CMD_CONT);
	}
	close(fd);

	/* Refresh in memory copy to reflect what was just written. */
	MBR_parse(disk, &dos_mbr, mbr->offset, mbr->reloffset, mbr);

	return (CMD_CLEAN);
}
Exemple #2
0
int
Xreinit(cmd_t *cmd, disk_t *disk, mbr_t *mbr, mbr_t *tt, int offset)
{
	char buf[DEV_BSIZE];

	/* Copy template MBR */
	MBR_make(tt, buf);
	MBR_parse(disk, buf, mbr->offset, mbr->reloffset, mbr);

	MBR_init(disk, mbr);

	/* Tell em we did something */
	printf("In memory copy is initialized to:\n");
	printf("Offset: %d\t", offset);
	MBR_print(mbr, cmd->args);
	printf("Use 'write' to update disk.\n");

	return (CMD_DIRTY);
}
Exemple #3
0
int
Xreinit(char *args, struct disk *disk, struct mbr *mbr, struct mbr *tt,
    int offset)
{
	struct dos_mbr dos_mbr;

	/* Copy template MBR */
	MBR_make(tt, &dos_mbr);
	MBR_parse(disk, &dos_mbr, mbr->offset, mbr->reloffset, mbr);

	MBR_init(disk, mbr);

	/* Tell em we did something */
	printf("In memory copy is initialized to:\n");
	printf("Offset: %d\t", offset);
	MBR_print(mbr, args);
	printf("Use 'write' to update disk.\n");

	return (CMD_DIRTY);
}