diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 29 | ||||
| -rw-r--r-- | src/Makefile.in | 3 | ||||
| -rw-r--r-- | src/callproc.c | 4 | ||||
| -rw-r--r-- | src/charset.c | 3 | ||||
| -rw-r--r-- | src/conf_post.h | 4 | ||||
| -rw-r--r-- | src/fileio.c | 97 | ||||
| -rw-r--r-- | src/lisp.h | 1 | ||||
| -rw-r--r-- | src/lread.c | 56 | ||||
| -rw-r--r-- | src/process.c | 36 | ||||
| -rw-r--r-- | src/sysdep.c | 6 | ||||
| -rw-r--r-- | src/term.c | 4 | ||||
| -rw-r--r-- | src/w32.c | 18 | ||||
| -rw-r--r-- | src/xrdb.c | 8 |
13 files changed, 137 insertions, 132 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ee18650e992..5a1b4a5d8ee 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,32 +1,3 @@ | |||
| 1 | 2012-10-19 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Use faccessat, not access, when checking file permissions (Bug#12632). | ||
| 4 | * Makefile.in (LIB_EACCESS): New macro. | ||
| 5 | (LIBES): Use it. | ||
| 6 | * callproc.c (init_callproc): | ||
| 7 | * charset.c (init_charset): | ||
| 8 | * fileio.c (check_existing, check_executable): | ||
| 9 | * lread.c (openp, load_path_check): | ||
| 10 | * process.c (allocate_pty): | ||
| 11 | * xrdb.c (file_p): | ||
| 12 | Use faccessat, not access or euidaccess. Use symbolic names | ||
| 13 | instead of integers for the flags, as they're portable now. | ||
| 14 | * charset.c, xrdb.c: Include <fcntl.h>, for the new flags used. | ||
| 15 | * fileio.c (Ffile_readable_p): | ||
| 16 | Use faccessat, not stat + open + close. | ||
| 17 | (file_directory_p): New function, which uses 'stat' on most places | ||
| 18 | but 'access' (for efficiency) if WINDOWSNT. | ||
| 19 | * fileio.c (Ffile_directory_p, Fset_file_times): | ||
| 20 | * xrdb.c (file_p): Use file_directory_p. | ||
| 21 | * lisp.h (file_directory_p): New decl. | ||
| 22 | * lread.c (openp): When opening a file, use fstat rather than | ||
| 23 | stat, as that avoids a permissions race. When not opening a file, | ||
| 24 | use file_directory_p rather than stat. | ||
| 25 | * process.c, sysdep.c, term.c: All uses of '#ifdef O_NONBLOCK' | ||
| 26 | changed to '#if O_NONBLOCK', to accommodate gnulib O_* style. | ||
| 27 | * w32.c (sys_faccessat): Rename from sys_access and switch to | ||
| 28 | faccessat's API. All uses changed. | ||
| 29 | |||
| 30 | 2012-10-19 Kazuhiro Ito <kzhr@d1.dion.ne.jp> (tiny change) | 1 | 2012-10-19 Kazuhiro Ito <kzhr@d1.dion.ne.jp> (tiny change) |
| 31 | 2 | ||
| 32 | * font.c (Ffont_at): Fix previous change. | 3 | * font.c (Ffont_at): Fix previous change. |
diff --git a/src/Makefile.in b/src/Makefile.in index d034ad04796..c24e421bbbc 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -150,7 +150,6 @@ M17N_FLT_CFLAGS = @M17N_FLT_CFLAGS@ | |||
| 150 | M17N_FLT_LIBS = @M17N_FLT_LIBS@ | 150 | M17N_FLT_LIBS = @M17N_FLT_LIBS@ |
| 151 | 151 | ||
| 152 | LIB_CLOCK_GETTIME=@LIB_CLOCK_GETTIME@ | 152 | LIB_CLOCK_GETTIME=@LIB_CLOCK_GETTIME@ |
| 153 | LIB_EACCESS=@LIB_EACCESS@ | ||
| 154 | LIB_TIMER_TIME=@LIB_TIMER_TIME@ | 153 | LIB_TIMER_TIME=@LIB_TIMER_TIME@ |
| 155 | 154 | ||
| 156 | DBUS_CFLAGS = @DBUS_CFLAGS@ | 155 | DBUS_CFLAGS = @DBUS_CFLAGS@ |
| @@ -393,7 +392,7 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \ | |||
| 393 | LIBES = $(LIBS) $(W32_LIBS) $(LIBX_BASE) $(LIBIMAGE) \ | 392 | LIBES = $(LIBS) $(W32_LIBS) $(LIBX_BASE) $(LIBIMAGE) \ |
| 394 | $(LIBX_OTHER) $(LIBSOUND) \ | 393 | $(LIBX_OTHER) $(LIBSOUND) \ |
| 395 | $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \ | 394 | $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \ |
| 396 | $(LIB_EACCESS) $(LIB_TIMER_TIME) $(DBUS_LIBS) \ | 395 | $(LIB_TIMER_TIME) $(DBUS_LIBS) \ |
| 397 | $(LIB_EXECINFO) \ | 396 | $(LIB_EXECINFO) \ |
| 398 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ | 397 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ |
| 399 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ | 398 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ |
diff --git a/src/callproc.c b/src/callproc.c index 5a9b32f08c3..b33882e54c2 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -1597,13 +1597,13 @@ init_callproc (void) | |||
| 1597 | #endif | 1597 | #endif |
| 1598 | { | 1598 | { |
| 1599 | tempdir = Fdirectory_file_name (Vexec_directory); | 1599 | tempdir = Fdirectory_file_name (Vexec_directory); |
| 1600 | if (faccessat (AT_FDCWD, SSDATA (tempdir), F_OK, AT_EACCESS) != 0) | 1600 | if (access (SSDATA (tempdir), 0) < 0) |
| 1601 | dir_warning ("Warning: arch-dependent data dir (%s) does not exist.\n", | 1601 | dir_warning ("Warning: arch-dependent data dir (%s) does not exist.\n", |
| 1602 | Vexec_directory); | 1602 | Vexec_directory); |
| 1603 | } | 1603 | } |
| 1604 | 1604 | ||
| 1605 | tempdir = Fdirectory_file_name (Vdata_directory); | 1605 | tempdir = Fdirectory_file_name (Vdata_directory); |
| 1606 | if (faccessat (AT_FDCWD, SSDATA (tempdir), F_OK, AT_EACCESS) != 0) | 1606 | if (access (SSDATA (tempdir), 0) < 0) |
| 1607 | dir_warning ("Warning: arch-independent data dir (%s) does not exist.\n", | 1607 | dir_warning ("Warning: arch-independent data dir (%s) does not exist.\n", |
| 1608 | Vdata_directory); | 1608 | Vdata_directory); |
| 1609 | 1609 | ||
diff --git a/src/charset.c b/src/charset.c index fe068e1d3bc..6b999824dab 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 28 | 28 | ||
| 29 | #define CHARSET_INLINE EXTERN_INLINE | 29 | #define CHARSET_INLINE EXTERN_INLINE |
| 30 | 30 | ||
| 31 | #include <fcntl.h> | ||
| 32 | #include <stdio.h> | 31 | #include <stdio.h> |
| 33 | #include <unistd.h> | 32 | #include <unistd.h> |
| 34 | #include <limits.h> | 33 | #include <limits.h> |
| @@ -2294,7 +2293,7 @@ init_charset (void) | |||
| 2294 | { | 2293 | { |
| 2295 | Lisp_Object tempdir; | 2294 | Lisp_Object tempdir; |
| 2296 | tempdir = Fexpand_file_name (build_string ("charsets"), Vdata_directory); | 2295 | tempdir = Fexpand_file_name (build_string ("charsets"), Vdata_directory); |
| 2297 | if (faccessat (AT_FDCWD, SSDATA (tempdir), F_OK, AT_EACCESS) != 0) | 2296 | if (access (SSDATA (tempdir), 0) < 0) |
| 2298 | { | 2297 | { |
| 2299 | /* This used to be non-fatal (dir_warning), but it should not | 2298 | /* This used to be non-fatal (dir_warning), but it should not |
| 2300 | happen, and if it does sooner or later it will cause some | 2299 | happen, and if it does sooner or later it will cause some |
diff --git a/src/conf_post.h b/src/conf_post.h index eade536e6e1..aa008107ba6 100644 --- a/src/conf_post.h +++ b/src/conf_post.h | |||
| @@ -169,10 +169,6 @@ extern void _DebPrint (const char *fmt, ...); | |||
| 169 | #endif | 169 | #endif |
| 170 | #endif | 170 | #endif |
| 171 | 171 | ||
| 172 | /* Tell gnulib to omit support for openat-related functions having a | ||
| 173 | first argument other than AT_FDCWD. */ | ||
| 174 | #define GNULIB_SUPPORT_ONLY_AT_FDCWD | ||
| 175 | |||
| 176 | #include <string.h> | 172 | #include <string.h> |
| 177 | #include <stdlib.h> | 173 | #include <stdlib.h> |
| 178 | 174 | ||
diff --git a/src/fileio.c b/src/fileio.c index 3accb58a3eb..d47d7dd9e0b 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2425,7 +2425,15 @@ On Unix, this is a name starting with a `/' or a `~'. */) | |||
| 2425 | bool | 2425 | bool |
| 2426 | check_existing (const char *filename) | 2426 | check_existing (const char *filename) |
| 2427 | { | 2427 | { |
| 2428 | return faccessat (AT_FDCWD, filename, F_OK, AT_EACCESS) == 0; | 2428 | #ifdef DOS_NT |
| 2429 | /* The full emulation of Posix 'stat' is too expensive on | ||
| 2430 | DOS/Windows, when all we want to know is whether the file exists. | ||
| 2431 | So we use 'access' instead, which is much more lightweight. */ | ||
| 2432 | return (access (filename, F_OK) >= 0); | ||
| 2433 | #else | ||
| 2434 | struct stat st; | ||
| 2435 | return (stat (filename, &st) >= 0); | ||
| 2436 | #endif | ||
| 2429 | } | 2437 | } |
| 2430 | 2438 | ||
| 2431 | /* Return true if file FILENAME exists and can be executed. */ | 2439 | /* Return true if file FILENAME exists and can be executed. */ |
| @@ -2433,7 +2441,21 @@ check_existing (const char *filename) | |||
| 2433 | static bool | 2441 | static bool |
| 2434 | check_executable (char *filename) | 2442 | check_executable (char *filename) |
| 2435 | { | 2443 | { |
| 2436 | return faccessat (AT_FDCWD, filename, X_OK, AT_EACCESS) == 0; | 2444 | #ifdef DOS_NT |
| 2445 | struct stat st; | ||
| 2446 | if (stat (filename, &st) < 0) | ||
| 2447 | return 0; | ||
| 2448 | return ((st.st_mode & S_IEXEC) != 0); | ||
| 2449 | #else /* not DOS_NT */ | ||
| 2450 | #ifdef HAVE_EUIDACCESS | ||
| 2451 | return (euidaccess (filename, 1) >= 0); | ||
| 2452 | #else | ||
| 2453 | /* Access isn't quite right because it uses the real uid | ||
| 2454 | and we really want to test with the effective uid. | ||
| 2455 | But Unix doesn't give us a right way to do it. */ | ||
| 2456 | return (access (filename, 1) >= 0); | ||
| 2457 | #endif | ||
| 2458 | #endif /* not DOS_NT */ | ||
| 2437 | } | 2459 | } |
| 2438 | 2460 | ||
| 2439 | /* Return true if file FILENAME exists and can be written. */ | 2461 | /* Return true if file FILENAME exists and can be written. */ |
| @@ -2442,16 +2464,15 @@ static bool | |||
| 2442 | check_writable (const char *filename) | 2464 | check_writable (const char *filename) |
| 2443 | { | 2465 | { |
| 2444 | #ifdef MSDOS | 2466 | #ifdef MSDOS |
| 2445 | /* FIXME: an faccessat implementation should be added to the | ||
| 2446 | DOS/Windows ports and this #ifdef branch should be removed. */ | ||
| 2447 | struct stat st; | 2467 | struct stat st; |
| 2448 | if (stat (filename, &st) < 0) | 2468 | if (stat (filename, &st) < 0) |
| 2449 | return 0; | 2469 | return 0; |
| 2450 | return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode)); | 2470 | return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode)); |
| 2451 | #else /* not MSDOS */ | 2471 | #else /* not MSDOS */ |
| 2452 | bool res = faccessat (AT_FDCWD, filename, W_OK, AT_EACCESS) == 0; | 2472 | #ifdef HAVE_EUIDACCESS |
| 2473 | bool res = (euidaccess (filename, 2) >= 0); | ||
| 2453 | #ifdef CYGWIN | 2474 | #ifdef CYGWIN |
| 2454 | /* faccessat may have returned failure because Cygwin couldn't | 2475 | /* euidaccess may have returned failure because Cygwin couldn't |
| 2455 | determine the file's UID or GID; if so, we return success. */ | 2476 | determine the file's UID or GID; if so, we return success. */ |
| 2456 | if (!res) | 2477 | if (!res) |
| 2457 | { | 2478 | { |
| @@ -2462,6 +2483,14 @@ check_writable (const char *filename) | |||
| 2462 | } | 2483 | } |
| 2463 | #endif /* CYGWIN */ | 2484 | #endif /* CYGWIN */ |
| 2464 | return res; | 2485 | return res; |
| 2486 | #else /* not HAVE_EUIDACCESS */ | ||
| 2487 | /* Access isn't quite right because it uses the real uid | ||
| 2488 | and we really want to test with the effective uid. | ||
| 2489 | But Unix doesn't give us a right way to do it. | ||
| 2490 | Opening with O_WRONLY could work for an ordinary file, | ||
| 2491 | but would lose for directories. */ | ||
| 2492 | return (access (filename, 2) >= 0); | ||
| 2493 | #endif /* not HAVE_EUIDACCESS */ | ||
| 2465 | #endif /* not MSDOS */ | 2494 | #endif /* not MSDOS */ |
| 2466 | } | 2495 | } |
| 2467 | 2496 | ||
| @@ -2518,6 +2547,9 @@ See also `file-exists-p' and `file-attributes'. */) | |||
| 2518 | { | 2547 | { |
| 2519 | Lisp_Object absname; | 2548 | Lisp_Object absname; |
| 2520 | Lisp_Object handler; | 2549 | Lisp_Object handler; |
| 2550 | int desc; | ||
| 2551 | int flags; | ||
| 2552 | struct stat statbuf; | ||
| 2521 | 2553 | ||
| 2522 | CHECK_STRING (filename); | 2554 | CHECK_STRING (filename); |
| 2523 | absname = Fexpand_file_name (filename, Qnil); | 2555 | absname = Fexpand_file_name (filename, Qnil); |
| @@ -2529,8 +2561,31 @@ See also `file-exists-p' and `file-attributes'. */) | |||
| 2529 | return call2 (handler, Qfile_readable_p, absname); | 2561 | return call2 (handler, Qfile_readable_p, absname); |
| 2530 | 2562 | ||
| 2531 | absname = ENCODE_FILE (absname); | 2563 | absname = ENCODE_FILE (absname); |
| 2532 | return (faccessat (AT_FDCWD, SSDATA (absname), R_OK, AT_EACCESS) == 0 | 2564 | |
| 2533 | ? Qt : Qnil); | 2565 | #if defined (DOS_NT) || defined (macintosh) |
| 2566 | /* Under MS-DOS, Windows, and Macintosh, open does not work for | ||
| 2567 | directories. */ | ||
| 2568 | if (access (SDATA (absname), 0) == 0) | ||
| 2569 | return Qt; | ||
| 2570 | return Qnil; | ||
| 2571 | #else /* not DOS_NT and not macintosh */ | ||
| 2572 | flags = O_RDONLY; | ||
| 2573 | #ifdef O_NONBLOCK | ||
| 2574 | /* Opening a fifo without O_NONBLOCK can wait. | ||
| 2575 | We don't want to wait. But we don't want to mess wth O_NONBLOCK | ||
| 2576 | except in the case of a fifo, on a system which handles it. */ | ||
| 2577 | desc = stat (SSDATA (absname), &statbuf); | ||
| 2578 | if (desc < 0) | ||
| 2579 | return Qnil; | ||
| 2580 | if (S_ISFIFO (statbuf.st_mode)) | ||
| 2581 | flags |= O_NONBLOCK; | ||
| 2582 | #endif | ||
| 2583 | desc = emacs_open (SSDATA (absname), flags, 0); | ||
| 2584 | if (desc < 0) | ||
| 2585 | return Qnil; | ||
| 2586 | emacs_close (desc); | ||
| 2587 | return Qt; | ||
| 2588 | #endif /* not DOS_NT and not macintosh */ | ||
| 2534 | } | 2589 | } |
| 2535 | 2590 | ||
| 2536 | /* Having this before file-symlink-p mysteriously caused it to be forgotten | 2591 | /* Having this before file-symlink-p mysteriously caused it to be forgotten |
| @@ -2567,7 +2622,7 @@ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0, | |||
| 2567 | /* The read-only attribute of the parent directory doesn't affect | 2622 | /* The read-only attribute of the parent directory doesn't affect |
| 2568 | whether a file or directory can be created within it. Some day we | 2623 | whether a file or directory can be created within it. Some day we |
| 2569 | should check ACLs though, which do affect this. */ | 2624 | should check ACLs though, which do affect this. */ |
| 2570 | return file_directory_p (SDATA (dir)) ? Qt : Qnil; | 2625 | return (access (SDATA (dir), D_OK) < 0) ? Qnil : Qt; |
| 2571 | #else | 2626 | #else |
| 2572 | return (check_writable (!NILP (dir) ? SSDATA (dir) : "") | 2627 | return (check_writable (!NILP (dir) ? SSDATA (dir) : "") |
| 2573 | ? Qt : Qnil); | 2628 | ? Qt : Qnil); |
| @@ -2648,7 +2703,8 @@ Symbolic links to directories count as directories. | |||
| 2648 | See `file-symlink-p' to distinguish symlinks. */) | 2703 | See `file-symlink-p' to distinguish symlinks. */) |
| 2649 | (Lisp_Object filename) | 2704 | (Lisp_Object filename) |
| 2650 | { | 2705 | { |
| 2651 | Lisp_Object absname; | 2706 | register Lisp_Object absname; |
| 2707 | struct stat st; | ||
| 2652 | Lisp_Object handler; | 2708 | Lisp_Object handler; |
| 2653 | 2709 | ||
| 2654 | absname = expand_and_dir_to_file (filename, BVAR (current_buffer, directory)); | 2710 | absname = expand_and_dir_to_file (filename, BVAR (current_buffer, directory)); |
| @@ -2661,20 +2717,9 @@ See `file-symlink-p' to distinguish symlinks. */) | |||
| 2661 | 2717 | ||
| 2662 | absname = ENCODE_FILE (absname); | 2718 | absname = ENCODE_FILE (absname); |
| 2663 | 2719 | ||
| 2664 | return file_directory_p (SSDATA (absname)) ? Qt : Qnil; | 2720 | if (stat (SSDATA (absname), &st) < 0) |
| 2665 | } | 2721 | return Qnil; |
| 2666 | 2722 | return S_ISDIR (st.st_mode) ? Qt : Qnil; | |
| 2667 | /* Return true if FILE is a directory or a symlink to a directory. */ | ||
| 2668 | bool | ||
| 2669 | file_directory_p (char const *file) | ||
| 2670 | { | ||
| 2671 | #ifdef WINDOWSNT | ||
| 2672 | /* This is cheaper than 'stat'. */ | ||
| 2673 | return faccessat (AT_FDCWD, file, D_OK, AT_EACCESS) == 0; | ||
| 2674 | #else | ||
| 2675 | struct stat st; | ||
| 2676 | return stat (file, &st) == 0 && S_ISDIR (st.st_mode); | ||
| 2677 | #endif | ||
| 2678 | } | 2723 | } |
| 2679 | 2724 | ||
| 2680 | DEFUN ("file-accessible-directory-p", Ffile_accessible_directory_p, | 2725 | DEFUN ("file-accessible-directory-p", Ffile_accessible_directory_p, |
| @@ -2999,8 +3044,10 @@ Use the current time if TIMESTAMP is nil. TIMESTAMP is in the format of | |||
| 2999 | if (set_file_times (-1, SSDATA (encoded_absname), t, t)) | 3044 | if (set_file_times (-1, SSDATA (encoded_absname), t, t)) |
| 3000 | { | 3045 | { |
| 3001 | #ifdef MSDOS | 3046 | #ifdef MSDOS |
| 3047 | struct stat st; | ||
| 3048 | |||
| 3002 | /* Setting times on a directory always fails. */ | 3049 | /* Setting times on a directory always fails. */ |
| 3003 | if (file_directory_p (SSDATA (encoded_absname))) | 3050 | if (stat (SSDATA (encoded_absname), &st) == 0 && S_ISDIR (st.st_mode)) |
| 3004 | return Qnil; | 3051 | return Qnil; |
| 3005 | #endif | 3052 | #endif |
| 3006 | report_file_error ("Setting file times", Fcons (absname, Qnil)); | 3053 | report_file_error ("Setting file times", Fcons (absname, Qnil)); |
diff --git a/src/lisp.h b/src/lisp.h index 897757cf462..01f6ca5e57c 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3178,7 +3178,6 @@ extern Lisp_Object close_file_unwind (Lisp_Object); | |||
| 3178 | extern Lisp_Object restore_point_unwind (Lisp_Object); | 3178 | extern Lisp_Object restore_point_unwind (Lisp_Object); |
| 3179 | extern _Noreturn void report_file_error (const char *, Lisp_Object); | 3179 | extern _Noreturn void report_file_error (const char *, Lisp_Object); |
| 3180 | extern void internal_delete_file (Lisp_Object); | 3180 | extern void internal_delete_file (Lisp_Object); |
| 3181 | extern bool file_directory_p (const char *); | ||
| 3182 | extern void syms_of_fileio (void); | 3181 | extern void syms_of_fileio (void); |
| 3183 | extern Lisp_Object make_temp_name (Lisp_Object, bool); | 3182 | extern Lisp_Object make_temp_name (Lisp_Object, bool); |
| 3184 | extern Lisp_Object Qdelete_file; | 3183 | extern Lisp_Object Qdelete_file; |
diff --git a/src/lread.c b/src/lread.c index dedce50de2a..6d4c0d990af 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1404,7 +1404,7 @@ Returns the file's name in absolute form, or nil if not found. | |||
| 1404 | If SUFFIXES is non-nil, it should be a list of suffixes to append to | 1404 | If SUFFIXES is non-nil, it should be a list of suffixes to append to |
| 1405 | file name when searching. | 1405 | file name when searching. |
| 1406 | If non-nil, PREDICATE is used instead of `file-readable-p'. | 1406 | If non-nil, PREDICATE is used instead of `file-readable-p'. |
| 1407 | PREDICATE can also be an integer to pass to the faccessat(2) function, | 1407 | PREDICATE can also be an integer to pass to the access(2) function, |
| 1408 | in which case file-name-handlers are ignored. | 1408 | in which case file-name-handlers are ignored. |
| 1409 | This function will normally skip directories, so if you want it to find | 1409 | This function will normally skip directories, so if you want it to find |
| 1410 | directories, make sure the PREDICATE function returns `dir-ok' for them. */) | 1410 | directories, make sure the PREDICATE function returns `dir-ok' for them. */) |
| @@ -1442,6 +1442,7 @@ static Lisp_Object Qdir_ok; | |||
| 1442 | int | 1442 | int |
| 1443 | openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) | 1443 | openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *storeptr, Lisp_Object predicate) |
| 1444 | { | 1444 | { |
| 1445 | int fd; | ||
| 1445 | ptrdiff_t fn_size = 100; | 1446 | ptrdiff_t fn_size = 100; |
| 1446 | char buf[100]; | 1447 | char buf[100]; |
| 1447 | char *fn = buf; | 1448 | char *fn = buf; |
| @@ -1496,6 +1497,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1496 | { | 1497 | { |
| 1497 | ptrdiff_t fnlen, lsuffix = SBYTES (XCAR (tail)); | 1498 | ptrdiff_t fnlen, lsuffix = SBYTES (XCAR (tail)); |
| 1498 | Lisp_Object handler; | 1499 | Lisp_Object handler; |
| 1500 | bool exists; | ||
| 1499 | 1501 | ||
| 1500 | /* Concatenate path element/specified name with the suffix. | 1502 | /* Concatenate path element/specified name with the suffix. |
| 1501 | If the directory starts with /:, remove that. */ | 1503 | If the directory starts with /:, remove that. */ |
| @@ -1519,7 +1521,6 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1519 | handler = Ffind_file_name_handler (string, Qfile_exists_p); | 1521 | handler = Ffind_file_name_handler (string, Qfile_exists_p); |
| 1520 | if ((!NILP (handler) || !NILP (predicate)) && !NATNUMP (predicate)) | 1522 | if ((!NILP (handler) || !NILP (predicate)) && !NATNUMP (predicate)) |
| 1521 | { | 1523 | { |
| 1522 | bool exists; | ||
| 1523 | if (NILP (predicate)) | 1524 | if (NILP (predicate)) |
| 1524 | exists = !NILP (Ffile_readable_p (string)); | 1525 | exists = !NILP (Ffile_readable_p (string)); |
| 1525 | else | 1526 | else |
| @@ -1541,40 +1542,37 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto | |||
| 1541 | } | 1542 | } |
| 1542 | else | 1543 | else |
| 1543 | { | 1544 | { |
| 1544 | int fd; | 1545 | #ifndef WINDOWSNT |
| 1546 | struct stat st; | ||
| 1547 | #endif | ||
| 1545 | const char *pfn; | 1548 | const char *pfn; |
| 1546 | 1549 | ||
| 1547 | encoded_fn = ENCODE_FILE (string); | 1550 | encoded_fn = ENCODE_FILE (string); |
| 1548 | pfn = SSDATA (encoded_fn); | 1551 | pfn = SSDATA (encoded_fn); |
| 1549 | 1552 | #ifdef WINDOWSNT | |
| 1550 | /* Check that we can access or open it. */ | 1553 | exists = access (pfn, F_OK) == 0 && access (pfn, D_OK) < 0; |
| 1551 | if (NATNUMP (predicate)) | 1554 | #else |
| 1552 | fd = (((XFASTINT (predicate) & ~INT_MAX) == 0 | 1555 | exists = (stat (pfn, &st) == 0 && ! S_ISDIR (st.st_mode)); |
| 1553 | && (faccessat (AT_FDCWD, pfn, XFASTINT (predicate), | 1556 | #endif |
| 1554 | AT_EACCESS) | 1557 | if (exists) |
| 1555 | == 0) | ||
| 1556 | && ! file_directory_p (pfn)) | ||
| 1557 | ? 1 : -1); | ||
| 1558 | else | ||
| 1559 | { | 1558 | { |
| 1560 | struct stat st; | 1559 | /* Check that we can access or open it. */ |
| 1561 | fd = emacs_open (pfn, O_RDONLY, 0); | 1560 | if (NATNUMP (predicate)) |
| 1562 | if (0 <= fd | 1561 | fd = (((XFASTINT (predicate) & ~INT_MAX) == 0 |
| 1563 | && (fstat (fd, &st) != 0 || S_ISDIR (st.st_mode))) | 1562 | && access (pfn, XFASTINT (predicate)) == 0) |
| 1563 | ? 1 : -1); | ||
| 1564 | else | ||
| 1565 | fd = emacs_open (pfn, O_RDONLY, 0); | ||
| 1566 | |||
| 1567 | if (fd >= 0) | ||
| 1564 | { | 1568 | { |
| 1565 | emacs_close (fd); | 1569 | /* We succeeded; return this descriptor and filename. */ |
| 1566 | fd = -1; | 1570 | if (storeptr) |
| 1571 | *storeptr = string; | ||
| 1572 | UNGCPRO; | ||
| 1573 | return fd; | ||
| 1567 | } | 1574 | } |
| 1568 | } | 1575 | } |
| 1569 | |||
| 1570 | if (fd >= 0) | ||
| 1571 | { | ||
| 1572 | /* We succeeded; return this descriptor and filename. */ | ||
| 1573 | if (storeptr) | ||
| 1574 | *storeptr = string; | ||
| 1575 | UNGCPRO; | ||
| 1576 | return fd; | ||
| 1577 | } | ||
| 1578 | } | 1576 | } |
| 1579 | } | 1577 | } |
| 1580 | if (absolute) | 1578 | if (absolute) |
| @@ -4090,7 +4088,7 @@ load_path_check (void) | |||
| 4090 | if (STRINGP (dirfile)) | 4088 | if (STRINGP (dirfile)) |
| 4091 | { | 4089 | { |
| 4092 | dirfile = Fdirectory_file_name (dirfile); | 4090 | dirfile = Fdirectory_file_name (dirfile); |
| 4093 | if (faccessat (AT_FDCWD, SSDATA (dirfile), F_OK, AT_EACCESS) != 0) | 4091 | if (access (SSDATA (dirfile), 0) < 0) |
| 4094 | dir_warning ("Warning: Lisp directory `%s' does not exist.\n", | 4092 | dir_warning ("Warning: Lisp directory `%s' does not exist.\n", |
| 4095 | XCAR (path_tail)); | 4093 | XCAR (path_tail)); |
| 4096 | } | 4094 | } |
diff --git a/src/process.c b/src/process.c index 572ab83de09..307e82819d6 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -204,7 +204,7 @@ static EMACS_INT update_tick; | |||
| 204 | #ifndef NON_BLOCKING_CONNECT | 204 | #ifndef NON_BLOCKING_CONNECT |
| 205 | #ifdef HAVE_SELECT | 205 | #ifdef HAVE_SELECT |
| 206 | #if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX) | 206 | #if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX) |
| 207 | #if O_NONBLOCK || O_NDELAY | 207 | #if defined (O_NONBLOCK) || defined (O_NDELAY) |
| 208 | #if defined (EWOULDBLOCK) || defined (EINPROGRESS) | 208 | #if defined (EWOULDBLOCK) || defined (EINPROGRESS) |
| 209 | #define NON_BLOCKING_CONNECT | 209 | #define NON_BLOCKING_CONNECT |
| 210 | #endif /* EWOULDBLOCK || EINPROGRESS */ | 210 | #endif /* EWOULDBLOCK || EINPROGRESS */ |
| @@ -651,7 +651,7 @@ allocate_pty (void) | |||
| 651 | PTY_OPEN; | 651 | PTY_OPEN; |
| 652 | #else /* no PTY_OPEN */ | 652 | #else /* no PTY_OPEN */ |
| 653 | { | 653 | { |
| 654 | # if O_NONBLOCK | 654 | # ifdef O_NONBLOCK |
| 655 | fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); | 655 | fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); |
| 656 | # else | 656 | # else |
| 657 | fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0); | 657 | fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0); |
| @@ -668,7 +668,7 @@ allocate_pty (void) | |||
| 668 | #else | 668 | #else |
| 669 | sprintf (pty_name, "/dev/tty%c%x", c, i); | 669 | sprintf (pty_name, "/dev/tty%c%x", c, i); |
| 670 | #endif /* no PTY_TTY_NAME_SPRINTF */ | 670 | #endif /* no PTY_TTY_NAME_SPRINTF */ |
| 671 | if (faccessat (AT_FDCWD, pty_name, R_OK | W_OK, AT_EACCESS) != 0) | 671 | if (access (pty_name, 6) != 0) |
| 672 | { | 672 | { |
| 673 | emacs_close (fd); | 673 | emacs_close (fd); |
| 674 | # ifndef __sgi | 674 | # ifndef __sgi |
| @@ -1621,7 +1621,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1621 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) | 1621 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) |
| 1622 | /* On most USG systems it does not work to open the pty's tty here, | 1622 | /* On most USG systems it does not work to open the pty's tty here, |
| 1623 | then close it and reopen it in the child. */ | 1623 | then close it and reopen it in the child. */ |
| 1624 | #if O_NOCTTY | 1624 | #ifdef O_NOCTTY |
| 1625 | /* Don't let this terminal become our controlling terminal | 1625 | /* Don't let this terminal become our controlling terminal |
| 1626 | (in case we don't have one). */ | 1626 | (in case we don't have one). */ |
| 1627 | forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); | 1627 | forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); |
| @@ -1675,11 +1675,11 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1675 | } | 1675 | } |
| 1676 | #endif | 1676 | #endif |
| 1677 | 1677 | ||
| 1678 | #if O_NONBLOCK | 1678 | #ifdef O_NONBLOCK |
| 1679 | fcntl (inchannel, F_SETFL, O_NONBLOCK); | 1679 | fcntl (inchannel, F_SETFL, O_NONBLOCK); |
| 1680 | fcntl (outchannel, F_SETFL, O_NONBLOCK); | 1680 | fcntl (outchannel, F_SETFL, O_NONBLOCK); |
| 1681 | #else | 1681 | #else |
| 1682 | #if O_NDELAY | 1682 | #ifdef O_NDELAY |
| 1683 | fcntl (inchannel, F_SETFL, O_NDELAY); | 1683 | fcntl (inchannel, F_SETFL, O_NDELAY); |
| 1684 | fcntl (outchannel, F_SETFL, O_NDELAY); | 1684 | fcntl (outchannel, F_SETFL, O_NDELAY); |
| 1685 | #endif | 1685 | #endif |
| @@ -1967,7 +1967,7 @@ create_pty (Lisp_Object process) | |||
| 1967 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) | 1967 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) |
| 1968 | /* On most USG systems it does not work to open the pty's tty here, | 1968 | /* On most USG systems it does not work to open the pty's tty here, |
| 1969 | then close it and reopen it in the child. */ | 1969 | then close it and reopen it in the child. */ |
| 1970 | #if O_NOCTTY | 1970 | #ifdef O_NOCTTY |
| 1971 | /* Don't let this terminal become our controlling terminal | 1971 | /* Don't let this terminal become our controlling terminal |
| 1972 | (in case we don't have one). */ | 1972 | (in case we don't have one). */ |
| 1973 | int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); | 1973 | int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); |
| @@ -1987,11 +1987,11 @@ create_pty (Lisp_Object process) | |||
| 1987 | } | 1987 | } |
| 1988 | #endif /* HAVE_PTYS */ | 1988 | #endif /* HAVE_PTYS */ |
| 1989 | 1989 | ||
| 1990 | #if O_NONBLOCK | 1990 | #ifdef O_NONBLOCK |
| 1991 | fcntl (inchannel, F_SETFL, O_NONBLOCK); | 1991 | fcntl (inchannel, F_SETFL, O_NONBLOCK); |
| 1992 | fcntl (outchannel, F_SETFL, O_NONBLOCK); | 1992 | fcntl (outchannel, F_SETFL, O_NONBLOCK); |
| 1993 | #else | 1993 | #else |
| 1994 | #if O_NDELAY | 1994 | #ifdef O_NDELAY |
| 1995 | fcntl (inchannel, F_SETFL, O_NDELAY); | 1995 | fcntl (inchannel, F_SETFL, O_NDELAY); |
| 1996 | fcntl (outchannel, F_SETFL, O_NDELAY); | 1996 | fcntl (outchannel, F_SETFL, O_NDELAY); |
| 1997 | #endif | 1997 | #endif |
| @@ -2951,7 +2951,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 2951 | { | 2951 | { |
| 2952 | /* Don't support network sockets when non-blocking mode is | 2952 | /* Don't support network sockets when non-blocking mode is |
| 2953 | not available, since a blocked Emacs is not useful. */ | 2953 | not available, since a blocked Emacs is not useful. */ |
| 2954 | #if !O_NONBLOCK && !O_NDELAY | 2954 | #if !defined (O_NONBLOCK) && !defined (O_NDELAY) |
| 2955 | error ("Network servers not supported"); | 2955 | error ("Network servers not supported"); |
| 2956 | #else | 2956 | #else |
| 2957 | is_server = 1; | 2957 | is_server = 1; |
| @@ -3217,7 +3217,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3217 | #ifdef NON_BLOCKING_CONNECT | 3217 | #ifdef NON_BLOCKING_CONNECT |
| 3218 | if (is_non_blocking_client) | 3218 | if (is_non_blocking_client) |
| 3219 | { | 3219 | { |
| 3220 | #if O_NONBLOCK | 3220 | #ifdef O_NONBLOCK |
| 3221 | ret = fcntl (s, F_SETFL, O_NONBLOCK); | 3221 | ret = fcntl (s, F_SETFL, O_NONBLOCK); |
| 3222 | #else | 3222 | #else |
| 3223 | ret = fcntl (s, F_SETFL, O_NDELAY); | 3223 | ret = fcntl (s, F_SETFL, O_NDELAY); |
| @@ -3434,10 +3434,10 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3434 | 3434 | ||
| 3435 | chan_process[inch] = proc; | 3435 | chan_process[inch] = proc; |
| 3436 | 3436 | ||
| 3437 | #if O_NONBLOCK | 3437 | #ifdef O_NONBLOCK |
| 3438 | fcntl (inch, F_SETFL, O_NONBLOCK); | 3438 | fcntl (inch, F_SETFL, O_NONBLOCK); |
| 3439 | #else | 3439 | #else |
| 3440 | #if O_NDELAY | 3440 | #ifdef O_NDELAY |
| 3441 | fcntl (inch, F_SETFL, O_NDELAY); | 3441 | fcntl (inch, F_SETFL, O_NDELAY); |
| 3442 | #endif | 3442 | #endif |
| 3443 | #endif | 3443 | #endif |
| @@ -4169,10 +4169,10 @@ server_accept_connection (Lisp_Object server, int channel) | |||
| 4169 | 4169 | ||
| 4170 | chan_process[s] = proc; | 4170 | chan_process[s] = proc; |
| 4171 | 4171 | ||
| 4172 | #if O_NONBLOCK | 4172 | #ifdef O_NONBLOCK |
| 4173 | fcntl (s, F_SETFL, O_NONBLOCK); | 4173 | fcntl (s, F_SETFL, O_NONBLOCK); |
| 4174 | #else | 4174 | #else |
| 4175 | #if O_NDELAY | 4175 | #ifdef O_NDELAY |
| 4176 | fcntl (s, F_SETFL, O_NDELAY); | 4176 | fcntl (s, F_SETFL, O_NDELAY); |
| 4177 | #endif | 4177 | #endif |
| 4178 | #endif | 4178 | #endif |
| @@ -4873,11 +4873,11 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4873 | #endif | 4873 | #endif |
| 4874 | /* ISC 4.1 defines both EWOULDBLOCK and O_NONBLOCK, | 4874 | /* ISC 4.1 defines both EWOULDBLOCK and O_NONBLOCK, |
| 4875 | and Emacs uses O_NONBLOCK, so what we get is EAGAIN. */ | 4875 | and Emacs uses O_NONBLOCK, so what we get is EAGAIN. */ |
| 4876 | #if O_NONBLOCK | 4876 | #ifdef O_NONBLOCK |
| 4877 | else if (nread == -1 && errno == EAGAIN) | 4877 | else if (nread == -1 && errno == EAGAIN) |
| 4878 | ; | 4878 | ; |
| 4879 | #else | 4879 | #else |
| 4880 | #if O_NDELAY | 4880 | #ifdef O_NDELAY |
| 4881 | else if (nread == -1 && errno == EAGAIN) | 4881 | else if (nread == -1 && errno == EAGAIN) |
| 4882 | ; | 4882 | ; |
| 4883 | /* Note that we cannot distinguish between no input | 4883 | /* Note that we cannot distinguish between no input |
| @@ -7363,7 +7363,7 @@ init_process_emacs (void) | |||
| 7363 | #ifdef HAVE_GETSOCKNAME | 7363 | #ifdef HAVE_GETSOCKNAME |
| 7364 | ADD_SUBFEATURE (QCservice, Qt); | 7364 | ADD_SUBFEATURE (QCservice, Qt); |
| 7365 | #endif | 7365 | #endif |
| 7366 | #if O_NONBLOCK || O_NDELAY | 7366 | #if defined (O_NONBLOCK) || defined (O_NDELAY) |
| 7367 | ADD_SUBFEATURE (QCserver, Qt); | 7367 | ADD_SUBFEATURE (QCserver, Qt); |
| 7368 | #endif | 7368 | #endif |
| 7369 | 7369 | ||
diff --git a/src/sysdep.c b/src/sysdep.c index 8a31957d182..35beeaa7202 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -1216,7 +1216,7 @@ reset_sys_modes (struct tty_display_info *tty_out) | |||
| 1216 | old_fcntl_owner[fileno (tty_out->input)]); | 1216 | old_fcntl_owner[fileno (tty_out->input)]); |
| 1217 | } | 1217 | } |
| 1218 | #endif /* F_SETOWN */ | 1218 | #endif /* F_SETOWN */ |
| 1219 | #if O_NDELAY | 1219 | #ifdef O_NDELAY |
| 1220 | fcntl (fileno (tty_out->input), F_SETFL, | 1220 | fcntl (fileno (tty_out->input), F_SETFL, |
| 1221 | fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NDELAY); | 1221 | fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NDELAY); |
| 1222 | #endif | 1222 | #endif |
| @@ -2312,12 +2312,12 @@ serial_open (char *port) | |||
| 2312 | 2312 | ||
| 2313 | fd = emacs_open ((char*) port, | 2313 | fd = emacs_open ((char*) port, |
| 2314 | O_RDWR | 2314 | O_RDWR |
| 2315 | #if O_NONBLOCK | 2315 | #ifdef O_NONBLOCK |
| 2316 | | O_NONBLOCK | 2316 | | O_NONBLOCK |
| 2317 | #else | 2317 | #else |
| 2318 | | O_NDELAY | 2318 | | O_NDELAY |
| 2319 | #endif | 2319 | #endif |
| 2320 | #if O_NOCTTY | 2320 | #ifdef O_NOCTTY |
| 2321 | | O_NOCTTY | 2321 | | O_NOCTTY |
| 2322 | #endif | 2322 | #endif |
| 2323 | , 0); | 2323 | , 0); |
diff --git a/src/term.c b/src/term.c index 87ce5447b76..f7c87b7608d 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -3023,7 +3023,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3023 | int fd; | 3023 | int fd; |
| 3024 | FILE *file; | 3024 | FILE *file; |
| 3025 | 3025 | ||
| 3026 | #if O_IGNORE_CTTY | 3026 | #ifdef O_IGNORE_CTTY |
| 3027 | if (!ctty) | 3027 | if (!ctty) |
| 3028 | /* Open the terminal device. Don't recognize it as our | 3028 | /* Open the terminal device. Don't recognize it as our |
| 3029 | controlling terminal, and don't make it the controlling tty | 3029 | controlling terminal, and don't make it the controlling tty |
| @@ -3054,7 +3054,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3054 | name); | 3054 | name); |
| 3055 | } | 3055 | } |
| 3056 | 3056 | ||
| 3057 | #if !O_IGNORE_CTTY | 3057 | #ifndef O_IGNORE_CTTY |
| 3058 | if (!ctty) | 3058 | if (!ctty) |
| 3059 | dissociate_if_controlling_tty (fd); | 3059 | dissociate_if_controlling_tty (fd); |
| 3060 | #endif | 3060 | #endif |
| @@ -1597,7 +1597,7 @@ init_environment (char ** argv) | |||
| 1597 | see if it succeeds. But I think that's too much to ask. */ | 1597 | see if it succeeds. But I think that's too much to ask. */ |
| 1598 | 1598 | ||
| 1599 | /* MSVCRT's _access crashes with D_OK. */ | 1599 | /* MSVCRT's _access crashes with D_OK. */ |
| 1600 | if (tmp && sys_faccessat (AT_FDCWD, tmp, D_OK, AT_EACCESS) == 0) | 1600 | if (tmp && sys_access (tmp, D_OK) == 0) |
| 1601 | { | 1601 | { |
| 1602 | char * var = alloca (strlen (tmp) + 8); | 1602 | char * var = alloca (strlen (tmp) + 8); |
| 1603 | sprintf (var, "TMPDIR=%s", tmp); | 1603 | sprintf (var, "TMPDIR=%s", tmp); |
| @@ -2714,16 +2714,10 @@ logon_network_drive (const char *path) | |||
| 2714 | long file names. */ | 2714 | long file names. */ |
| 2715 | 2715 | ||
| 2716 | int | 2716 | int |
| 2717 | sys_faccessat (int dirfd, const char * path, int mode, int flags) | 2717 | sys_access (const char * path, int mode) |
| 2718 | { | 2718 | { |
| 2719 | DWORD attributes; | 2719 | DWORD attributes; |
| 2720 | 2720 | ||
| 2721 | if (dirfd != AT_FDCWD) | ||
| 2722 | { | ||
| 2723 | errno = EINVAL; | ||
| 2724 | return -1; | ||
| 2725 | } | ||
| 2726 | |||
| 2727 | /* MSVCRT implementation of 'access' doesn't recognize D_OK, and its | 2721 | /* MSVCRT implementation of 'access' doesn't recognize D_OK, and its |
| 2728 | newer versions blow up when passed D_OK. */ | 2722 | newer versions blow up when passed D_OK. */ |
| 2729 | path = map_w32_filename (path, NULL); | 2723 | path = map_w32_filename (path, NULL); |
| @@ -2966,7 +2960,7 @@ sys_mktemp (char * template) | |||
| 2966 | { | 2960 | { |
| 2967 | int save_errno = errno; | 2961 | int save_errno = errno; |
| 2968 | p[0] = first_char[i]; | 2962 | p[0] = first_char[i]; |
| 2969 | if (sys_faccessat (AT_FDCWD, template, F_OK, AT_EACCESS) < 0) | 2963 | if (sys_access (template, 0) < 0) |
| 2970 | { | 2964 | { |
| 2971 | errno = save_errno; | 2965 | errno = save_errno; |
| 2972 | return template; | 2966 | return template; |
| @@ -4017,7 +4011,7 @@ symlink (char const *filename, char const *linkname) | |||
| 4017 | { | 4011 | { |
| 4018 | /* Non-absolute FILENAME is understood as being relative to | 4012 | /* Non-absolute FILENAME is understood as being relative to |
| 4019 | LINKNAME's directory. We need to prepend that directory to | 4013 | LINKNAME's directory. We need to prepend that directory to |
| 4020 | FILENAME to get correct results from sys_faccessat below, since | 4014 | FILENAME to get correct results from sys_access below, since |
| 4021 | otherwise it will interpret FILENAME relative to the | 4015 | otherwise it will interpret FILENAME relative to the |
| 4022 | directory where the Emacs process runs. Note that | 4016 | directory where the Emacs process runs. Note that |
| 4023 | make-symbolic-link always makes sure LINKNAME is a fully | 4017 | make-symbolic-link always makes sure LINKNAME is a fully |
| @@ -4031,10 +4025,10 @@ symlink (char const *filename, char const *linkname) | |||
| 4031 | strncpy (tem, linkfn, p - linkfn); | 4025 | strncpy (tem, linkfn, p - linkfn); |
| 4032 | tem[p - linkfn] = '\0'; | 4026 | tem[p - linkfn] = '\0'; |
| 4033 | strcat (tem, filename); | 4027 | strcat (tem, filename); |
| 4034 | dir_access = sys_faccessat (AT_FDCWD, tem, D_OK, AT_EACCESS); | 4028 | dir_access = sys_access (tem, D_OK); |
| 4035 | } | 4029 | } |
| 4036 | else | 4030 | else |
| 4037 | dir_access = sys_faccessat (AT_FDCWD, filename, D_OK, AT_EACCESS); | 4031 | dir_access = sys_access (filename, D_OK); |
| 4038 | 4032 | ||
| 4039 | /* Since Windows distinguishes between symlinks to directories and | 4033 | /* Since Windows distinguishes between symlinks to directories and |
| 4040 | to files, we provide a kludgy feature: if FILENAME doesn't | 4034 | to files, we provide a kludgy feature: if FILENAME doesn't |
diff --git a/src/xrdb.c b/src/xrdb.c index 982a6e46a13..9d056a607e4 100644 --- a/src/xrdb.c +++ b/src/xrdb.c | |||
| @@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 21 | 21 | ||
| 22 | #include <config.h> | 22 | #include <config.h> |
| 23 | 23 | ||
| 24 | #include <fcntl.h> | ||
| 25 | #include <unistd.h> | 24 | #include <unistd.h> |
| 26 | #include <errno.h> | 25 | #include <errno.h> |
| 27 | #include <epaths.h> | 26 | #include <epaths.h> |
| @@ -262,8 +261,11 @@ gethomedir (void) | |||
| 262 | static int | 261 | static int |
| 263 | file_p (const char *filename) | 262 | file_p (const char *filename) |
| 264 | { | 263 | { |
| 265 | return (faccessat (AT_FDCWD, filename, R_OK, AT_EACCESS) == 0 | 264 | struct stat status; |
| 266 | && ! file_directory_p (filename)); | 265 | |
| 266 | return (access (filename, 4) == 0 /* exists and is readable */ | ||
| 267 | && stat (filename, &status) == 0 /* get the status */ | ||
| 268 | && (S_ISDIR (status.st_mode)) == 0); /* not a directory */ | ||
| 267 | } | 269 | } |
| 268 | 270 | ||
| 269 | 271 | ||