Skip to content

Commit

Permalink
Added fix for Kubernetes btrfs issue #38337
Browse files Browse the repository at this point in the history
  • Loading branch information
dmrub committed Jan 15, 2017
1 parent 1fa56cb commit 1674778
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,31 @@ func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) ma
continue
}

// btrfs fix
if mount.Fstype == "btrfs" && mount.Major == 0 && strings.HasPrefix(mount.Source, "/dev/") {

buf := new(syscall.Stat_t)
err := syscall.Stat(mount.Source, buf)
if err != nil {
glog.Warningf("stat failed on %s with error: %s", mount.Source, err)
} else {
glog.Infof("btrfs mount %#v", mount)
if buf.Mode&syscall.S_IFMT == syscall.S_IFBLK {
err := syscall.Stat(mount.Mountpoint, buf)
if err != nil {
glog.Warningf("stat failed on %s with error: %s", mount.Mountpoint, err)
} else {
glog.Infof("apply fix to btrfs mount")
glog.Infof("btrfs dev major:minor %d:%d\n", int(major(buf.Dev)), int(minor(buf.Dev)))
glog.Infof("btrfs rdev major:minor %d:%d\n", int(major(buf.Rdev)), int(minor(buf.Rdev)))

mount.Major = int(major(buf.Dev))
mount.Minor = int(minor(buf.Dev))
}
}
}
}

partitions[mount.Source] = partition{
fsType: mount.Fstype,
mountpoint: mount.Mountpoint,
Expand Down

0 comments on commit 1674778

Please sign in to comment.