From: krw Date: Fri, 11 Jun 2021 16:22:46 +0000 (+0000) Subject: Add local functions edit() and setpid(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f05f27a778c31b6bd873efb536e955c6020b597d;p=openbsd 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. --- 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)); @@ -288,6 +282,21 @@ done: return (CMD_CONT); } +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) { @@ -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]; @@ -349,6 +351,21 @@ Xsetpid(char *args, struct mbr *mbr) return (CMD_DIRTY); } +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) {