summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-12-27 07:59:27 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-12-27 07:59:27 +0000
commit40ea51a322910c7695bc4837fc7b11568700c590 (patch)
tree98d6fbdd3e89c8e712bb0b928afeaaeeac96d68e /src
parentda4c548bbb8c634c179d7c33f54fea651d1b3619 (diff)
downloadcoreutils-40ea51a322910c7695bc4837fc7b11568700c590.tar.xz
(fd_to_subdirp): Open with O_DIRECTORY | O_NOCTTY
| O_NOFOLLOW too, for consistency with other dir-openers. Use POSIX-preferred O_NONBLOCK rather than O_NDELAY. (is_empty_dir): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/remove.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/remove.c b/src/remove.c
index bae642870..1506c56a5 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -578,15 +578,16 @@ AD_is_removable (Dirstack_state const *ds, char const *file)
return ! (top->unremovable && hash_lookup (top->unremovable, file));
}
-/* Return true if DIR is determined to be an empty directory
- or if fdopendir or readdir fails. */
+/* Return true if DIR is determined to be an empty directory. */
static bool
is_empty_dir (int fd_cwd, char const *dir)
{
DIR *dirp;
struct dirent const *dp;
int saved_errno;
- int fd = openat (fd_cwd, dir, O_RDONLY | O_NDELAY);
+ int fd = openat (fd_cwd, dir,
+ (O_RDONLY | O_DIRECTORY
+ | O_NOCTTY | O_NOFOLLOW | O_NONBLOCK));
if (fd < 0)
return false;
@@ -987,8 +988,8 @@ fd_to_subdirp (int fd_cwd, char const *f,
struct stat *subdir_sb, Dirstack_state *ds,
int *cwd_errno ATTRIBUTE_UNUSED)
{
- int fd_sub = openat_permissive (fd_cwd, f, O_RDONLY | O_NOFOLLOW,
- 0, cwd_errno);
+ int open_flags = O_RDONLY | O_NOCTTY | O_NOFOLLOW | O_NONBLOCK;
+ int fd_sub = openat_permissive (fd_cwd, f, open_flags, 0, cwd_errno);
/* Record dev/ino of F. We may compare them against saved values
to thwart any attempt to subvert the traversal. They are also used