]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(is_empty_dir): Open with O_NDELAY, so we don't hang, e.g., on a named pipe.
authorJim Meyering <jim@meyering.net>
Sat, 17 Dec 2005 13:46:27 +0000 (13:46 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 17 Dec 2005 13:46:27 +0000 (13:46 +0000)
(OPEN_NO_FOLLOW_SYMLINK): Remove definition.  Use O_NOFOLLOW in
place of all uses, since it is guaranteed (system.h) to be defined.

src/remove.c

index f96ca840c8cd0b3f5aea8edab4390a2d6ba7fe52..bae6428706fdeae2370f89d7d9eaa0b2de8d88c4 100644 (file)
 #define obstack_chunk_alloc malloc
 #define obstack_chunk_free free
 
-/* Define to the options that make open (or openat) fail to open
-   a symlink.  Define to 0 if there are no such options.
-   This is useful because it permits us to skip the `fstat'
-   and dev/ino comparison in AD_push.  */
-#if defined O_NOFOLLOW
-# define OPEN_NO_FOLLOW_SYMLINK O_NOFOLLOW
-#else
-# define OPEN_NO_FOLLOW_SYMLINK 0
-#endif
-
 /* This is the maximum number of consecutive readdir/unlink calls that
    can be made (with no intervening rewinddir or closedir/opendir)
    before triggering a bug that makes readdir return NULL even though
@@ -547,7 +537,7 @@ AD_push (int fd_cwd, Dirstack_state *ds, char const *dir,
 
   /* If our uses of openat are guaranteed not to
      follow a symlink, then we can skip this check.  */
-  if ( ! OPEN_NO_FOLLOW_SYMLINK)
+  if ( ! O_NOFOLLOW)
     {
       struct stat sb;
       if (fstat (fd_cwd, &sb) != 0)
@@ -596,7 +586,7 @@ 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);
+  int fd = openat (fd_cwd, dir, O_RDONLY | O_NDELAY);
 
   if (fd < 0)
     return false;
@@ -997,7 +987,7 @@ 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 | OPEN_NO_FOLLOW_SYMLINK,
+  int fd_sub = openat_permissive (fd_cwd, f, O_RDONLY | O_NOFOLLOW,
                                  0, cwd_errno);
 
   /* Record dev/ino of F.  We may compare them against saved values