fixed detection of errors on open
authorewt <devnull@localhost>
Tue, 9 Jan 1996 21:50:43 +0000 (21:50 +0000)
committerewt <devnull@localhost>
Tue, 9 Jan 1996 21:50:43 +0000 (21:50 +0000)
CVS patchset: 186
CVS date: 1996/01/09 21:50:43

lib/dbindex.c

index 367490d..28612e7 100644 (file)
@@ -1,4 +1,5 @@
 #include <db.h>
+#include <errno.h>
 #include <stdlib.h>
 #include <strings.h>
 
@@ -11,10 +12,11 @@ dbIndex * openDBIndex(char * filename, int flags, int perms) {
     db = malloc(sizeof(*db));
     db->indexname = strdup(filename);
     db->db = dbopen(filename, flags, perms, DB_HASH, NULL);
-    if (!db) {
+    if (!db->db) {
        free(db->indexname);
        free(db);
-       error(RPMERR_DBOPEN, "cannot open file %s filename");
+       error(RPMERR_DBOPEN, "cannot open file %s: ", filename, 
+                             strerror(errno));
        return NULL;
     }