Skip to content

Commit

Permalink
fix: list full paths while listing via lsblk --paths
Browse files Browse the repository at this point in the history
Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
  • Loading branch information
iamniting committed Aug 22, 2022
1 parent e757e9d commit e1fda0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/internal/block_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func ListBlockDevices(exec Executor) ([]BlockDevice, error) {
// var output bytes.Buffer
var blockDeviceMap map[string][]BlockDevice
columns := "NAME,ROTA,TYPE,SIZE,MODEL,VENDOR,RO,STATE,KNAME,SERIAL,PARTLABEL,FSTYPE"
args := []string{"--json", "-o", columns}
args := []string{"--json", "--paths", "-o", columns}

output, err := exec.ExecuteCommandWithOutput("lsblk", args...)
if err != nil {
Expand Down Expand Up @@ -106,7 +106,7 @@ func (b BlockDevice) IsUsableLoopDev(exec Executor) (bool, error) {

usable := true

args := []string{fmt.Sprintf("/dev/%s", b.Name), "-O", "BACK-FILE", "--json"}
args := []string{b.Name, "-O", "BACK-FILE", "--json"}

output, err := exec.ExecuteCommandWithOutput(losetupPath, args...)
if err != nil {
Expand Down Expand Up @@ -153,7 +153,7 @@ func (b BlockDevice) HasBindMounts() (bool, string, error) {
mountInfoList := strings.Split(mountInfo, " ")
if len(mountInfoList) >= 10 {
// device source is 4th field for bind mounts and 10th for regular mounts
if mountInfoList[3] == fmt.Sprintf("/%s", b.KName) || mountInfoList[9] == fmt.Sprintf("/dev/%s", b.KName) {
if mountInfoList[3] == fmt.Sprintf("/%s", filepath.Base(b.KName)) || mountInfoList[9] == b.KName {
return true, mountInfoList[4], nil
}
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/vgmanager/vgmanager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (r *VGReconciler) addDevicesToVG(vgName string, devices []internal.BlockDev
if device.DiskByPath != "" {
args = append(args, device.DiskByPath)
} else {
args = append(args, fmt.Sprintf("/dev/%s", device.KName))
args = append(args, device.KName)
}
}

Expand Down Expand Up @@ -420,8 +420,7 @@ func (r *VGReconciler) filterMatchingDevices(blockDevices []internal.BlockDevice
continue
}

baseDiskName := filepath.Base(diskName)
blockDevice, ok := hasExactDisk(blockDevices, baseDiskName)
blockDevice, ok := hasExactDisk(blockDevices, diskName)

if filepath.Dir(path) == internal.DiskByPathPrefix {
// handle disk by path here such as /dev/disk/by-path/pci-0000:87:00.0-nvme-1
Expand Down

0 comments on commit e1fda0d

Please sign in to comment.