guile-1.8.8-mkdir-mask.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. --- a/libguile/filesys.c 2016-11-05 15:03:52.131894648 +0100
  2. +++ b/libguile/filesys.c 2016-11-05 15:07:13.275894481 +0100
  3. @@ -791,24 +791,18 @@
  4. SCM_DEFINE (scm_mkdir, "mkdir", 1, 1, 0,
  5. (SCM path, SCM mode),
  6. "Create a new directory named by @var{path}. If @var{mode} is omitted\n"
  7. - "then the permissions of the directory file are set using the current\n"
  8. - "umask. Otherwise they are set to the decimal value specified with\n"
  9. - "@var{mode}. The return value is unspecified.")
  10. + "then the permissions of the directory are set to @code{#o777}\n"
  11. + "masked with the current umask (@pxref{Processes, @code{umask}}).\n"
  12. + "Otherwise they are set to the value specified with @var{mode}.\n"
  13. + "The return value is unspecified.")
  14. #define FUNC_NAME s_scm_mkdir
  15. {
  16. int rv;
  17. - mode_t mask;
  18. + mode_t c_mode;
  19. - if (SCM_UNBNDP (mode))
  20. - {
  21. - mask = umask (0);
  22. - umask (mask);
  23. - STRING_SYSCALL (path, c_path, rv = mkdir (c_path, 0777 ^ mask));
  24. - }
  25. - else
  26. - {
  27. - STRING_SYSCALL (path, c_path, rv = mkdir (c_path, scm_to_uint (mode)));
  28. - }
  29. + c_mode = SCM_UNBNDP (mode) ? 0777 : scm_to_uint (mode);
  30. +
  31. + STRING_SYSCALL (path, c_path, rv = mkdir (c_path, c_mode));
  32. if (rv != 0)
  33. SCM_SYSERROR;
  34. return SCM_UNSPECIFIED;