From b308f3d45d71fb5203b31f11dde306981ab9cf65 Mon Sep 17 00:00:00 2001 From: krw Date: Thu, 30 Aug 2018 12:30:08 +0000 Subject: [PATCH] Never let FS_RAID partition be named, a.k.a. given a mount point. Nuke pointless and inconsistant error message before one get_mp() invocation. ok otto@ --- sbin/disklabel/editor.c | 78 ++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index 59d1b6aef11..5412b178ca2 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.346 2018/08/28 12:40:54 krw Exp $ */ +/* $OpenBSD: editor.c,v 1.347 2018/08/30 12:30:08 krw Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller @@ -945,15 +945,6 @@ editor_name(struct disklabel *lp, char *p) return; } - /* Not all fstypes can be named */ - if (pp->p_fstype == FS_UNUSED || pp->p_fstype == FS_SWAP || - pp->p_fstype == FS_BOOT || pp->p_fstype == FS_OTHER || - pp->p_fstype == FS_RAID) { - fprintf(stderr, "You cannot name a filesystem of type %s.\n", - fstypenames[lp->d_partitions[partno].p_fstype]); - return; - } - get_mp(lp, partno); } @@ -2124,39 +2115,46 @@ get_mp(struct disklabel *lp, int partno) char *p; int i; - if (fstabfile && pp->p_fstype != FS_UNUSED && - pp->p_fstype != FS_SWAP && pp->p_fstype != FS_BOOT && - pp->p_fstype != FS_OTHER) { - for (;;) { - p = getstring("mount point", - "Where to mount this filesystem (ie: / /var /usr)", - mountpoints[partno] ? mountpoints[partno] : "none"); - if (p == NULL) - return (1); - if (strcasecmp(p, "none") == 0) { - free(mountpoints[partno]); - mountpoints[partno] = NULL; - break; - } - for (i = 0; i < MAXPARTITIONS; i++) - if (mountpoints[i] != NULL && i != partno && - strcmp(p, mountpoints[i]) == 0) - break; - if (i < MAXPARTITIONS) { - fprintf(stderr, "'%c' already being mounted at " - "'%s'\n", 'a'+i, p); - break; - } - if (*p == '/') { - /* XXX - might as well realloc */ - free(mountpoints[partno]); - if ((mountpoints[partno] = strdup(p)) == NULL) - errx(4, "out of memory"); + if (fstabfile == NULL || + pp->p_fstype == FS_UNUSED || + pp->p_fstype == FS_SWAP || + pp->p_fstype == FS_BOOT || + pp->p_fstype == FS_OTHER || + pp->p_fstype == FS_RAID) { + /* No fstabfile, no names. Not all fstypes can be named */ + return 0; + } + + for (;;) { + p = getstring("mount point", + "Where to mount this filesystem (ie: / /var /usr)", + mountpoints[partno] ? mountpoints[partno] : "none"); + if (p == NULL) + return (1); + if (strcasecmp(p, "none") == 0) { + free(mountpoints[partno]); + mountpoints[partno] = NULL; + break; + } + for (i = 0; i < MAXPARTITIONS; i++) + if (mountpoints[i] != NULL && i != partno && + strcmp(p, mountpoints[i]) == 0) break; - } - fputs("Mount points must start with '/'\n", stderr); + if (i < MAXPARTITIONS) { + fprintf(stderr, "'%c' already being mounted at " + "'%s'\n", 'a'+i, p); + break; + } + if (*p == '/') { + /* XXX - might as well realloc */ + free(mountpoints[partno]); + if ((mountpoints[partno] = strdup(p)) == NULL) + errx(4, "out of memory"); + break; } + fputs("Mount points must start with '/'\n", stderr); } + return (0); } -- 2.20.1