emacs-diffs
[Top][All Lists]
Advanced

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

master 6662079b90 1/3: Merge from origin/emacs-28


From: Paul Eggert
Subject: master 6662079b90 1/3: Merge from origin/emacs-28
Date: Sun, 17 Apr 2022 16:24:54 -0400 (EDT)

branch: master
commit 6662079b9025d437477e58a81af994a6513d7408
Merge: 1dd8a00325 3cccf0a910
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    Merge from origin/emacs-28
    
    3cccf0a910 Don’t assume openat
---
 lib-src/emacsclient.c |  3 +--
 src/sysdep.c          | 29 ++++++++++++++++++-----------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 7406ef3490..73c8e45a86 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1431,8 +1431,7 @@ local_sockname (int s, char sockname[socknamesize], int 
tmpdirlen,
   char *emacsdirend = sockname + tmpdirlen + suffixlen -
     strlen(server_name) - 1;
   *emacsdirend = '\0';
-  int dir = openat (AT_FDCWD, sockname,
-                   O_PATH | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
+  int dir = open (sockname, O_PATH | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
   *emacsdirend = '/';
   if (dir < 0)
     return errno;
diff --git a/src/sysdep.c b/src/sysdep.c
index 87a6365de6..36636d0ed5 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -2330,6 +2330,20 @@ emacs_fstatat (int dirfd, char const *filename, void 
*st, int flags)
   return r;
 }
 
+static int
+sys_openat (int dirfd, char const *file, int oflags, int mode)
+{
+#ifdef O_PATH
+  return openat (dirfd, file, oflags, mode);
+#else
+  /* On platforms without O_PATH, emacs_openat's callers arrange for
+     DIRFD to be AT_FDCWD, so it should be safe to just call 'open'.
+     This ports to old platforms like OS X 10.9 that lack openat.  */
+  eassert (dirfd == AT_FDCWD);
+  return open (file, oflags, mode);
+#endif
+}
+
 /* Assuming the directory DIRFD, open FILE for Emacs use,
    using open flags OFLAGS and mode MODE.
    Use binary I/O on systems that care about text vs binary I/O.
@@ -2345,7 +2359,7 @@ emacs_openat (int dirfd, char const *file, int oflags, 
int mode)
   if (! (oflags & O_TEXT))
     oflags |= O_BINARY;
   oflags |= O_CLOEXEC;
-  while ((fd = openat (dirfd, file, oflags, mode)) < 0 && errno == EINTR)
+  while ((fd = sys_openat (dirfd, file, oflags, mode)) < 0 && errno == EINTR)
     maybe_quit ();
   return fd;
 }
@@ -2358,26 +2372,19 @@ emacs_open (char const *file, int oflags, int mode)
 
 /* Same as above, but doesn't allow the user to quit.  */
 
-static int
-emacs_openat_noquit (int dirfd, const char *file, int oflags,
-                     int mode)
+int
+emacs_open_noquit (char const *file, int oflags, int mode)
 {
   int fd;
   if (! (oflags & O_TEXT))
     oflags |= O_BINARY;
   oflags |= O_CLOEXEC;
   do
-    fd = openat (dirfd, file, oflags, mode);
+    fd = open (file, oflags, mode);
   while (fd < 0 && errno == EINTR);
   return fd;
 }
 
-int
-emacs_open_noquit (char const *file, int oflags, int mode)
-{
-  return emacs_openat_noquit (AT_FDCWD, file, oflags, mode);
-}
-
 /* Open FILE as a stream for Emacs use, with mode MODE.
    Act like emacs_open with respect to threads, signals, and quits.  */
 



reply via email to

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