diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/fileio.c b/src/fileio.c index e33ac4afabf..a9e5975a2eb 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -4187,16 +4187,14 @@ by calling `format-decode', which see. */) | |||
| 4187 | if (emacs_fd_fstat (fd, &st) < 0) | 4187 | if (emacs_fd_fstat (fd, &st) < 0) |
| 4188 | report_file_error ("Input file status", orig_filename); | 4188 | report_file_error ("Input file status", orig_filename); |
| 4189 | 4189 | ||
| 4190 | /* For backwards compatibility to traditional Unix, | 4190 | /* Normally there is no need for an S_ISDIR test here, |
| 4191 | POSIX allows the 'read' syscall to succeed on directories. | 4191 | as the first 'read' syscall will fail with EISDIR. |
| 4192 | However, we want to fail, to be consistent across platforms | 4192 | However, for backwards compatibility to traditional Unix, |
| 4193 | and to let callers rely on this function failing on directories. | 4193 | POSIX allows 'read' to succeed on directories. |
| 4194 | There is no need to check on platforms where it is known that the | 4194 | So do an explicit S_ISDIR test now, so that callers can rely on |
| 4195 | 'read' syscall always fails on a directory. */ | 4195 | this function rejecting directories on all platforms. */ |
| 4196 | #if ! (defined GNU_LINUX || defined __ANDROID__) | ||
| 4197 | if (S_ISDIR (st.st_mode)) | 4196 | if (S_ISDIR (st.st_mode)) |
| 4198 | report_file_errno ("Read error", orig_filename, EISDIR); | 4197 | report_file_errno ("Read error", orig_filename, EISDIR); |
| 4199 | #endif | ||
| 4200 | 4198 | ||
| 4201 | regular = S_ISREG (st.st_mode) != 0; | 4199 | regular = S_ISREG (st.st_mode) != 0; |
| 4202 | bool memory_object = S_TYPEISSHM (&st) || S_TYPEISTMO (&st); | 4200 | bool memory_object = S_TYPEISSHM (&st) || S_TYPEISTMO (&st); |