[Monetdb-developers] [PATCH] Mx Io.c more specific errors

Fabian Groffen Fabian.Groffen at cwi.nl
Thu Aug 3 11:29:35 CEST 2006


Hi devs,

I ran into a problem with Mx, where IoWriteToFile seemed to have a
problem but didn't tell exactly what.  With the attached patch, I was
able to figure out what the problem was.  I don't like to commit it, as
the Mx code is completely unknown to me.  Also, I have no ideas on the
effects on this highly portable piece of code on Windows.  If someone
considers it useful to commit, please do.
-------------- next part --------------
--- Io.c
+++ Io.c
@@ -25,6 +25,7 @@
 #include "MxFcnDef.h"
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <errno.h>
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -204,7 +205,7 @@
 			    (p != fname + 2 || fname[1] != ':') &&
 #endif
 			    stat(fname, &buf) < 0 && mkdir(fname, S_IRWXU) < 0)
-				Fatal("fmustopen:", "Can't create directory %s\n", fname);
+				Fatal("fmustopen:", "Can't create directory %s:%s\n", fname, strerror(errno));
 			*p = DIR_SEP;
 		}
 	}
@@ -230,12 +231,12 @@
 	if ((f->f_mode & m) == m) {
 		ofile = fmustopen(f->f_tmp, "a");
 		if (ofile == NULL)
-			Fatal("IoWriteFile", "can't append to:%s", f->f_tmp);
+			Fatal("IoWriteFile", "can't append to %s: %s", f->f_tmp, strerror(errno));
 	} else {
 		f->f_mode |= m;
 		ofile = fmustopen(f->f_tmp, "w");
 		if (ofile == NULL)
-			Fatal("IoWriteFile", "can't create:%s", f->f_tmp);
+			Fatal("IoWriteFile", "can't create %s: %s", f->f_tmp, strerror(errno));
 		if (disclaimer)
 			insertDisclaimer(ofile, f->f_tmp);
 	}


More information about the developers-list mailing list