Skip to content

Commit

Permalink
Merge pull request #1971 from MaximilianMeister/fix-kubernetes-issue-…
Browse files Browse the repository at this point in the history
…65204

fix brtfs issue where dir is sub-directory of a sub-volume
  • Loading branch information
dashpole committed Jun 20, 2018
2 parents fc0bd7a + 87ddb0e commit 179330d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,21 @@ func (self *RealFsInfo) GetDirFsDevice(dir string) (*DeviceInfo, error) {
}

mount, found := self.mounts[dir]
// try the parent dir if not found until we reach the root dir
// this is an issue on btrfs systems where the directory is not
// the subvolume
for !found {
pathdir, _ := filepath.Split(dir)
// break when we reach root
if pathdir == "/" {
break
}
// trim "/" from the new parent path otherwise the next possible
// filepath.Split in the loop will not split the string any further
dir = strings.TrimSuffix(pathdir, "/")
mount, found = self.mounts[dir]
}

if found && mount.Fstype == "btrfs" && mount.Major == 0 && strings.HasPrefix(mount.Source, "/dev/") {
major, minor, err := getBtrfsMajorMinorIds(mount)
if err != nil {
Expand Down

0 comments on commit 179330d

Please sign in to comment.