[Rd] header containing (PR#13834)

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Aug 21 16:52:43 CEST 2009


Thank you, that's a plausible explanation and probably also explains 
PR#13899.

However, it's not listed by POSIX (not even a 'may fail') at
http://www.opengroup.org/onlinepubs/009695399/functions/mkdir.html
and 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.

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

On Thu, 20 Aug 2009, mrg at fhcrc.org wrote:

>
> 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").

It is supposed to mean 'function not implemented'.

> 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
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list