mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
Include dirfd.h.
(print_dir): If dirfd fails, resort to using stat.
This commit is contained in:
1 parent
866d4b9e59
commit
6fa5979ccb
1 file changed
+7
-1
@@ -108,6 +108,7 @@ int wcwidth ();
|
||||
|
||||
#include "argmatch.h"
|
||||
#include "dirname.h"
|
||||
#include "dirfd.h"
|
||||
#include "error.h"
|
||||
#include "hard-locale.h"
|
||||
#include "hash.h"
|
||||
@@ -2036,7 +2037,12 @@ print_dir (const char *name, const char *realname)
|
||||
if (LOOP_DETECT)
|
||||
{
|
||||
struct stat dir_stat;
|
||||
if (fstat (dirfd (reading), &dir_stat) < 0)
|
||||
int fd = dirfd (reading);
|
||||
|
||||
/* If dirfd failed, endure the overhead of using stat. */
|
||||
if ((0 <= fd
|
||||
? fstat (fd, &dir_stat)
|
||||
: stat (name, &dir_stat)) < 0)
|
||||
{
|
||||
error (0, errno, _("cannot determine device and inode of %s"),
|
||||
quotearg_colon (name));
|
||||
|
||||
Reference in new issue
Block a user