[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[debian-hurd-Patches][304464] ecl PATH_MAX



Patches item #304464, was opened at 10/02/2007 16:48
Status: Open
Priority: 3
Submitted By: Pierre THIERRY (nowhrman-guest)
Assigned to: Nobody (None)
Summary: ecl PATH_MAX 
Resolution: None
Group: unreviewed
Category: posix


Initial Comment:
ECL was relying on PATH_MAX or MAXPATHLEN be defined. Here is a preliminary patch:

diff -r 045b9347e44a src/c/main.d
--- a/src/c/main.d	Tue Feb 06 17:36:54 2007 +0100
+++ b/src/c/main.d	Sat Feb 10 16:08:38 2007 +0100
@@ -174,6 +174,8 @@ cl_boot(int argc, char **argv)
 	ARGV = argv;
 	ecl_self = argv[0];
 
+	path_max = sysconf(_PC_PATH_MAX);
+
 	init_alloc();
 	GC_disable();
 #ifdef ECL_THREADS
diff -r 045b9347e44a src/c/pathname.d
--- a/src/c/pathname.d	Tue Feb 06 17:36:54 2007 +0100
+++ b/src/c/pathname.d	Sat Feb 10 16:35:37 2007 +0100
@@ -29,8 +29,8 @@
 #ifndef MAXPATHLEN
 # ifdef PATH_MAX
 #   define MAXPATHLEN PATH_MAX
-# else
-#   error "Either MAXPATHLEN or PATH_MAX should be defined"
+//# else
+//#   error "Either MAXPATHLEN or PATH_MAX should be defined"
 # endif
 #endif
 
@@ -754,8 +754,13 @@ si_coerce_to_filename(cl_object pathname
 		FEerror("Pathname ~A does not have a physical namestring",
 			1, pathname_orig);
 	}
+#ifdef MAXPATHLEN
 	if (namestring->base_string.fillp >= MAXPATHLEN - 16)
+#else
+	if (path_max != -1 && namestring->base_string.fillp >= path_max - 16)
+#endif
 		FEerror("Too long filename: ~S.", 1, namestring);
+
 	return namestring;
 }
 
diff -r 045b9347e44a src/c/unixfsys.d
--- a/src/c/unixfsys.d	Tue Feb 06 17:36:54 2007 +0100
+++ b/src/c/unixfsys.d	Sat Feb 10 16:11:52 2007 +0100
@@ -49,8 +49,8 @@
 #ifndef MAXPATHLEN
 # ifdef PATH_MAX
 #   define MAXPATHLEN PATH_MAX
-# else
-#   error "Either MAXPATHLEN or PATH_MAX should be defined"
+//# else
+//#   error "Either MAXPATHLEN or PATH_MAX should be defined"
 # endif
 #endif
 
@@ -247,7 +247,15 @@ FILE *
 FILE *
 backup_fopen(const char *filename, const char *option)
 {
+#ifdef MAXPATHLEN
 	char backupfilename[MAXPATHLEN];
+#else
+	char *backupfilename = malloc(strlen(filename) + 5);
+	if (backupfilename == NULL) {
+		// not sure how allocation failure should be dealt with
+		FElibc_error("Cannot allocate memory for backup filename", 0);
+	}
+#endif
 
 	strcat(strcpy(backupfilename, filename), ".BAK");
 #ifdef _MSC_VER
@@ -258,6 +266,9 @@ backup_fopen(const char *filename, const
 	if (rename(filename, backupfilename))
 		FElibc_error("Cannot rename the file ~S to ~S.", 2,
 			     make_constant_base_string(filename), make_simple_base_string(backupfilename));
+#ifndef MAXPATHLEN
+	free(backupfilename);
+#endif
 	return fopen(filename, option);
 }
 
diff -r 045b9347e44a src/h/ecl.h
--- a/src/h/ecl.h	Tue Feb 06 17:36:54 2007 +0100
+++ b/src/h/ecl.h	Sat Feb 10 16:06:35 2007 +0100
@@ -15,6 +15,7 @@
 
 #ifndef _MSC_VER
 #include <sys/param.h>		/* includes <sys/signal.h> and <sys/types.h> */
+int path_max;
 #else
 #include <limits.h>
 #endif


----------------------------------------------------------------------

Comment By: Pierre THIERRY (nowhrman-guest)
Date: 11/02/2007 19:10

Message:
I received specific comments on this patch from an ECL maintainer, and made an improved version. I'll publish it when reviewed by people from ECL.

----------------------------------------------------------------------

You can respond by visiting: 
http://alioth.debian.org/tracker/?func=detail&atid=410472&aid=304464&group_id=30628



Reply to: