Skip to content

Commit f0dbef3

Browse files
committed
Add support for non btrfs devices in GetDirFsDevice
We can create a `*DeviceInfo` from the mount even if the `FSType` is not `btrfs`. Signed-off-by: Sascha Grunert <[email protected]>
1 parent 291c215 commit f0dbef3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

fs/fs.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,14 +582,19 @@ func (i *RealFsInfo) GetDirFsDevice(dir string) (*DeviceInfo, error) {
582582
}
583583

584584
mnt, found := i.mountInfoFromDir(dir)
585-
if found && mnt.FSType == "btrfs" && mnt.Major == 0 && strings.HasPrefix(mnt.Source, "/dev/") {
586-
major, minor, err := getBtrfsMajorMinorIds(mnt)
587-
if err != nil {
588-
klog.Warningf("%s", err)
589-
} else {
590-
return &DeviceInfo{mnt.Source, uint(major), uint(minor)}, nil
585+
if found && strings.HasPrefix(mnt.Source, "/dev/") {
586+
major, minor := mnt.Major, mnt.Minor
587+
588+
if mnt.FSType == "btrfs" && major == 0 {
589+
major, minor, err = getBtrfsMajorMinorIds(mnt)
590+
if err != nil {
591+
klog.Warningf("Unable to get btrfs mountpoint IDs: %v", err)
592+
}
591593
}
594+
595+
return &DeviceInfo{mnt.Source, uint(major), uint(minor)}, nil
592596
}
597+
593598
return nil, fmt.Errorf("could not find device with major: %d, minor: %d in cached partitions map", major, minor)
594599
}
595600

0 commit comments

Comments
 (0)