diff options
| author | Eli Zaretskii | 2012-11-14 19:22:55 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-11-14 19:22:55 +0200 |
| commit | 14f207289c224b3ad12fc8704c2183ef8fbcab28 (patch) | |
| tree | 762793d11e03d384ff44353bdfde59c302cda66d /src | |
| parent | c62792e7dfa403db8c36cb92f32fb69258a199ef (diff) | |
| download | emacs-14f207289c224b3ad12fc8704c2183ef8fbcab28.tar.gz emacs-14f207289c224b3ad12fc8704c2183ef8fbcab28.zip | |
MS-Windows followup for 2012-11-14T04:55:41Z!eggert@cs.ucla.edu, regarding faccessat.
nt/inc/unistd.h (faccessat): Add prototype.
(AT_FDCWD, AT_EACCESS, AT_SYMLINK_NOFOLLOW): New macros; the first
2 moved from ms-w32.h.
nt/inc/ms-w32.h (AT_FDCWD, AT_EACCESS, faccessat): Remove macros.
src/w32.c (faccessat): Rename from sys_faccessat. (No need to use a
different name, as the MS runtime does not have such a function,
and probably never will.) All callers changed. Ignore DIRFD
value if PATH is an absolute file name, to match Posix spec
better. If AT_SYMLINK_NOFOLLOW is set in FLAGS, don't resolve
symlinks.
Fixes: debbugs:12632
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/w32.c | 30 |
2 files changed, 26 insertions, 13 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 99f3128b321..ec8f7e219f7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2012-11-14 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * w32.c (faccessat): Rename from sys_faccessat. (No need to use a | ||
| 4 | different name, as the MS runtime does not have such a function, | ||
| 5 | and probably never will.) All callers changed. Ignore DIRFD | ||
| 6 | value if PATH is an absolute file name, to match Posix spec | ||
| 7 | better. If AT_SYMLINK_NOFOLLOW is set in FLAGS, don't resolve | ||
| 8 | symlinks. | ||
| 9 | |||
| 1 | 2012-11-14 Dmitry Antipov <dmantipov@yandex.ru> | 10 | 2012-11-14 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 11 | ||
| 3 | * xdisp.c (echo_area_display, redisplay_internal): | 12 | * xdisp.c (echo_area_display, redisplay_internal): |
| @@ -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 && faccessat (AT_FDCWD, tmp, D_OK, AT_EACCESS) == 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); |
| @@ -2708,17 +2708,15 @@ logon_network_drive (const char *path) | |||
| 2708 | WNetAddConnection2 (&resource, NULL, NULL, CONNECT_INTERACTIVE); | 2708 | WNetAddConnection2 (&resource, NULL, NULL, CONNECT_INTERACTIVE); |
| 2709 | } | 2709 | } |
| 2710 | 2710 | ||
| 2711 | /* Shadow some MSVC runtime functions to map requests for long filenames | 2711 | /* Emulate faccessat(2). */ |
| 2712 | to reasonable short names if necessary. This was originally added to | ||
| 2713 | permit running Emacs on NT 3.1 on a FAT partition, which doesn't support | ||
| 2714 | long file names. */ | ||
| 2715 | |||
| 2716 | int | 2712 | int |
| 2717 | sys_faccessat (int dirfd, const char * path, int mode, int flags) | 2713 | faccessat (int dirfd, const char * path, int mode, int flags) |
| 2718 | { | 2714 | { |
| 2719 | DWORD attributes; | 2715 | DWORD attributes; |
| 2720 | 2716 | ||
| 2721 | if (dirfd != AT_FDCWD) | 2717 | if (dirfd != AT_FDCWD |
| 2718 | && !(IS_DIRECTORY_SEP (path[0]) | ||
| 2719 | || IS_DEVICE_SEP (path[1]))) | ||
| 2722 | { | 2720 | { |
| 2723 | errno = EBADF; | 2721 | errno = EBADF; |
| 2724 | return -1; | 2722 | return -1; |
| @@ -2731,7 +2729,8 @@ sys_faccessat (int dirfd, const char * path, int mode, int flags) | |||
| 2731 | to get the attributes of its target file. Note: any symlinks in | 2729 | to get the attributes of its target file. Note: any symlinks in |
| 2732 | PATH elements other than the last one are transparently resolved | 2730 | PATH elements other than the last one are transparently resolved |
| 2733 | by GetFileAttributes below. */ | 2731 | by GetFileAttributes below. */ |
| 2734 | if ((volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0) | 2732 | if ((volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0 |
| 2733 | && (flags & AT_SYMLINK_NOFOLLOW) == 0) | ||
| 2735 | path = chase_symlinks (path); | 2734 | path = chase_symlinks (path); |
| 2736 | 2735 | ||
| 2737 | if ((attributes = GetFileAttributes (path)) == -1) | 2736 | if ((attributes = GetFileAttributes (path)) == -1) |
| @@ -2781,6 +2780,11 @@ sys_faccessat (int dirfd, const char * path, int mode, int flags) | |||
| 2781 | return 0; | 2780 | return 0; |
| 2782 | } | 2781 | } |
| 2783 | 2782 | ||
| 2783 | /* Shadow some MSVC runtime functions to map requests for long filenames | ||
| 2784 | to reasonable short names if necessary. This was originally added to | ||
| 2785 | permit running Emacs on NT 3.1 on a FAT partition, which doesn't support | ||
| 2786 | long file names. */ | ||
| 2787 | |||
| 2784 | int | 2788 | int |
| 2785 | sys_chdir (const char * path) | 2789 | sys_chdir (const char * path) |
| 2786 | { | 2790 | { |
| @@ -2966,7 +2970,7 @@ sys_mktemp (char * template) | |||
| 2966 | { | 2970 | { |
| 2967 | int save_errno = errno; | 2971 | int save_errno = errno; |
| 2968 | p[0] = first_char[i]; | 2972 | p[0] = first_char[i]; |
| 2969 | if (sys_faccessat (AT_FDCWD, template, F_OK, AT_EACCESS) < 0) | 2973 | if (faccessat (AT_FDCWD, template, F_OK, AT_EACCESS) < 0) |
| 2970 | { | 2974 | { |
| 2971 | errno = save_errno; | 2975 | errno = save_errno; |
| 2972 | return template; | 2976 | return template; |
| @@ -4017,7 +4021,7 @@ symlink (char const *filename, char const *linkname) | |||
| 4017 | { | 4021 | { |
| 4018 | /* Non-absolute FILENAME is understood as being relative to | 4022 | /* Non-absolute FILENAME is understood as being relative to |
| 4019 | LINKNAME's directory. We need to prepend that directory to | 4023 | LINKNAME's directory. We need to prepend that directory to |
| 4020 | FILENAME to get correct results from sys_faccessat below, since | 4024 | FILENAME to get correct results from faccessat below, since |
| 4021 | otherwise it will interpret FILENAME relative to the | 4025 | otherwise it will interpret FILENAME relative to the |
| 4022 | directory where the Emacs process runs. Note that | 4026 | directory where the Emacs process runs. Note that |
| 4023 | make-symbolic-link always makes sure LINKNAME is a fully | 4027 | make-symbolic-link always makes sure LINKNAME is a fully |
| @@ -4031,10 +4035,10 @@ symlink (char const *filename, char const *linkname) | |||
| 4031 | strncpy (tem, linkfn, p - linkfn); | 4035 | strncpy (tem, linkfn, p - linkfn); |
| 4032 | tem[p - linkfn] = '\0'; | 4036 | tem[p - linkfn] = '\0'; |
| 4033 | strcat (tem, filename); | 4037 | strcat (tem, filename); |
| 4034 | dir_access = sys_faccessat (AT_FDCWD, tem, D_OK, AT_EACCESS); | 4038 | dir_access = faccessat (AT_FDCWD, tem, D_OK, AT_EACCESS); |
| 4035 | } | 4039 | } |
| 4036 | else | 4040 | else |
| 4037 | dir_access = sys_faccessat (AT_FDCWD, filename, D_OK, AT_EACCESS); | 4041 | dir_access = faccessat (AT_FDCWD, filename, D_OK, AT_EACCESS); |
| 4038 | 4042 | ||
| 4039 | /* Since Windows distinguishes between symlinks to directories and | 4043 | /* Since Windows distinguishes between symlinks to directories and |
| 4040 | to files, we provide a kludgy feature: if FILENAME doesn't | 4044 | to files, we provide a kludgy feature: if FILENAME doesn't |