Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] Use gdbm_errno with gdbm_open



Hello,
there was one report about gdbm_open() failing. The patch uses gdbm_errno / gdbm_strerror() to know what exactly happened. I've checked that it works:

ztie: error opening database file /Users/sgniazdowski/db3 (Can't be writer)

– after ztie to already opened database. I hope Airmail will not mess up the patch. It is also attached.

Sebastian Gniazdowski
psprint [at] zdharma.org

diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c
index 596a8ae..0a28a07 100644
--- a/Src/Modules/db_gdbm.c
+++ b/Src/Modules/db_gdbm.c
@@ -154,12 +154,13 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
 	    return 1;
     }
 
+    gdbm_errno=0;
     dbf = gdbm_open(resource_name, 0, read_write, 0666, 0);
     if(dbf) {
 	addmodulefd(gdbm_fdesc(dbf), FDT_MODULE);
         append_tied_name(pmname);
     } else {
-	zwarnnam(nam, "error opening database file %s", resource_name);
+	zwarnnam(nam, "error opening database file %s (%s)", resource_name, gdbm_strerror(gdbm_errno));
 	return 1;
     }
 

Attachment: gdbm_errno.diff
Description: Binary data



Messages sorted by: Reverse Date, Date, Thread, Author