On Fri, 21 Aug 2009, Prof Brian Ripley wrote:

... nor is it described on man -s2 mkdir on my Solaris 10 system, so it is not surprising that we didn't know about it.

Yep- I see the lack of documentation reported as a bug on opensolaris:

http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6738185

Though FSM knows when they'll update the manpage.

My slight concern is that ENOSYS might not be defined on some other OS, but I've not found one and POSIX requires it.

This is sort of why I'd thought it might be best to have this ENOSYS check done on Solaris only. Since it seems to work everywhere else, isolate this change to Solaris only.

I've attached a patch I've developed that seems to work in our environment. I do use defines to do platform detection in this patch.

Copy this patch inside the source directory and run:

 solaris$ gpatch -p 1 -i platform.patch"

Michael
--- R-2.9.1-orig/src/main/platform.c	2009-03-22 20:05:03.000000000 -0700
+++ R-2.9.1/src/main/platform.c	2009-08-25 16:17:14.548685000 -0700
@@ -33,6 +33,12 @@
 # include <errno.h>
 #endif
 
+#if defined(sun) || defined(__sun)
+#  if defined(__SVR4) || defined (__svr4__) 
+#		define _IS_SOLARIS 1
+#  endif
+#endif
+
 /* Machine Constants */
 
 static void Init_R_Machine(SEXP rho)
@@ -1956,21 +1962,33 @@
     /* remove trailing slashes */
     p = dir + strlen(dir) - 1;
     while (*p == '/' && strlen(dir) > 1) *p-- = '\0';
+
     if (recursive) {
-	p = dir;
-	while ((p = Rf_strchr(p+1, '/'))) {
-	    *p = '\0';
-	    res = mkdir(dir, mode);
-	    if (res && errno != EEXIST) goto end;
-	    *p = '/';
-	}
-    }
+			p = dir;
+			while ((p = Rf_strchr(p+1, '/'))) {
+					*p = '\0';
+					errno = 0 ;
+					res = mkdir(dir, mode);
+#if defined(_IS_SOLARIS)
+					if (res && ( errno != EEXIST && errno != ENOSYS )) goto end;
+#else
+					if (res && errno != EEXIST) goto end;
+#endif
+
+					*p = '/';
+			}
+		}
+		errno = 0 ;
     res = mkdir(dir, mode);
+#if defined(_IS_SOLARIS)
+    if (show && res && ( errno == EEXIST && errno == ENOSYS ))
+#else
     if (show && res && errno == EEXIST)
-	warning(_("'%s' already exists"), dir);
+#endif
+			warning(_("'%s' already exists"), dir);
 end:
     if (show && res && errno != EEXIST)
-	warning(_("cannot create dir '%s', reason '%s'"), dir, strerror(errno));
+			warning(_("cannot create dir '%s', reason '%s'"), dir, strerror(errno));
     return ScalarLogical(res == 0);
 }
 #else /* Win32 */
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to