emacs-diffs
[Top][All Lists]
Advanced

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

master 7dfe90a: Adapt the MS-Windows build to 'nofollow' changes


From: Eli Zaretskii
Subject: master 7dfe90a: Adapt the MS-Windows build to 'nofollow' changes
Date: Mon, 24 Feb 2020 11:18:16 -0500 (EST)

branch: master
commit 7dfe90a666ab6b90597e3ee61c141da088da340c
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Adapt the MS-Windows build to 'nofollow' changes
    
    * nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_fchmodat)
    (OMIT_GNULIB_MODULE_lchmod): Set to true to omit building these
    modules on MS-Windows.
    * nt/mingw-cfg.site (ac_cv_func_fchmodat)
    (gl_cv_func_fchmodat_works, ac_cv_func_lchmod): Disable tests on
    MS-Windows.
    
    * src/w32.c (chmod_worker, lchmod, fchmodat): New functions.
    (sys_chmod): Move most of the code to chmod_worker.
    * src/w32.h (fchmodat, lchmod): Add prototypes.
---
 nt/gnulib-cfg.mk  |  2 ++
 nt/mingw-cfg.site |  3 +++
 src/w32.c         | 41 ++++++++++++++++++++++++++++++++++++++---
 src/w32.h         |  2 ++
 4 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/nt/gnulib-cfg.mk b/nt/gnulib-cfg.mk
index 08e83e0..1d120a9 100644
--- a/nt/gnulib-cfg.mk
+++ b/nt/gnulib-cfg.mk
@@ -63,3 +63,5 @@ OMIT_GNULIB_MODULE_sys_time = true
 OMIT_GNULIB_MODULE_sys_types = true
 OMIT_GNULIB_MODULE_unistd = true
 OMIT_GNULIB_MODULE_canonicalize-lgpl = true
+OMIT_GNULIB_MODULE_fchmodat = true
+OMIT_GNULIB_MODULE_lchmod = true
diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site
index dfdca39..5bd5b83 100644
--- a/nt/mingw-cfg.site
+++ b/nt/mingw-cfg.site
@@ -102,6 +102,9 @@ ac_cv_func_lstat=yes
 gl_cv_func_lstat_dereferences_slashed_symlink=yes
 ac_cv_func_fstatat=yes
 gl_cv_func_fstatat_zero_flag=yes
+ac_cv_func_fchmodat=yes
+gl_cv_func_fchmodat_works="not-needed-so-yes"
+ac_cv_func_lchmod=yes
 # Aliased to _commit in ms-w32.h
 ac_cv_func_fsync=yes
 ac_cv_func_fdatasync=yes
diff --git a/src/w32.c b/src/w32.c
index a3b9a56..cf1a3b3 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -4320,10 +4320,9 @@ sys_chdir (const char * path)
     }
 }
 
-int
-sys_chmod (const char * path, int mode)
+static int
+chmod_worker (const char * path, int mode)
 {
-  path = chase_symlinks (map_w32_filename (path, NULL));
   if (w32_unicode_filenames)
     {
       wchar_t path_w[MAX_PATH];
@@ -4341,6 +4340,20 @@ sys_chmod (const char * path, int mode)
 }
 
 int
+sys_chmod (const char * path, int mode)
+{
+  path = chase_symlinks (map_w32_filename (path, NULL));
+  return chmod_worker (path, mode);
+}
+
+int
+lchmod (const char * path, mode_t mode)
+{
+  path = map_w32_filename (path, NULL);
+  return chmod_worker (path, mode);
+}
+
+int
 sys_creat (const char * path, int mode)
 {
   path = map_w32_filename (path, NULL);
@@ -4619,6 +4632,28 @@ fchmod (int fd, mode_t mode)
 }
 
 int
+fchmodat (int fd, char const *path, mode_t mode, int flags)
+{
+  /* Rely on a hack: an open directory is modeled as file descriptor 0,
+     as in fstatat.  FIXME: Add proper support for fchmodat.  */
+  char fullname[MAX_UTF8_PATH];
+
+  if (fd != AT_FDCWD)
+    {
+      if (_snprintf (fullname, sizeof fullname, "%s/%s", dir_pathname, path)
+         < 0)
+       {
+         errno = ENAMETOOLONG;
+         return -1;
+       }
+      path = fullname;
+    }
+
+  return
+    flags == AT_SYMLINK_NOFOLLOW ? lchmod (path, mode) : sys_chmod (path, 
mode);
+}
+
+int
 sys_rename_replace (const char *oldname, const char *newname, BOOL force)
 {
   BOOL result;
diff --git a/src/w32.h b/src/w32.h
index f301b38..cf1dadf 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -222,6 +222,8 @@ extern void register_child (pid_t, int);
 extern void sys_sleep (int);
 extern int sys_link (const char *, const char *);
 extern int openat (int, const char *, int, int);
+extern int fchmodat (int, char const *, mode_t, int);
+extern int lchmod (char const *, mode_t);
 
 /* Return total and free memory info.  */
 extern int w32_memory_info (unsigned long long *, unsigned long long *,



reply via email to

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