Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libutil In COMPAT_DKWEDGE, attempt to open the label as ...
details: https://anonhg.NetBSD.org/src/rev/b3d4e15b0dac
branches: trunk
changeset: 329454:b3d4e15b0dac
user: christos <christos%NetBSD.org@localhost>
date: Sun May 25 13:46:07 2014 +0000
description:
In COMPAT_DKWEDGE, attempt to open the label as specified in the NAME= entry.
This works for BSD disklabels, providing full compatibility. Merge some
duplicated code. This means that at least for BSD labels, we can handle
both pre and post- autodiscover kernels with the same fstab.
diffstat:
lib/libutil/getfsspecname.c | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
diffs (72 lines):
diff -r 060a3929b0d2 -r b3d4e15b0dac lib/libutil/getfsspecname.c
--- a/lib/libutil/getfsspecname.c Sun May 25 13:45:39 2014 +0000
+++ b/lib/libutil/getfsspecname.c Sun May 25 13:46:07 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getfsspecname.c,v 1.4 2013/01/01 18:32:17 dsl Exp $ */
+/* $NetBSD: getfsspecname.c,v 1.5 2014/05/25 13:46:07 christos Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: getfsspecname.c,v 1.4 2013/01/01 18:32:17 dsl Exp $");
+__RCSID("$NetBSD: getfsspecname.c,v 1.5 2014/05/25 13:46:07 christos Exp $");
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -53,13 +53,12 @@
{
static const int mib[] = { CTL_HW, HW_DISKNAMES };
static const unsigned int miblen = __arraycount(mib);
- char *drives, *dk;
+ char *drives, *dk, *p;
size_t len;
- int fd, savee;
+ int fd, savee = errno;
char *vname;
- drives = NULL;
- vname = NULL;
+ p = drives = vname = NULL;
if (strncasecmp(name, "NAME=", 5) != 0) {
#ifdef COMPAT_DKWEDGE
/*
@@ -129,20 +128,28 @@
}
(void)close(fd);
if (strcmp(vname, (char *)dkw.dkw_wname) == 0) {
- char *p = strstr(buf, "/rdk");
- if (p++ == NULL)
- return buf;
- strcpy(p, p + 1);
- free(drives);
- free(vname);
- return buf;
+ p = strstr(buf, "/rdk");
+ goto good;
}
}
+#ifdef COMPAT_DKWEDGE
+ /* Last ditch effort assuming NAME=label, and label is a disk name */
+ fd = opendisk(name, O_RDONLY, buf, bufsiz, 0);
+ if (fd != -1) {
+ close(fd);
+ p = strstr(buf, "/r");
+ goto good;
+ }
+#endif
savee = ESRCH;
snprintf(buf, bufsiz, "no match for `%s'", vname);
out:
+ buf = NULL;
+good:
+ if (p++ != NULL)
+ strcpy(p, p + 1);
free(drives);
free(vname);
errno = savee;
- return NULL;
+ return buf;
}
Home |
Main Index |
Thread Index |
Old Index