Re: [PATCH 3/7] Make storage.devices.deviceNameToDiskByPath() more robust.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



One comment below.

On 10/08/2009 09:28 AM, David Cantrell wrote:
> Have deviceNameToDiskByPath() return the full device path rather than
> just the basename path.  Have it check to see if the entry in
> /dev/disk/by-path is actually a symlink, then readlink that.  Otherwise
> just take the basename of the entry.  Also fix a problem where passing
> it a full device path would not match (e.g., '/dev/dasdb1').  Take the
> basename of deviceName and match that against the readlink() value.
> ---
>  storage/devices.py |   12 ++++++++++--
>  1 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/storage/devices.py b/storage/devices.py
> index 348d2fd..9d257e2 100644
> --- a/storage/devices.py
> +++ b/storage/devices.py
> @@ -154,10 +154,18 @@ def deviceNameToDiskByPath(deviceName=None):
>      if not os.path.isdir(bypath):
>          return ""
> 
> +    deviceName = os.path.basename(deviceName)
> +
>      for path in os.listdir(bypath):

With many devices this linear search may become a performance problem.
I was wondering, if one could just use something that you already had
for a different purpose in your "[PATCH] Add dracutSetupString() method
to ZFCPDiskDevice (#526354)". Take info.get("symlinks") since it's in
the udev-db anyway already. Search for a match of "disk/by-path" and
then you have it.

> -        target = os.path.basename(os.readlink(bypath + '/' + path))
> +        entry = bypath + '/' + path
> +
> +        if os.path.islink(entry):
> +            target = os.path.basename(os.readlink(entry))
> +        else:
> +            target = os.path.basename(entry)
> +
>          if target == deviceName:
> -            return path
> +            return entry
> 
>      return ""
> 

Steffen Maier

Linux on System z Development

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Erich Baier
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux