No functional change.
-/* $OpenBSD: cmd.c,v 1.118 2021/06/28 19:50:30 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.119 2021/07/11 12:51:36 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
dogpt = 0;
else if (strlen(args) > 0) {
printf("Unrecognized modifier '%s'\n", args);
- return (CMD_CONT);
+ return CMD_CONT;
}
MBR_make(&initial_mbr, &dos_mbr);
printf("Use 'write' to update disk.\n");
- return (CMD_DIRTY);
+ return CMD_DIRTY;
}
int
disk.size = disk.cylinders * disk.heads * disk.sectors;
}
- return (CMD_CONT);
+ return CMD_CONT;
}
int
pt = parsepn(to);
if (pt == -1)
- return (CMD_CONT);
+ return CMD_CONT;
pf = parsepn(from);
if (pf == -1)
- return (CMD_CONT);
+ return CMD_CONT;
if (pt == pf) {
printf("%d same partition as %d, doing nothing.\n", pt, pf);
- return (CMD_CONT);
+ return CMD_CONT;
}
if (letoh64(gh.gh_sig) == GPTSIGNATURE) {
mbr->part[pf] = pp;
}
- return (CMD_DIRTY);
+ return CMD_DIRTY;
}
int
goto done;
memset(gg, 0, sizeof(struct gpt_partition));
printf("Partition %d is disabled.\n", pn);
- return (CMD_DIRTY);
+ return CMD_DIRTY;
}
if (GPT_get_lba_start(pn) == -1 ||
}
if (memcmp(gg, &oldgg, sizeof(*gg)))
- return (CMD_DIRTY);
+ return CMD_DIRTY;
else
- return (CMD_CLEAN);
+ return CMD_CLEAN;
done:
*gg = oldgg;
- return (CMD_CONT);
+ return CMD_CONT;
}
int
done:
if (memcmp(pp, &oldpp, sizeof(*pp)))
- return (CMD_DIRTY);
+ return CMD_DIRTY;
else
- return (CMD_CONT);
+ return CMD_CONT;
}
int
pn = parsepn(args);
if (pn == -1)
- return (CMD_CONT);
+ return CMD_CONT;
if (letoh64(gh.gh_sig) == GPTSIGNATURE)
- return (gedit(pn));
+ return gedit(pn);
else
- return (edit(pn, mbr));
+ return edit(pn, mbr);
}
int
}
if (memcmp(gg, &oldgg, sizeof(*gg)))
- return (CMD_DIRTY);
+ return CMD_DIRTY;
else
- return (CMD_CLEAN);
+ return CMD_CLEAN;
done:
*gg = oldgg;
- return (CMD_CONT);
+ return CMD_CONT;
}
int
/* Ask for MBR partition type */
num = ask_pid(pp->id, NULL);
if (num == pp->id)
- return (CMD_CONT);
+ return CMD_CONT;
pp->id = num;
- return (CMD_DIRTY);
+ return CMD_DIRTY;
}
int
pn = parsepn(args);
if (pn == -1)
- return (CMD_CONT);
+ return CMD_CONT;
if (letoh64(gh.gh_sig) == GPTSIGNATURE)
- return (gsetpid(pn));
+ return gsetpid(pn);
else
- return (setpid(pn, mbr));
+ return setpid(pn, mbr);
}
int
pn = parsepn(args);
if (pn == -1)
- return (CMD_CONT);
+ return CMD_CONT;
off = mbr->part[pn].bs;
if ((mbr->part[pn].id != DOSPTYP_EXTEND) &&
(mbr->part[pn].id != DOSPTYP_EXTENDL)) {
printf("Partition %d is not an extended partition.\n", pn);
- return (CMD_CONT);
+ return CMD_CONT;
}
if (firstoff == 0)
if (!off) {
printf("Loop to offset 0! Not selected.\n");
- return (CMD_CONT);
+ return CMD_CONT;
} else {
printf("Selected extended partition %d\n", pn);
printf("New MBR at offset %lld.\n", (long long)off);
/* Recursion is beautiful! */
USER_edit(off, firstoff);
- return (CMD_CONT);
+ return CMD_CONT;
}
int
else
MBR_print(mbr, args);
- return (CMD_CONT);
+ return CMD_CONT;
}
int
if (n >= 2) {
warnx("MBR contains more than one OpenBSD partition!");
if (!ask_yn("Write MBR anyway?"))
- return (CMD_CONT);
+ return CMD_CONT;
}
MBR_make(mbr, &dos_mbr);
printf("Writing MBR at offset %lld.\n", (long long)mbr->offset);
if (MBR_write(mbr->offset, &dos_mbr) == -1) {
warn("error writing MBR");
- return (CMD_CONT);
+ return CMD_CONT;
}
if (letoh64(gh.gh_sig) == GPTSIGNATURE) {
efi = MBR_protective_mbr(mbr);
if (efi == -1 || GPT_write() == -1) {
warn("error writing GPT");
- return (CMD_CONT);
+ return CMD_CONT;
}
} else {
GPT_zap_headers();
/* Refresh in memory copy to reflect what was just written. */
MBR_parse(&dos_mbr, mbr->offset, mbr->reloffset, mbr);
- return (CMD_CLEAN);
+ return CMD_CLEAN;
}
int
Xquit(char *args, struct mbr *mbr)
{
- return (CMD_SAVE);
+ return CMD_SAVE;
}
int
int
Xexit(char *args, struct mbr *mbr)
{
- return (CMD_EXIT);
+ return CMD_EXIT;
}
int
printf("\t%s\t\t%s\n", cmd_table[i].cmd, help);
}
- return (CMD_CONT);
+ return CMD_CONT;
}
int
memcpy(mbr->code, initial_mbr.code, sizeof(mbr->code));
mbr->signature = DOSMBR_SIGNATURE;
printf("Machine code updated.\n");
- return (CMD_DIRTY);
+ return CMD_DIRTY;
}
int
pn = parsepn(part);
if (pn == -1)
- return (CMD_CONT);
+ return CMD_CONT;
if (flag != NULL) {
/* Set flag to value provided. */
val = strtonum(flag, 0, 0xff, &errstr);
if (errstr) {
printf("flag value is %s: %s.\n", errstr, flag);
- return (CMD_CONT);
+ return CMD_CONT;
}
if (letoh64(gh.gh_sig) == GPTSIGNATURE)
gp[pn].gp_attrs = htole64(val);
printf("Partition %d marked active.\n", pn);
}
- return (CMD_DIRTY);
+ return CMD_DIRTY;
}
int
signal(SIGPIPE, opipe);
- return (CMD_CONT);
+ return CMD_CONT;
}
-/* $OpenBSD: disk.c,v 1.57 2021/05/07 22:15:13 krw Exp $ */
+/* $OpenBSD: disk.c,v 1.58 2021/07/11 12:51:36 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
} else
printf("geometry: <none>\n");
- return (0);
+ return 0;
}
/*
where *= secsize;
off = lseek(disk.fd, where, SEEK_SET);
if (off != where)
- return (NULL);
+ return NULL;
secbuf = calloc(1, secsize);
if (secbuf == NULL)
- return (NULL);
+ return NULL;
len = read(disk.fd, secbuf, secsize);
if (len == -1 || len != secsize) {
free(secbuf);
- return (NULL);
+ return NULL;
}
- return (secbuf);
+ return secbuf;
}
/*
if (len == -1 || len != secsize) {
/* short read or write */
errno = EIO;
- return (-1);
+ return -1;
}
- return (0);
+ return 0;
}
-/* $OpenBSD: fdisk.c,v 1.114 2021/06/28 19:50:30 krw Exp $ */
+/* $OpenBSD: fdisk.c,v 1.115 2021/07/11 12:51:36 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
done:
close(disk.fd);
- return (0);
+ return 0;
}
-/* $OpenBSD: gpt.c,v 1.34 2021/06/28 19:50:30 krw Exp $ */
+/* $OpenBSD: gpt.c,v 1.35 2021/07/11 12:51:36 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
secbuf = DISK_readsector(where);
if (secbuf == 0)
- return (1);
+ return 1;
memcpy(&gh, secbuf, sizeof(struct gpt_header));
free(secbuf);
if (letoh64(gh.gh_sig) != GPTSIGNATURE) {
DPRINTF("gpt signature: expected 0x%llx, got 0x%llx\n",
GPTSIGNATURE, letoh64(gh.gh_sig));
- return (1);
+ return 1;
}
if (letoh32(gh.gh_rev) != GPTREVISION) {
DPRINTF("gpt revision: expected 0x%x, got 0x%x\n",
GPTREVISION, letoh32(gh.gh_rev));
- return (1);
+ return 1;
}
if (letoh64(gh.gh_lba_self) != where) {
DPRINTF("gpt self lba: expected %lld, got %llu\n",
(long long)where, letoh64(gh.gh_lba_self));
- return (1);
+ return 1;
}
if (letoh32(gh.gh_size) != GPTMINHDRSIZE) {
DPRINTF("gpt header size: expected %u, got %u\n",
GPTMINHDRSIZE, letoh32(gh.gh_size));
- return (1);
+ return 1;
}
if (letoh32(gh.gh_part_size) != GPTMINPARTSIZE) {
DPRINTF("gpt partition size: expected %u, got %u\n",
GPTMINPARTSIZE, letoh32(gh.gh_part_size));
- return (1);
+ return 1;
}
if (letoh32(gh.gh_part_num) > NGPTPARTITIONS) {
DPRINTF("gpt partition count: expected <= %u, got %u\n",
NGPTPARTITIONS, letoh32(gh.gh_part_num));
- return (1);
+ return 1;
}
orig_gh_csum = gh.gh_csum;
if (letoh32(orig_gh_csum) != new_gh_csum) {
DPRINTF("gpt header checksum: expected 0x%x, got 0x%x\n",
orig_gh_csum, new_gh_csum);
- return (1);
+ return 1;
}
/* XXX Assume part_num * part_size is multiple of secsize. */
if (letoh64(gh.gh_lba_start) >= letoh64(gh.gh_lba_end)) {
DPRINTF("gpt first usable LBA: expected < %llu, got %llu\n",
letoh64(gh.gh_lba_end), letoh64(gh.gh_lba_start));
- return (1);
+ return 1;
}
if (letoh64(gh.gh_part_lba) <= letoh64(gh.gh_lba_end) &&
DPRINTF("gpt partition table start lba: expected < %llu or "
"> %llu, got %llu\n", letoh64(gh.gh_lba_start),
letoh64(gh.gh_lba_end), letoh64(gh.gh_part_lba));
- return (1);
+ return 1;
}
partspersec = dl.d_secsize / letoh32(gh.gh_part_size);
DPRINTF("gpt partition table last LBA: expected < %llu or "
"> %llu, got %llu\n", letoh64(gh.gh_lba_start),
letoh64(gh.gh_lba_end), partlastlba);
- return (1);
+ return 1;
}
/*
* 2) partition table extends into lowest partition.
* 3) alt partition table starts before gh_lba_end.
*/
- return (0);
+ return 0;
}
int
if (partspersec * letoh32(gh.gh_part_size) != dl.d_secsize) {
DPRINTF("gpt partition table entry invalid size. %u\n",
letoh32(gh.gh_part_size));
- return (1);
+ return 1;
}
secs = (letoh32(gh.gh_part_num) + partspersec - 1) / partspersec;
if (off == -1) {
DPRINTF("seek to gpt partition table @ sector %llu failed\n",
(unsigned long long)where / dl.d_secsize);
- return (1);
+ return 1;
}
len = read(disk.fd, &gp, secs * dl.d_secsize);
if (len == -1 || len != secs * dl.d_secsize) {
DPRINTF("gpt partition table read failed.\n");
- return (1);
+ return 1;
}
checksum = crc32((unsigned char *)&gp, letoh32(gh.gh_part_num) *
if (checksum != letoh32(gh.gh_part_csum)) {
DPRINTF("gpt partition table checksum: expected %x, got %x\n",
checksum, letoh32(gh.gh_part_csum));
- return (1);
+ return 1;
}
- return (0);
+ return 0;
}
void
secbuf = DISK_readsector(prigh);
if (secbuf == NULL)
- return (-1);
+ return -1;
memcpy(secbuf, &gh, sizeof(gh));
DISK_writesector(secbuf, prigh);
secbuf = DISK_readsector(altgh);
if (secbuf == NULL)
- return (-1);
+ return -1;
memcpy(secbuf, &gh, sizeof(gh));
DISK_writesector(secbuf, altgh);
len = -1;
if (len == -1 || len != gpbytes) {
errno = EIO;
- return (-1);
+ return -1;
}
off = lseek(disk.fd, secsize * altgp, SEEK_SET);
if (len == -1 || len != gpbytes) {
errno = EIO;
- return (-1);
+ return -1;
}
/* Refresh in-kernel disklabel from the updated disk information. */
ioctl(disk.fd, DIOCRLDINFO, 0);
- return (0);
+ return 0;
}
int
}
}
- return (sgp);
+ return sgp;
}
int
-/* $OpenBSD: mbr.c,v 1.78 2021/07/04 20:37:11 krw Exp $ */
+/* $OpenBSD: mbr.c,v 1.79 2021/07/11 12:51:36 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
int i;
if (mbr->offset != 0)
- return (-1);
+ return -1;
for (i = 0; i < NDOSPART; i++) {
PRT_make(&mbr->part[i], mbr->offset, mbr->reloffset,
memcpy(&dp[i], &dos_partition, sizeof(dp[i]));
}
- return (gpt_chk_mbr(dp, DL_GETDSIZE(&dl)));
+ return gpt_chk_mbr(dp, DL_GETDSIZE(&dl));
}
void
secbuf = DISK_readsector(where);
if (secbuf == NULL)
- return (-1);
+ return -1;
memcpy(dos_mbr, secbuf, sizeof(*dos_mbr));
free(secbuf);
- return (0);
+ return 0;
}
int
secbuf = DISK_readsector(where);
if (secbuf == NULL)
- return (-1);
+ return -1;
/*
* Place the new MBR at the start of the sector and
free(secbuf);
- return (0);
+ return 0;
}
/*
}
}
if (found == 1 && eficnt == 1)
- return (efi);
+ return efi;
- return (-1);
+ return -1;
}
-/* $OpenBSD: misc.c,v 1.69 2021/06/25 19:24:53 krw Exp $ */
+/* $OpenBSD: misc.c,v 1.70 2021/07/11 12:51:36 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
int i = 0;
if (units == NULL)
- return (SECTORS);
+ return SECTORS;
while (unit_types[i].abbr != NULL) {
if (strncasecmp(unit_types[i].abbr, units, 1) == 0)
}
/* default */
if (unit_types[i].abbr == NULL)
- return (SECTORS);
+ return SECTORS;
- return (i);
+ return i;
}
int
len = getline(&line, &sz, stdin);
if (len == -1)
- return (1);
+ return 1;
if (line[len - 1] == '\n')
line[len - 1] = '\0';
strlcpy(buf, line, buflen);
- return (0);
+ return 0;
}
void
}
} while (errstr);
- return (num);
+ return num;
}
int
if (guid && strlen(lbuf) == UUID_STR_LEN) {
uuid_from_string(lbuf, guid, &status);
if (status == uuid_s_ok)
- return (0x100);
+ return 0x100;
}
/* Convert */
}
} while (num < 0 || num > 0xff);
- return (num);
+ return num;
}
int
extern int y_flag;
if (y_flag)
- return (1);
+ return 1;
printf("%s [n] ", str);
fflush(stdout);
if (ch == EOF || first == EOF)
errx(1, "eof");
- return (first == 'y' || first == 'Y');
+ return first == 'y' || first == 'Y';
}
/*
if (rslt < 0 || rslt >= sizeof(buf))
errx(1, "default value too long");
} else if (buf[0] == '*' && buf[1] == '\0') {
- return (maxval);
+ return maxval;
}
/* deal with units */
}
} while (1);
- return((uint64_t)d);
+ return (uint64_t)d;
}
char *
if (buf[0] == '\0' && oval)
strlcpy(buf, oval, sizeof(buf));
- return(buf);
+ return buf;
}
/*
if (i == GPTPARTNAMESIZE)
name[i - 1] = '\0';
- return (name);
+ return name;
}
uint16_t *
if (i == GPTPARTNAMESIZE)
utf[i - 1] = 0;
- return (utf);
+ return utf;
}
void
-/* $OpenBSD: part.c,v 1.87 2021/06/21 13:17:20 krw Exp $ */
+/* $OpenBSD: part.c,v 1.88 2021/07/11 12:51:36 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
for (i = 0; i < sizeof(part_types)/sizeof(struct part_type); i++) {
if (part_types[i].type == id)
- return (part_types[i].sname);
+ return part_types[i].sname;
}
- return (unknown);
+ return unknown;
}
void
(partn->esect >63) ||
(partn->ecyl > 1023) )
{
- return (0);
+ return 0;
}
- return (1);
+ return 1;
}
void
done:
free(uuidstr);
- return (partition_type);
+ return partition_type;
}
int
done:
free(uuidstr);
- return (type);
+ return type;
}
struct uuid *
if (i == entries || status != uuid_s_ok)
uuid_from_string(part_types[0].guid, &guid, &status);
- return (&guid);
+ return &guid;
}