Mathieu Lirzin <m...@gnu.org> skribis: > l...@gnu.org (Ludovic Courtès) writes: > >> Mathieu Lirzin <m...@gnu.org> skribis: >> >>> I have tried to apply this change (add an optional parameter) on top of >>> Guix, but it produces a ton of failures for ‘make check’ :). >> >> What’s the failure exactly? > > > ====================================== > GNU Guix 0.9.1: ./test-suite.log > ======================================
[...] > ?: 2 [primitive-load > "/home/mthl/src/gnu/guix/test-tmp/store/zx9l2f7cgfwabmslfcxzvli07qaikma1-module-import-builder"] > In srfi/srfi-1.scm: > 619: 1 [for-each #<procedure 1168fc0 at ice-9/eval.scm:416:20 (a)> (#)] > In ice-9/eval.scm: > 432: 0 [eval # #] > > ice-9/eval.scm:432:17: In procedure eval: > ice-9/eval.scm:432:17: In procedure mkdir: Permission denied My guess is that we end up creating parent directories that lack the execute or write bits, which prevents ‘mkdir-p’ from creating the child directories. >>> So my conclusion is that it is not possible to set a default value. So I >>> think it required to do something like: >>> >>> (define* (mkdir-p dir #:optional mode) >>> ... >>> (if mode >>> (mkdir path mode) >>> (mkdir path)) >>> ...) >>> >>> Am I correct? >> >> That would work… but why do we need ‘mode’ in the first place? > > Shepherd config user directories are created with #o700 permissions. > Since it is possible to set an arbitrary value in XDG_CONFIG_HOME, my > understanding was that Shepherd is supposed to try to create the > directory composing this directory name if they don't exist. So to > create them It is convenient to have a MODE argument for ‘mkdir-p’. Right, it makes sense in this particular case. >> It seems that the semantics are fuzzy, because the result may differ >> depending on which components of DIR already exist when ‘mkdir-p’ is >> called, and the user can just set the process’ umask before calling it. >> >> WDYT? > > I don't know. mkdir(1) let the users do it, so I guess it makes sense > to handle the case. Yes, but it only applies to the last component: --8<---------------cut here---------------start------------->8--- $ mkdir -p -m 500 a/b/c/d $ ls -ld a a/b a/b/c a/b/c/d drwxr-xr-x 3 ludo users 4096 Jan 18 22:06 a drwxr-xr-x 3 ludo users 4096 Jan 18 22:06 a/b drwxr-xr-x 3 ludo users 4096 Jan 18 22:06 a/b/c dr-x------ 2 ludo users 4096 Jan 18 22:06 a/b/c/d --8<---------------cut here---------------end--------------->8--- Ludo’.