>Number: 6471
>Category: system
>Synopsis: disklabel(8) does not recognize <UID>.x partition names when
>parsing /etc/fstab
>Confidential: yes
>Severity: serious
>Priority: medium
>Responsible: bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: unknown
>Arrival-Date: Sun Sep 19 17:40:01 GMT 2010
>Closed-Date:
>Last-Modified:
>Originator:
>Release:
>Organization:
>Environment:
System : OpenBSD 4.8
Details : OpenBSD 4.8 (GENERIC) #26: Thu Sep 16 07:24:17 PDT 2010
[email protected]:/usr/src/sys/arch/i386/compile/GENERIC
Architecture: OpenBSD.i386
Machine : i386
>Description:
The disklabel(8) program will normally parse /etc/fstab and
later, when printing the partition list, show the mountpoint from
/etc/fstab. The new <UID>.x format for fstab is not recognized,
however.
>How-To-Repeat:
disk=wd0
uid=`disklabel $disk | sed -n 's/^uid: //p'`
disklabel $disk
mv /etc/fstab /etc/fstab.bak
sed "s|^/dev/${disk}|${uid}.|" < /etc/fstab.bak > /etc/fstab
disklabel $disk
>Fix:
Index: disklabel.c
===================================================================
RCS file: /cvsroot/src/sbin/disklabel/disklabel.c,v
retrieving revision 1.171
diff -u -r1.171 disklabel.c
--- disklabel.c 12 Aug 2010 23:32:07 -0000 1.171
+++ disklabel.c 19 Sep 2010 16:50:17 -0000
@@ -115,15 +115,14 @@
int cmplabel(struct disklabel *, struct disklabel *);
void usage(void);
u_int64_t getnum(char *, u_int64_t, u_int64_t, const char **);
+void uid_format(char *, size_t, struct disklabel *);
int
main(int argc, char *argv[])
{
- int ch, f, i, writeable, error = 0;
+ int ch, f, 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 +227,6 @@
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 +468,11 @@
void
readlabel(int f)
{
+ struct fstab *fsent;
+ char partuid[sizeof(lab.d_uid)*2+3];
+ char *partname;
+ int i;
+
if (cflag && ioctl(f, DIOCRLDINFO) < 0)
err(4, "ioctl DIOCRLDINFO");
@@ -491,6 +484,22 @@
err(4, "ioctl DIOCGDINFO");
}
+ asprintf(&partname, "/dev/%s%c", dkname, 'a');
+ uid_format(partuid, sizeof(partuid), &lab);
+ strlcat(partuid, ".a", sizeof(partuid));
+ setfsent();
+ for (i = 0; i < MAXPARTITIONS; i++) {
+ partname[strlen(dkname)+5] = 'a'+i;
+ partuid[sizeof(partuid)-2] = 'a'+i;
+ fsent = getfsspec(partname);
+ if (fsent == NULL)
+ fsent = getfsspec(partuid);
+ if (fsent)
+ mountpoints[i] = strdup(fsent->fs_file);
+ }
+ endfsent();
+ free(partname);
+
if (aflag)
editor_allocspace(&lab);
}
@@ -983,6 +992,19 @@
for (i = 0; i < sizeof(lp->d_uid); i++)
fprintf(f, "%c%c", hex[(lp->d_uid[i] >> 4) & 0xf],
hex[lp->d_uid[i] & 0xf]);
+}
+
+void
+uid_format(char *s, size_t size, struct disklabel *lp)
+{
+ char hex[] = "0123456789abcdef";
+ int i;
+
+ for (i = 0; i < sizeof(lp->d_uid) && i * 2 < size - 2; i++) {
+ s[i*2] = hex[(lp->d_uid[i] >> 4) & 0xf];
+ s[i*2+1] = hex[lp->d_uid[i] & 0xf];
+ }
+ s[i*2] = '\0';
}
int
>Release-Note:
>Audit-Trail:
>Unformatted: