summaryrefslogtreecommitdiff
path: root/sbin/disklabel/disklabel.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2010-09-23 13:59:11 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2010-09-23 13:59:11 +0000
commit4a48051e162b8c01b75b51232afa5ec7fb0d89e6 (patch)
tree7fb460dbc5ac297894fce0c66d988a130ab14699 /sbin/disklabel/disklabel.c
parent7fdd2f645f69259da6f3791bd23898d143e7391a (diff)
Correctly identify mount points when they are specified in /etc/fstab using
a disklabel UID. Based on a diff from josh@elsasser.org. Resolves PR6471. ok krw@
Diffstat (limited to 'sbin/disklabel/disklabel.c')
-rw-r--r--sbin/disklabel/disklabel.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index a82360c05a6..24dbd6cafdd 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.172 2010/09/23 13:54:21 jsing Exp $ */
+/* $OpenBSD: disklabel.c,v 1.173 2010/09/23 13:59:10 jsing Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -121,9 +121,7 @@ main(int argc, char *argv[])
{
int ch, f, i, writeable, error = 0;
struct disklabel *lp;
- struct fstab *fsent;
FILE *t;
- char *partname;
while ((ch = getopt(argc, argv, "ABEf:hNRWb:cdenp:s:tvw")) != -1)
switch (ch) {
@@ -228,17 +226,6 @@ main(int argc, char *argv[])
if (f < 0)
err(4, "%s", specname);
- asprintf(&partname, "/dev/%s%c", dkname, 'a');
- setfsent();
- for (i = 0; i < MAXPARTITIONS; i++) {
- partname[strlen(dkname)+5] = 'a'+i;
- fsent = getfsspec(partname);
- if (fsent)
- mountpoints[i] = strdup(fsent->fs_file);
- }
- endfsent();
- free(partname);
-
switch (op) {
case EDIT:
if (argc != 1)
@@ -480,6 +467,10 @@ l_perror(char *s)
void
readlabel(int f)
{
+ char *partname, *partuid;
+ struct fstab *fsent;
+ int i;
+
if (cflag && ioctl(f, DIOCRLDINFO) < 0)
err(4, "ioctl DIOCRLDINFO");
@@ -491,6 +482,24 @@ readlabel(int f)
err(4, "ioctl DIOCGDINFO");
}
+ asprintf(&partname, "/dev/%s%c", dkname, 'a');
+ asprintf(&partuid, "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx.a",
+ lab.d_uid[0], lab.d_uid[1], lab.d_uid[2], lab.d_uid[3],
+ lab.d_uid[4], lab.d_uid[5], lab.d_uid[6], lab.d_uid[7]);
+ setfsent();
+ for (i = 0; i < MAXPARTITIONS; i++) {
+ partname[strlen(dkname) + 5] = 'a' + i;
+ partuid[strlen(partuid) - 1] = 'a' + i;
+ fsent = getfsspec(partname);
+ if (fsent == NULL)
+ fsent = getfsspec(partuid);
+ if (fsent)
+ mountpoints[i] = strdup(fsent->fs_file);
+ }
+ endfsent();
+ free(partuid);
+ free(partname);
+
if (aflag)
editor_allocspace(&lab);
}