diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2009-05-03 22:01:47 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2009-05-03 22:01:47 +0000 |
commit | 76f41a467495ead3a95906f5a46d9c9ec863a92b (patch) | |
tree | 391c38fb05c11c2d3472631c32852612ccc80ad9 | |
parent | bd74198d1bacda9a7174aa132a93f922df4cfe4f (diff) |
Prevent the entry of duplicate mount points while in Editor mode.
ok deraadt@
-rw-r--r-- | sbin/disklabel/editor.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index d3224fc8e38..4704e126782 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.202 2009/05/03 16:49:16 deraadt Exp $ */ +/* $OpenBSD: editor.c,v 1.203 2009/05/03 22:01:46 krw Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com> @@ -17,7 +17,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: editor.c,v 1.202 2009/05/03 16:49:16 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: editor.c,v 1.203 2009/05/03 22:01:46 krw Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -2121,8 +2121,9 @@ get_fstype(struct disklabel *lp, int partno) int get_mp(struct disklabel *lp, int partno) { - char *p; struct partition *pp = &lp->d_partitions[partno]; + char *p; + int i; if (fstabfile && pp->p_fstype != FS_UNUSED && pp->p_fstype != FS_SWAP && pp->p_fstype != FS_BOOT && @@ -2140,6 +2141,14 @@ get_mp(struct disklabel *lp, int partno) mountpoints[partno] = NULL; break; } + for (i = 0; i < MAXPARTITIONS; i++) + if (mountpoints[i] != NULL && + 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]); |