On Wed, Sep 05, 2018 at 02:18:34PM +0200, Jan Kiszka wrote: > On 2018-09-05 13:12, Andreas Reichel wrote: > > On Tue, Sep 04, 2018 at 05:44:07PM +0200, Jan Kiszka wrote: > > > On 2018-09-03 16:09, [ext] Andreas J. Reichel wrote: > > > > From: Andreas Reichel <[email protected]> > > > > > > > > Get the boot device out of the loaded image's handle and add a > > > > function to compare a device path with the boot device's one. > > > > > > > > status); > > > > } > > > > + tmp = > > > > DevicePathToStr(DevicePathFromHandle(loaded_image->DeviceHandle)); > > > > > > For my understanding: What is actually cut off there, ie. who does that > > > path > > > look like so that we only to cut off the last element, and there is not > > > filesystem directory element remaining in it? > > > > > The DevicePath is pointing to the device, not to the file. That was my > > argumentation all along regarding dirname/RemoveLastNodeFromDevicePath. > > Since it is not just a directory. > > > > Please read below. > > > > > > +BOOLEAN IsOnBootDevice(EFI_DEVICE_PATH *dp) > > > > +{ > > > > + extern CHAR16 *boot_device_path; > > > > + CHAR16 *device_path, *tmp; > > > > + BOOLEAN result = FALSE; > > > > + > > > > + tmp = DevicePathToStr(dp); > > > > + device_path = dirname(tmp); > > > > + mfree(tmp); > > > > + > > > > + if (StrCmp(device_path, boot_device_path) == 0) { > > > > + result = TRUE; > > > > + } > > > > + mfree(device_path); > > > > + > > > > + return result; > > > > +} > > > > + > > > > uint32_t calc_crc32(void *data, int32_t size) > > > > { > > > > uint32_t crc; > > > > > > > > > > Looks good, /me just needs to understand the path structure, and maybe > > > that > > > should then also be documented in the code. > > > > > Agreed. We have something like > > > > controller/bus/device/partition > > > > in all cases. > > > > Like > > > > PciRoot(0)/Pci(0x1,0x1)/Ata(Primary,Master)/HD(Part2,Sig870E7D1B-3D9F-4E49-98BA-7283AB6AA632) > > > > which gets cut to > > > > PciRoot(0)/Pci(0x1,0x1)/Ata(Primary,Master) > > > > I will add that to the documentation. > > OK, so you are removing the disk/partition > element from the boot device path. Is it UEFI > standard that this path will always have the > above structure? > > It's probably the question what "device" is in > this UEFI context, but you are passing in a > device according to the type (EFI_DEVICE_PATH), > and the extracted path is maybe rather the "boot > medium". > > As I said on patch 1: Make the extraction helper > context specific in its naming. Then you can do > all the shortcuts you like, and we can settle > that topic.
Regarding the "standard" of this structure: Node structure: see https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Protocol/DevicePath.h about line 1235 there are a lot of different path conventions depending on the boot device. If we were to boot from Fiber Channel or from IPV6_DEVICE_PATH, then this will most probably also work in some manner because we always go to the closest parent. String representation: All have in common the same string representation system as defined in i.e. UEFI Spec 2.6, paragraph 9.3.5 If it works or not in a useful sense depends on the partitioning and the medium structure. For example, if we had a block device inside a block device, and the file system was raw on the inner block device then the outer block device would be the parent node we compare against (hypothetic scenario). If we had two partitions within each other, then the outer partition would be the parent node we compare against. But it's a good idea to call it boot medium instead of boot device to get rid of the confusion. Wether it is a real medium or not depends on the protocol AND the system setup we boot with. So I will name the function GetBootMediumPath. Then the context is clear. Do you agree? Andreas > > Jan > > -- > Siemens AG, Corporate Technology, CT RDA IOT SES-DE > Corporate Competence Center Embedded Linux -- Andreas Reichel Dipl.-Phys. (Univ.) Software Consultant [email protected], +49-174-3180074 TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterfoehring Geschaeftsfuehrer: Henrik Klagges, Dr. Robert Dahlke, Gerhard Mueller Sitz: Unterfoehring * Amtsgericht Muenchen * HRB 135082 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20180905132207.GA16879%40iiotirae. For more options, visit https://groups.google.com/d/optout.
