Re: [PATCH 1/4] Add pure python EDD code parsing and compareDrives substitute (#478996)

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

 



> There are various issues with the EDD C-code, mostly that it is way
> too complicated for what it does. This patch re-implements it in
> python, and adds a compareDrives substitute to the storage class.
> 
> Note that the compareDrives substitute is a copy and paste job of the
> isys code (using the new storage edd_dict). The isys code will be removed
> in a separate patch.

The concept looks fine, though I'm not familiar with the intricacies of
our EDD code.

> @@ -255,6 +256,7 @@ class Storage(object):
>          self.zeroMbr = None
>          self.protectedDevSpecs = []
>          self.autoPartitionRequests = []
> +        self.edd_dict = {}
>  
>          self.__luksDevs = {}
>  

For consistency, you might want to call it self.eddDict.

> +def get_edd_dict(devices):
> +    """Given an array of devices return a dict with the BIOS ID for them."""
> +    edd_dict = {}
> +
> +    for biosdev in range(80, 80 + 15):
> +        sysfspath = "/sys/firmware/edd/int13_dev%d" % biosdev
> +        if not os.path.exists(sysfspath):
> +            break # We are done
> +
> +        sysfspath = "/sys/firmware/edd/int13_dev%d/mbr_signature" % biosdev
> +        if not os.path.exists(sysfspath):
> +            log.warning("No mbrsig for biosdev: %d" % biosdev)
> +            continue
> +
> +        try:
> +            file = open(sysfspath, "r")
> +            eddsig = file.read()
> +            file.close()
> +        except (IOError, OSError), e:
> +            log.warning("Error reading EDD mbrsig for %d: %s" %
> +                        (biosdev, str(e)))
> +            continue

The rest of the storage stuff does:

   except (IOError, OSError) as e:

so we should probably do that here too.

> +        sysfspath = "/sys/firmware/edd/int13_dev%d/sectors" % biosdev
> +        try:
> +            file = open(sysfspath, "r")
> +            eddsize = file.read()
> +            file.close()
> +        except (IOError, OSError), e:
> +            eddsize = None

Likewise.

> +        found = []
> +        for dev in devices:
> +            try:
> +                fd = os.open(dev.path, os.O_RDONLY)
> +                os.lseek(fd, 440, 0) 
> +                mbrsig = struct.unpack('I', os.read(fd, 4))
> +                os.close(fd)
> +            except OSError:
> +                log.warning("Error reading mbrsig from disk %s: %s" %
> +                            (dev.name, str(e)))
> +                continue
> +
> +            mbrsigStr = "0x%08x\n" % mbrsig
> +            if mbrsigStr == eddsig:
> +                if eddsize:
> +                    sysfspath = "/sys%s/size" % dev.sysfsPath
> +                    try:
> +                        file = open(sysfspath, "r")
> +                        size = file.read()
> +                        file.close()
> +                    except (IOError, OSError), e:

And once more, with feeling.

- Chris

_______________________________________________
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