Check if /dev/disk/*/ item is a symlink
Sometimes udev places devices symlinks into a directory /dev/disk/by-id/foo/device_symlink and we must be able to go through this directories recursively and find all symlinks. Change-Id: I0749ab94e05fdf6fd12dc89c2c788a61a128b77d Closes-Bug: #1642391
This commit is contained in:
parent
af1e5da094
commit
402eb1f423
4
agent
4
agent
|
@ -872,13 +872,13 @@ class NodeAgent
|
|||
|
||||
def _disk_id_by_name(name)
|
||||
dn = "/dev/disk/by-id"
|
||||
basepath = Dir["#{dn}/**?"].select{|f| /\/#{name}$/.match(File.readlink(f))}
|
||||
basepath = Dir["#{dn}/**/*?"].select{|f| File.symlink?(f) and /\/#{name}$/.match(File.readlink(f))}
|
||||
basepath.map{|p| p.split("/")[2..-1].join("/")}
|
||||
end
|
||||
|
||||
def _disk_path_by_name(name)
|
||||
dn = "/dev/disk/by-path"
|
||||
basepath = Dir["#{dn}/**?"].find{|f| /\/#{name}$/.match(File.readlink(f))}
|
||||
basepath = Dir["#{dn}/**/*?"].find{|f| File.symlink?(f) and /\/#{name}$/.match(File.readlink(f))}
|
||||
basepath.split("/")[2..-1].join("/") if basepath
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue