deviceNumberFromStat returned device 0 and true for a stat whose device and inode numbers are both zero. afero's unreleased master gives such a stat for every in-memory file; the pinned v1.15.0 gives none. It now returns false for it, as its comment says, and a test covers both in-memory shapes. Model: opus-5-5
This commit is contained in:
1 parent
d747ddef3a
commit
8d586ed4f9
2 files changed
+39
-3
No files matched your search
@@ -1438,11 +1438,12 @@ func (s *Scanner) deviceNumberAt(path string) (uint64, bool) {
|
||||
}
|
||||
|
||||
// deviceNumberFromStat returns the number of the device that holds the
|
||||
// file info describes, and false when info carries no stat, as from the
|
||||
// in-memory test filesystem.
|
||||
// file info describes, and false when info carries no stat from a real
|
||||
// filesystem. The in-memory test filesystem gives either no stat or one
|
||||
// whose device and inode numbers are both zero, which no real file has.
|
||||
func deviceNumberFromStat(info os.FileInfo) (uint64, bool) {
|
||||
stat, ok := info.Sys().(*syscall.Stat_t)
|
||||
if !ok {
|
||||
if !ok || (stat.Dev == 0 && stat.Ino == 0) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user