From 43539a0c86a1b09688c885f30b935b2a9adfa205 Mon Sep 17 00:00:00 2001 From: Bala FA Date: Sat, 14 May 2016 00:09:48 +0530 Subject: [PATCH] posix: parseDirents() should follow symlink and get values. (#1631) Previously parseDirents() ignores symbolic links. This patch fixes the issue by following the symlink using os.Stat(). Fixes #1545 --- posix-list-dir-nix.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/posix-list-dir-nix.go b/posix-list-dir-nix.go index 56bb6fd63..1d06a019f 100644 --- a/posix-list-dir-nix.go +++ b/posix-list-dir-nix.go @@ -79,7 +79,9 @@ func parseDirents(dirPath string, buf []byte) (entries []string, err error) { entries = append(entries, name+slashSeparator) case syscall.DT_REG: entries = append(entries, name) - case syscall.DT_UNKNOWN: + case syscall.DT_LNK, syscall.DT_UNKNOWN: + // If its symbolic link, follow the link using os.Stat() + // On Linux XFS does not implement d_type for on disk // format << v5. Fall back to Stat(). var fi os.FileInfo @@ -101,7 +103,6 @@ func parseDirents(dirPath string, buf []byte) (entries []string, err error) { } default: // Skip entries which are not file or directory. - // FIXME: should we handle symlinks? continue } }