bug-gnulib
[Top][All Lists]
Advanced

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

apparent complexity of mkdir-p module (was: Re: dirchownmod and savewd m


From: John W. Eaton
Subject: apparent complexity of mkdir-p module (was: Re: dirchownmod and savewd modules uses unavailable functions under) Windows
Date: Thu, 7 Jun 2012 08:09:48 -0400

On  7-Jun-2012, Paul Eggert wrote:

| Much of gnulib has never been ported to MSVC / MingW
| and apparently octave is using that part.  I suggest
| using Cygwin.

If it were up to me, I'd go a step further and say, "don't use
Windows," but the reality is that that's not going to fly with many of
Octave's users and developers.  (insert emoticon of your choosing
here).

Octave already uses quite a few modules from gnulib (see list at the
bottom of this message) and up until now, it is working on Windows
systems with MinGW and MSVC.  So it seems a lot of things do work on
those systems.  The use of mkdir-p is a recent addition and is not
critical, so for now I've removed the patch that added that module to
Octave.

In any case, I am curious about the design of this module.  Could
someone shed some light on why it is so complex, and why that
complexity is exposed?  Looking at mkdir-p.h, I was quite surprised to
find that the only function it declares is

  struct savewd;
  bool make_dir_parents (char *dir,
                         struct savewd *wd,
                         int (*make_ancestor) (char const *, char const *,
                                               void *),
                         void *options,
                         mode_t mode,
                         void (*announce) (char const *, void *),
                         mode_t mode_bits,
                         uid_t owner,
                         gid_t group,
                         bool preserve_existing);

I was expecting to find a simple interface that covers what I would
think is the most common case of creating a directory tree: do exactly
the same thing as mkdir, but iterate over the directories given (as a
string, separated by DIRSEP):

  int mkdir_with_parents (const char *dirname, mode_t mode)

At least on the surface, this seems like a simple operation.  But
looking into the implementation of mkdir-p, I was even more surprised
when I found that the mkancesdirs and savewd modules that it depends
on ultimately call fork.

I admit to never having looked into implementing this operation in a
robust way, so perhaps all this complexity is required.  But it would
definitely help mere mortals to use mkdir-p if there were a simpler
way to use this module for what I assume is the most common use case.

jwe


Here is the module list printed by a bootstrap run in Octave's source tree:

  Module list with included dependencies (indented):
      alloca
      alloca-opt
      at-internal
      c-ctype
    c-strcase
      canonicalize-lgpl
      chdir
      chdir-long
      cloexec
      close
    closedir
      configmake
    copysign
    copysignf
    crypto/md5
      d-ino
      d-type
      dirent
      dirfd
      dirname-lgpl
      dosname
      double-slash-root
      dup
      dup2
      errno
      error
      exitfail
      extensions
      fchdir
    fclose
    fcntl
      fcntl-h
      fd-hook
      fdopendir
    fflush
    filemode
      filename
      filenamecat-lgpl
      float
      floor
    fnmatch
    fopen
      fpieee
      fpurge
      freading
    fseek
      fseeko
      fstat
      fstatat
    ftell
      ftello
    getcwd
      getcwd-lgpl
      getdtablesize
    gethostname
      getlogin_r
    getopt-gnu
      getopt-posix
      gettext-h
    gettimeofday
    glob
      include_next
      intprops
    isatty
      isnand-nolibm
      isnanf-nolibm
      isnanl-nolibm
      largefile
    link
      localcharset
      lseek
    lstat
      malloc-posix
      malloca
      math
      mbrtowc
      mbsinit
      mbsrtowcs
      memchr
      mempcpy
      memrchr
    mkdir
    mkfifo
    mkostemp
    mkstemp
    mktime
      msvc-inval
      msvc-nothrow
      multiarch
    nanosleep
      nocrash
    nproc
      open
      openat
      openat-die
      openat-h
    opendir
    pathmax
    progname
      raise
    readdir
    readlink
      realloc-posix
    rename
    rewinddir
    rmdir
    round
    roundf
      same-inode
      save-cwd
      select
    sigaction
    signal
      signal-h
      signbit
    sigprocmask
      size_max
    sleep
      snippet/_Noreturn
      snippet/arg-nonnull
      snippet/c++defs
      snippet/warn-on-use
      socketlib
      sockets
      socklen
      ssize_t
    stat
      stdalign
      stdbool
      stddef
    stdint
    stdio
      stdlib
      strcase
      strdup-posix
      streq
      strerror
      strerror-override
    strftime
      string
      strings
      strnlen1
    strptime
    symlink
      sys_select
      sys_socket
    sys_stat
    sys_time
    sys_times
      sys_types
      sys_uio
      tempname
    time
      time_r
    times
      tmpdir
    tmpfile
    trunc
    truncf
    unistd
      unistd-safer
    unlink
      vasnprintf
    vasprintf
      verify
      wchar
      wctype-h
      xsize



reply via email to

[Prev in Thread] Current Thread [Next in Thread]