Module Name:    src
Committed By:   mrg
Date:           Sun Apr 19 10:19:26 UTC 2009

Modified Files:
        src/lib/libc/gen: devname.c

Log Message:
add some code to cope with dev.db's that have 32 bit time_t's in them.

shouldn't be relevant very much as dev.db should be re-created at boot,
but it helped me at least twice so far...


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libc/gen/devname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/devname.c
diff -u src/lib/libc/gen/devname.c:1.19 src/lib/libc/gen/devname.c:1.20
--- src/lib/libc/gen/devname.c:1.19	Tue Jan 20 18:20:48 2009
+++ src/lib/libc/gen/devname.c	Sun Apr 19 10:19:26 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: devname.c,v 1.19 2009/01/20 18:20:48 drochner Exp $	*/
+/*	$NetBSD: devname.c,v 1.20 2009/04/19 10:19:26 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = "@(#)devname.c	8.2 (Berkeley) 4/29/95";
 #else
-__RCSID("$NetBSD: devname.c,v 1.19 2009/01/20 18:20:48 drochner Exp $");
+__RCSID("$NetBSD: devname.c,v 1.20 2009/04/19 10:19:26 mrg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -108,6 +108,10 @@
 		mode_t type;
 		dev_t dev;
 	} bkey;
+	struct {
+		mode_t type;
+		int32_t dev;
+	} obkey;
 	static DB *db;
 	static int failure;
 	DBT data, key;
@@ -154,6 +158,7 @@
 	key.data = &bkey;
 	key.size = sizeof(bkey);
 	if ((db->get)(db, &key, &data, 0) == 0) {
+found_it:
 		if (ptr == NULL)
 			return (char *)data.data;
 		ptr->dev = dev;
@@ -162,6 +167,15 @@
 		ptr->name[NAME_MAX - 1] = '\0';
 		ptr->valid = VALID;
 	} else {
+		/* Look for a 32 bit dev_t. */
+		(void)memset(&obkey, 0, sizeof(obkey));
+		obkey.dev = (int32_t)(uint32_t)dev;
+		obkey.type = type;
+		key.data = &obkey;
+		key.size = sizeof(obkey);
+		if ((db->get)(db, &key, &data, 0) == 0)
+			goto found_it;
+
 		if (ptr == NULL)
 			return (NULL);
 		ptr->valid = INVALID;

Reply via email to