From mrg at fhcrc.org  Thu Aug 20 22:00:25 2009
From: mrg at fhcrc.org (mrg at fhcrc.org)
Date: Thu, 20 Aug 2009 22:00:25 +0200 (CEST)
Subject: [Rd] header containing (PR#13834)
Message-ID: <20090820200026.253632831FF8@mail.pubhealth.ku.dk>


This problem arises on Solaris because apparently Solaris 10 returns the 
error "ENOSYS" when you try to make a directory on an automount point 
(translates to "unsupported file system operation").

The R mkdir function invokes do_dircreate in platform.c.  The logic in 
this function, when the recursive option is set, attempts to mkdir() all 
of the antecedent elements of the directory, including directories that 
may already exist.  The function is configured to therefore ignore the 
"eexist" error returned when do_dircreate attempts to create a directory 
that already exists.

The problem thus arises when the directory is, in fact, an automount 
point.  Linux returns "eexist" and works.  Solaris returns "enosys" and 
thus fails.

I was able to get this to work as expected by updating the check on the 
error returned to include enosys as an ignored error:

bash$ diff -C 4 R-2.9.1-orig/src/main/platform.c R-2.9.1/src/main/platform.c

*** R-2.9.1-orig/src/main/platform.c    Sun Mar 22 20:05:03 2009
--- R-2.9.1/src/main/platform.c Thu Aug 20 12:32:15 2009
***************
*** 1960,1968 ****
         p = dir;
         while ((p = Rf_strchr(p+1, '/'))) {
             *p = '\0';
             res = mkdir(dir, mode);
!           if (res && errno != EEXIST) goto end;
             *p = '/';
         }
       }
       res = mkdir(dir, mode);
--- 1960,1968 ----
         p = dir;
         while ((p = Rf_strchr(p+1, '/'))) {
             *p = '\0';
             res = mkdir(dir, mode);
!           if (res && ( errno != EEXIST && errno != ENOSYS )) goto end;
             *p = '/';
         }
       }
       res = mkdir(dir, mode);

I suppose the other way to "fix" this would be to redo the logic to test 
for the existance of the directory before attempting to create it. 
Probably gets clunky.

Anyway, I'm not sure of the appropriate way to include this as a patch. 
I don't know if there's an existing way to "ifdef" this alteration for 
solaris only or if the update is generic enough to not cause problems on 
other platforms.  I saw a couple other projects implementing recursive 
mkdir that just assume enosys isn't fatal and continue on.

Let me know if I can be of further assistance.

Thanks

Michael

---
Michael Gutteridge            Fred Hutchinson CRC
Sr. System Architect          1100 Fairview Ave N
mrg at fhcrc.org                 Mailstop J2-225
                               Seattle, WA 98109



[Rd] header containing (PR#13834)
mrg at fhcrc.org