mirror of
https://github.com/munki/munki.git
synced 2026-01-25 00:19:39 -06:00
Better handling of d_type field from readdir results, fixing an issue with directory enumeration on macFUSE_sshfs filesystems (and likely other FUSE filesystems. Addresses #1273, which affected makecatalogs (and likely affected manifestutil)
This commit is contained in:
@@ -260,15 +260,18 @@ func listFilesRecursively(_ top: String, followLinks: Bool = true, skipDotFiles:
|
||||
dirs.append(entryName)
|
||||
continue
|
||||
}
|
||||
if entryType == DT_LNK, followLinks {
|
||||
// need to find out what the type is of the item that is the
|
||||
// symlink's target
|
||||
if entryType == DT_UNKNOWN || entryType == DT_LNK {
|
||||
// need to find the type of the unknown item or the symlink's target
|
||||
let itemPath = (top as NSString).appendingPathComponent(entryName)
|
||||
let sb = UnsafeMutablePointer<stat>.allocate(capacity: 1)
|
||||
stat(itemPath, sb)
|
||||
let isDir = sb.pointee.st_mode & S_IFDIR == S_IFDIR
|
||||
sb.deallocate()
|
||||
if isDir {
|
||||
if entryType == DT_LNK && !followLinks {
|
||||
// don't follow symlinks to directories
|
||||
continue
|
||||
}
|
||||
dirs.append(entryName)
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user