summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-03-18 04:36:23 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-03-18 04:36:23 +0000
commit53d51af8d97788ada70cdd5583f3c51a2f444336 (patch)
tree1f02dffbaea9be14ce56a67c3c0ad4b887d98c0d
parent09240b41a0ab92c6deff86a3ded09dcbd45366fa (diff)
make sure mountpoint starts with '/' and call get_mp() from editor_name() instead of rolling our own
-rw-r--r--sbin/disklabel/editor.c61
1 files changed, 27 insertions, 34 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index b7967c54d05..844b3b0077c 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.52 1999/03/18 01:59:20 millert Exp $ */
+/* $OpenBSD: editor.c,v 1.53 1999/03/18 04:36:22 millert Exp $ */
/*
* Copyright (c) 1997-1999 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -28,7 +28,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: editor.c,v 1.52 1999/03/18 01:59:20 millert Exp $";
+static char rcsid[] = "$OpenBSD: editor.c,v 1.53 1999/03/18 04:36:22 millert Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -615,23 +615,7 @@ editor_name(lp, mp, p)
return;
}
- p = getstring(lp, "mount point",
- "Where to mount this filesystem (ie: / /var /usr)",
- mp[partno] ? mp[partno] : "none");
- if (p == NULL) {
- fputs("Command aborted\n", stderr);
- pp->p_size = 0; /* effective delete */
- return;
- }
- if (mp[partno] != NULL) {
- free(mp[partno]);
- mp[partno] = NULL;
- }
- if (strcasecmp(p, "none") != 0) {
- /* XXX - check that it starts with '/' */
- if ((mp[partno] = strdup(p)) == NULL)
- errx(4, "out of memory");
- }
+ get_mp(lp, mp, partno);
}
/*
@@ -2233,21 +2217,30 @@ get_mp(lp, mp, partno)
if (mp != NULL && pp->p_fstype != FS_UNUSED &&
pp->p_fstype != FS_SWAP && pp->p_fstype != FS_BOOT &&
pp->p_fstype != FS_OTHER) {
- p = getstring(lp, "mount point",
- "Where to mount this filesystem (ie: / /var /usr)",
- mp[partno] ? mp[partno] : "none");
- if (p == NULL) {
- fputs("Command aborted\n", stderr);
- return(1);
- }
- if (mp[partno] != NULL) {
- free(mp[partno]);
- mp[partno] = NULL;
- }
- if (strcasecmp(p, "none") != 0) {
- /* XXX - check that it starts with '/' */
- if ((mp[partno] = strdup(p)) == NULL)
- errx(4, "out of memory");
+ for (;;) {
+ p = getstring(lp, "mount point",
+ "Where to mount this filesystem (ie: / /var /usr)",
+ mp[partno] ? mp[partno] : "none");
+ if (p == NULL) {
+ fputs("Command aborted\n", stderr);
+ return(1);
+ }
+ if (strcasecmp(p, "none") == 0) {
+ if (mp[partno] != NULL) {
+ free(mp[partno]);
+ mp[partno] = NULL;
+ }
+ break;
+ }
+ if (*p == '/') {
+ /* XXX - might as well realloc */
+ if (mp[partno] != NULL)
+ free(mp[partno]);
+ if ((mp[partno] = strdup(p)) == NULL)
+ errx(4, "out of memory");
+ break;
+ }
+ fputs("Mount points must start with '/'\n", stderr);
}
}
return(0);