summaryrefslogtreecommitdiff
path: root/sbin/fdisk/cmd.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2021-06-11 16:22:47 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2021-06-11 16:22:47 +0000
commiteb066f545d62b497fd865950279ae4279344e7ba (patch)
treeebdbfe8b54d0deb8ab895890d41f9aacd7798db9 /sbin/fdisk/cmd.c
parent87268072dc8425f97fd52dbe3cb9e5aef10b4fc3 (diff)
Add local functions edit() and setpid().
Reduce Xedit()/Xsetpid() to parsing the partition number and invoking [g]edit()/[g]setpid() appropriately. No intentional functional change.
Diffstat (limited to 'sbin/fdisk/cmd.c')
-rw-r--r--sbin/fdisk/cmd.c57
1 files changed, 37 insertions, 20 deletions
diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c
index 1485ef10c76..e60d9ac0fad 100644
--- a/sbin/fdisk/cmd.c
+++ b/sbin/fdisk/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.111 2021/06/11 14:02:22 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.112 2021/06/11 16:22:46 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -38,7 +38,9 @@
int reinited;
int gedit(int);
+int edit(int, struct mbr *);
int gsetpid(int);
+int setpid(int, struct mbr *);
int parsepn(char *);
int
@@ -227,23 +229,15 @@ parsepn(char *pnstr)
}
int
-Xedit(char *args, struct mbr *mbr)
+edit(int pn, struct mbr *mbr)
{
struct prt oldpp;
struct prt *pp;
- int pn;
-
- pn = parsepn(args);
- if (pn == -1)
- return (CMD_CONT);
-
- if (letoh64(gh.gh_sig) == GPTSIGNATURE)
- return (gedit(pn));
pp = &mbr->part[pn];
oldpp = *pp;
- Xsetpid(args, mbr);
+ setpid(pn, mbr);
if (pp->id == DOSPTYP_UNUSED) {
if (oldpp.id != DOSPTYP_UNUSED) {
memset(pp, 0, sizeof(*pp));
@@ -289,6 +283,21 @@ done:
}
int
+Xedit(char *args, struct mbr *mbr)
+{
+ int pn;
+
+ pn = parsepn(args);
+ if (pn == -1)
+ return (CMD_CONT);
+
+ if (letoh64(gh.gh_sig) == GPTSIGNATURE)
+ return (gedit(pn));
+ else
+ return (edit(pn, mbr));
+}
+
+int
gsetpid(int pn)
{
struct uuid guid;
@@ -321,17 +330,10 @@ gsetpid(int pn)
}
int
-Xsetpid(char *args, struct mbr *mbr)
+setpid(int pn, struct mbr *mbr)
{
struct prt *pp;
- int pn, num;
-
- pn = parsepn(args);
- if (pn == -1)
- return (CMD_CONT);
-
- if (letoh64(gh.gh_sig) == GPTSIGNATURE)
- return (gsetpid(pn));
+ int num;
pp = &mbr->part[pn];
@@ -350,6 +352,21 @@ Xsetpid(char *args, struct mbr *mbr)
}
int
+Xsetpid(char *args, struct mbr *mbr)
+{
+ int pn;
+
+ pn = parsepn(args);
+ if (pn == -1)
+ return (CMD_CONT);
+
+ if (letoh64(gh.gh_sig) == GPTSIGNATURE)
+ return (gsetpid(pn));
+ else
+ return (setpid(pn, mbr));
+}
+
+int
Xselect(char *args, struct mbr *mbr)
{
static off_t firstoff = 0;