Re: [PATCH 1/4] Mark the live device's parent devices protected. (#738964)

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

 



On Fri, 2011-09-23 at 14:07 -0400, Chris Lumens wrote:
> > diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py
> > index b735ec2..c4f3981 100644
> > --- a/pyanaconda/storage/devicetree.py
> > +++ b/pyanaconda/storage/devicetree.py
> > @@ -1016,11 +1016,49 @@ class DeviceTree(object):
> >              log.error("Unknown block device type for: %s" % name)
> >              return
> >  
> > +        def get_live_backing_device_path():
> > +            """ Return a path to the live block device or an empty string.
> > +
> > +                The line we're looking for will be of the form
> > +
> > +                    root='block:/dev/disk/by-uuid/<UUID>'
> > +
> > +            """
> > +            root_info = "/run/initramfs/tmp/root.info"
> > +            dev_live = "/dev/live"
> > +            root_path = ""
> > +            if os.path.exists(dev_live):
> > +                root_path = os.readlink(dev_live)
> > +            elif os.path.exists(root_info):
> > +                for line in open(root_info):
> > +                    if not line.startswith("root="):
> > +                        continue
> > +
> > +                    value = line.split("=", 1)[1][1:-1]
> > +                    if not value.startswith("block:"):
> > +                        continue
> > +
> > +                    root_path = os.path.realpath(value.split(":", 1)[1]))
> 
> This could be shortened up to something like:
> 
>     if not line.startswith("root='block:"):
>         continue
> 
>     root_path = os.path.realpath(line[11:-1])

Done like this:

            elif os.path.exists(root_info):
                prefix = "root='block:"
                for line in open(root_info):
                    if not line.startswith(prefix):
                        continue

                    start_idx = len(prefix) - 1
                    root_path = os.path.realpath(line[start_idx:-1])
> 
> >          # If this device is protected, mark it as such now. Once the tree
> >          # has been populated, devices' protected attribute is how we will
> >          # identify protected devices.
> >          if device and device.name in self.protectedDevNames:
> >              device.protected = True
> > +            # if this is the live backing device we want to mark its parents
> > +            # as protected also
> > +            live_path = get_live_backing_device_path()
> > +            if live_path and device.path and live_path:
> 
> You've got live_path in there twice.

It's supposed to be 'if live_path and device.path == live_path:'. Fixed.

Dave

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


_______________________________________________
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