diff options
| author | Eli Zaretskii | 2012-11-17 20:00:16 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-11-17 20:00:16 +0200 |
| commit | cf2d22b874ca2df0072e32ee641e8efffe4abd6d (patch) | |
| tree | 1795142ec7861fc85c61adc90f03265b69041556 /src/w32.c | |
| parent | 3c4ca7155293ffc2d04708007131bcbc882d8913 (diff) | |
| parent | 6ad30855c02908fdd99d9b11943719e185e65ee3 (diff) | |
| download | emacs-cf2d22b874ca2df0072e32ee641e8efffe4abd6d.tar.gz emacs-cf2d22b874ca2df0072e32ee641e8efffe4abd6d.zip | |
Merge from trunk.
Diffstat (limited to 'src/w32.c')
| -rw-r--r-- | src/w32.c | 37 |
1 files changed, 24 insertions, 13 deletions
| @@ -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_access (tmp, D_OK) == 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,16 +2708,20 @@ 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_access (const char * path, int mode) | 2713 | faccessat (int dirfd, const char * path, int mode, int flags) |
| 2718 | { | 2714 | { |
| 2719 | DWORD attributes; | 2715 | DWORD attributes; |
| 2720 | 2716 | ||
| 2717 | if (dirfd != AT_FDCWD | ||
| 2718 | && !(IS_DIRECTORY_SEP (path[0]) | ||
| 2719 | || IS_DEVICE_SEP (path[1]))) | ||
| 2720 | { | ||
| 2721 | errno = EBADF; | ||
| 2722 | return -1; | ||
| 2723 | } | ||
| 2724 | |||
| 2721 | /* MSVCRT implementation of 'access' doesn't recognize D_OK, and its | 2725 | /* MSVCRT implementation of 'access' doesn't recognize D_OK, and its |
| 2722 | newer versions blow up when passed D_OK. */ | 2726 | newer versions blow up when passed D_OK. */ |
| 2723 | path = map_w32_filename (path, NULL); | 2727 | path = map_w32_filename (path, NULL); |
| @@ -2725,7 +2729,8 @@ sys_access (const char * path, int mode) | |||
| 2725 | 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 |
| 2726 | PATH elements other than the last one are transparently resolved | 2730 | PATH elements other than the last one are transparently resolved |
| 2727 | by GetFileAttributes below. */ | 2731 | by GetFileAttributes below. */ |
| 2728 | 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) | ||
| 2729 | path = chase_symlinks (path); | 2734 | path = chase_symlinks (path); |
| 2730 | 2735 | ||
| 2731 | if ((attributes = GetFileAttributes (path)) == -1) | 2736 | if ((attributes = GetFileAttributes (path)) == -1) |
| @@ -2757,7 +2762,8 @@ sys_access (const char * path, int mode) | |||
| 2757 | } | 2762 | } |
| 2758 | return -1; | 2763 | return -1; |
| 2759 | } | 2764 | } |
| 2760 | if ((mode & X_OK) != 0 && !is_exec (path)) | 2765 | if ((mode & X_OK) != 0 |
| 2766 | && !(is_exec (path) || (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)) | ||
| 2761 | { | 2767 | { |
| 2762 | errno = EACCES; | 2768 | errno = EACCES; |
| 2763 | return -1; | 2769 | return -1; |
| @@ -2775,6 +2781,11 @@ sys_access (const char * path, int mode) | |||
| 2775 | return 0; | 2781 | return 0; |
| 2776 | } | 2782 | } |
| 2777 | 2783 | ||
| 2784 | /* Shadow some MSVC runtime functions to map requests for long filenames | ||
| 2785 | to reasonable short names if necessary. This was originally added to | ||
| 2786 | permit running Emacs on NT 3.1 on a FAT partition, which doesn't support | ||
| 2787 | long file names. */ | ||
| 2788 | |||
| 2778 | int | 2789 | int |
| 2779 | sys_chdir (const char * path) | 2790 | sys_chdir (const char * path) |
| 2780 | { | 2791 | { |
| @@ -2960,7 +2971,7 @@ sys_mktemp (char * template) | |||
| 2960 | { | 2971 | { |
| 2961 | int save_errno = errno; | 2972 | int save_errno = errno; |
| 2962 | p[0] = first_char[i]; | 2973 | p[0] = first_char[i]; |
| 2963 | if (sys_access (template, 0) < 0) | 2974 | if (faccessat (AT_FDCWD, template, F_OK, AT_EACCESS) < 0) |
| 2964 | { | 2975 | { |
| 2965 | errno = save_errno; | 2976 | errno = save_errno; |
| 2966 | return template; | 2977 | return template; |
| @@ -4011,7 +4022,7 @@ symlink (char const *filename, char const *linkname) | |||
| 4011 | { | 4022 | { |
| 4012 | /* Non-absolute FILENAME is understood as being relative to | 4023 | /* Non-absolute FILENAME is understood as being relative to |
| 4013 | LINKNAME's directory. We need to prepend that directory to | 4024 | LINKNAME's directory. We need to prepend that directory to |
| 4014 | FILENAME to get correct results from sys_access below, since | 4025 | FILENAME to get correct results from faccessat below, since |
| 4015 | otherwise it will interpret FILENAME relative to the | 4026 | otherwise it will interpret FILENAME relative to the |
| 4016 | directory where the Emacs process runs. Note that | 4027 | directory where the Emacs process runs. Note that |
| 4017 | make-symbolic-link always makes sure LINKNAME is a fully | 4028 | make-symbolic-link always makes sure LINKNAME is a fully |
| @@ -4025,10 +4036,10 @@ symlink (char const *filename, char const *linkname) | |||
| 4025 | strncpy (tem, linkfn, p - linkfn); | 4036 | strncpy (tem, linkfn, p - linkfn); |
| 4026 | tem[p - linkfn] = '\0'; | 4037 | tem[p - linkfn] = '\0'; |
| 4027 | strcat (tem, filename); | 4038 | strcat (tem, filename); |
| 4028 | dir_access = sys_access (tem, D_OK); | 4039 | dir_access = faccessat (AT_FDCWD, tem, D_OK, AT_EACCESS); |
| 4029 | } | 4040 | } |
| 4030 | else | 4041 | else |
| 4031 | dir_access = sys_access (filename, D_OK); | 4042 | dir_access = faccessat (AT_FDCWD, filename, D_OK, AT_EACCESS); |
| 4032 | 4043 | ||
| 4033 | /* Since Windows distinguishes between symlinks to directories and | 4044 | /* Since Windows distinguishes between symlinks to directories and |
| 4034 | to files, we provide a kludgy feature: if FILENAME doesn't | 4045 | to files, we provide a kludgy feature: if FILENAME doesn't |