␉static int editlevel;␊ |
␉mbr_t *mbr;␊ |
␉cmd_t cmd;␊ |
␉int i, st, fd;␊ |
␉int i, st = CMD_EXIT, fd;␊ |
␉int modified = 0;␉␊ |
␊ |
␉/* One level deeper */␊ |
|
␊ |
␉/* Read MBR & partition */␊ |
␉mbr = MBR_alloc(NULL);␊ |
␉if (!mbr) errx(1, "out of memory");␊ |
␉fd = DISK_open(disk->name, O_RDONLY);␊ |
␉if (fd == -1) ␊ |
␉␉err(1, "Could not open %s", disk->name);␊ |
␉MBR_read(disk, fd, offset, mbr);␊ |
␉DISK_close(fd);␊ |
␊ |
|
␉if (mbr->signature != MBR_SIGNATURE) {␊ |
␉ int yn = ask_yn("The signature for this MBR is invalid.\nWould you like to initialize the partition table?", 1);␊ |
␉ if (yn) {␊ |
␉ strcpy(cmd.cmd, "erase");␊ |
␉ strlcpy(cmd.cmd, "erase", sizeof(cmd.cmd));␊ |
␉ cmd.args[0] = '\0';␊ |
␉ st = Xerase(&cmd, disk, mbr, tt, offset);␊ |
␉ Xerase(&cmd, disk, mbr, tt, offset);␊ |
␉ modified = 1;␊ |
␉ }␊ |
␉}␊ |
|
␉␉␉␉break;␊ |
␊ |
␉␉/* Quick hack to put in '?' == 'help' */␊ |
␉␉if (!strcmp(cmd.cmd, "?"))␊ |
␉␉if (!strncmp(cmd.cmd, "?", sizeof("?")))␊ |
␉␉␉i = 0;␊ |
␊ |
␉␉/* Check for valid command */␊ |
|
␉␉␉printf("Invalid command '%s'. Try 'help'.\n", cmd.cmd);␊ |
␉␉␉continue;␊ |
␉␉} else␊ |
␉␉␉strcpy(cmd.cmd, cmd_table[i].cmd);␊ |
␉␉␉strlcpy(cmd.cmd, cmd_table[i].cmd, sizeof(cmd.cmd));␊ |
␊ |
␉␉/* Call function */␊ |
␉␉st = cmd_table[i].fcn(&cmd, disk, mbr, tt, offset);␊ |
|
␉disk_t *disk;␊ |
␉int do_dump;␊ |
{␊ |
␉int fd, offset, firstoff;␊ |
␉int fd /*, offset, firstoff*/;␊ |
␉mbr_t *mbr;␊ |
␊ |
␉fd = DISK_open(disk->name, O_RDONLY);␊ |
␉offset = firstoff = 0;␊ |
␉if (fd == -1) ␊ |
␉␉err(1, "Could not open %s", disk->name);␊ |
␉/*offset = firstoff = 0;*/␊ |
␊ |
␉if (!do_dump)␊ |
␉ DISK_printmetrics(disk);␊ |