OSDN Git Service

android-x86/external-efivar.git
5 years agoFix partition number detection when it's not provided.
Peter Jones [Tue, 18 Sep 2018 18:57:13 +0000 (14:57 -0400)]
Fix partition number detection when it's not provided.

We need to actually get the partition number from the child device when
we're called without it.

Resolves: rhbz#1616305

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoHandle partition name parsing and formatting for partitioned md.
Peter Jones [Mon, 17 Sep 2018 20:52:57 +0000 (16:52 -0400)]
Handle partition name parsing and formatting for partitioned md.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoDeal with devices that don't have a ->device link in sysfs
Peter Jones [Mon, 17 Sep 2018 20:13:24 +0000 (16:13 -0400)]
Deal with devices that don't have a ->device link in sysfs

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoFix dev->probes intialization test
Peter Jones [Mon, 17 Sep 2018 20:12:25 +0000 (16:12 -0400)]
Fix dev->probes intialization test

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoFix another buggy fake acpi pci root driver
Peter Jones [Mon, 10 Sep 2018 19:00:03 +0000 (15:00 -0400)]
Fix another buggy fake acpi pci root driver

In this case, the platform driver that creates the PCI(e) root device
doesn't fill in its driver link, so we can't look up what driver is in
use - but since it's the root, it *really* doesn't matter.  And in
general, we only really care if it's the last node in our path, because
that'll be the controller for the boot device anyway.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agolinux-emmc: update for internal API breakage.
Peter Jones [Fri, 3 Aug 2018 14:02:02 +0000 (10:02 -0400)]
linux-emmc: update for internal API breakage.

Alek wrote his code before I made debug() imply LOG_DEBUG, so we need to
change that here as well.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoUpdate abidw for newer tools.
Peter Jones [Fri, 8 Jun 2018 19:14:27 +0000 (15:14 -0400)]
Update abidw for newer tools.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoabignore: work around an abidw bug
Peter Jones [Fri, 3 Aug 2018 13:56:01 +0000 (09:56 -0400)]
abignore: work around an abidw bug

Some versions of abignore mistakenly treat brackets as section headers,
thus ignoring the rest of the stanza after them.  It's fixed upstream,
but I don't have the newer version yet.  Moving the braces to be after
the change-kind and other things works around the issue.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoemmc_parser: add emmc_parser
Alek Du [Fri, 27 Jul 2018 13:31:01 +0000 (21:31 +0800)]
emmc_parser: add emmc_parser

Signed-off-by: Alek Du <alek.du@intel.com>
5 years agomakeguids: initialize memory
Bernhard M. Wiedemann [Tue, 24 Jul 2018 07:34:21 +0000 (09:34 +0200)]
makeguids: initialize memory

so that we do not write uninitialized memory into guids.bin and names.bin
which made the resulting libefivar.so.1.36 unreproducible.
See https://reproducible-builds.org/ for why this matters.

5 years agoDon't require NVME to have an EUI
Peter Jones [Mon, 16 Jul 2018 19:40:22 +0000 (15:40 -0400)]
Don't require NVME to have an EUI

Resolves: rhbz#1593784

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoCoverity still doesn't believe in error codes...
Peter Jones [Thu, 21 Jun 2018 20:18:32 +0000 (16:18 -0400)]
Coverity still doesn't believe in error codes...

So also test fbuf here.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoefiboot: parse_scsi_link(): fix the offset searching for the port
Peter Jones [Thu, 21 Jun 2018 18:23:40 +0000 (14:23 -0400)]
efiboot: parse_scsi_link(): fix the offset searching for the port

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoefiboot: fix a bad error check
Peter Jones [Thu, 21 Jun 2018 17:55:45 +0000 (13:55 -0400)]
efiboot: fix a bad error check

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoefiboot: don't error on unknown type with DEV_ABBREV_ONLY
Peter Jones [Thu, 21 Jun 2018 17:55:32 +0000 (13:55 -0400)]
efiboot: don't error on unknown type with DEV_ABBREV_ONLY

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoefiboot: Make the device node skipping code pass coverity.
Peter Jones [Thu, 21 Jun 2018 17:33:26 +0000 (13:33 -0400)]
efiboot: Make the device node skipping code pass coverity.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMake the debug() code less intrusive
Peter Jones [Thu, 21 Jun 2018 17:32:28 +0000 (13:32 -0400)]
Make the debug() code less intrusive

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoTry even harder to convince coverity that get_file isn't leaking memory...
Peter Jones [Thu, 21 Jun 2018 16:23:20 +0000 (12:23 -0400)]
Try even harder to convince coverity that get_file isn't leaking memory...

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoPacify clang analyzer just a little.
Peter Jones [Thu, 21 Jun 2018 15:13:39 +0000 (11:13 -0400)]
Pacify clang analyzer just a little.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoIf we can't parse part of the device link, skip it and set DEV_ABBREV_ONLY
Peter Jones [Wed, 20 Jun 2018 21:00:24 +0000 (17:00 -0400)]
If we can't parse part of the device link, skip it and set DEV_ABBREV_ONLY

If we can't parse some part of the device symlink, we can't write a full
device path, but we can write an abbreviated HD() or File() path.  So if
we've exausted all possibilities, skip to the next node, set
DEV_ABBREV_ONLY in the device's flags, and try parsing again.  Then when
creator.c checks if that flag conflicts, it'll throw an error if it
does.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMake a linux device root for SOC devices that use FDT.
Peter Jones [Wed, 20 Jun 2018 20:16:35 +0000 (16:16 -0400)]
Make a linux device root for SOC devices that use FDT.

Add parsing for FDT devices in sysfs.  These devices have to use HD() or
File() because we don't have a way to express FDT nodes in a Device
Path.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMake a way to say "-e 3" isn't viable for a kind of device.
Peter Jones [Wed, 20 Jun 2018 20:16:00 +0000 (16:16 -0400)]
Make a way to say "-e 3" isn't viable for a kind of device.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMake a platform ACPI root parser separate from PCI roots.
Peter Jones [Wed, 20 Jun 2018 18:45:14 +0000 (14:45 -0400)]
Make a platform ACPI root parser separate from PCI roots.

Because apparently PNP0A03 and PNP0A0C weren't good enough.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove ACPI ID parsing to a shared location.
Peter Jones [Wed, 20 Jun 2018 18:43:32 +0000 (14:43 -0400)]
Move ACPI ID parsing to a shared location.

This is getting out of PCI because we have some other platforms that do
ACPI root parsing, but don't use the PCI roots.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoGive linux-*'s ->parse() functions the unmodified device link as well
Peter Jones [Wed, 20 Jun 2018 18:37:14 +0000 (14:37 -0400)]
Give linux-*'s ->parse() functions the unmodified device link as well

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoImprove ACPI device path formatting
Peter Jones [Wed, 20 Jun 2018 18:27:11 +0000 (14:27 -0400)]
Improve ACPI device path formatting

This factors a bunch of the duplication out to another function, which
also does a better job of it.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoFix a makeguids building problem with generics.h.
Peter Jones [Wed, 20 Jun 2018 18:12:42 +0000 (14:12 -0400)]
Fix a makeguids building problem with generics.h.

Guard generics.h with EFIVAR_BUILD_ENVIRONMENT to keep it from
interfering with the makeguids build if libefivar.so isn't around
already.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMake path-helpers.c also import fix_coverity.h
Peter Jones [Thu, 14 Jun 2018 16:15:03 +0000 (12:15 -0400)]
Make path-helpers.c also import fix_coverity.h

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMake efidp_make_file() have even more, better input constraints.
Peter Jones [Wed, 13 Jun 2018 13:25:58 +0000 (09:25 -0400)]
Make efidp_make_file() have even more, better input constraints.

This is all in the effort to convince coverity that it doesn't
dereference buf when size==0, which it already doesn't.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoTry to convince covscan that sysfs_read_file() doesn't leak on error.
Peter Jones [Wed, 13 Jun 2018 13:15:17 +0000 (09:15 -0400)]
Try to convince covscan that sysfs_read_file() doesn't leak on error.

Basically, covscan gets confused about some of our return paths and
doesn't  think the error condition correlates with not having allocated
(or having freed) the ram we're using to pass the file data back.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoPromote _make_hd_dn() to make_hd_dn() and get rid of the wrapper.
Peter Jones [Tue, 12 Jun 2018 18:36:20 +0000 (14:36 -0400)]
Promote _make_hd_dn() to make_hd_dn() and get rid of the wrapper.

The wrapper is just hiding what the code's doing, and all the other code
around where we use it does the same thing anyway.  This hopefully
convinces coverity we're not really dereferencing "buf" there unless
it's nonzero.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoefivar: Fix some types in -L behavior to pacify coverity.
Peter Jones [Tue, 12 Jun 2018 18:36:20 +0000 (14:36 -0400)]
efivar: Fix some types in -L behavior to pacify coverity.

Coverity doesn't realize that efi_well_known_guids is /actually/ an
array, because we didn't tell it so.  So fix the declaration so we've
told it so.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoPacify some coverity nits.
Peter Jones [Tue, 12 Jun 2018 18:36:20 +0000 (14:36 -0400)]
Pacify some coverity nits.

Coverity has trouble tracking data flow sometimes, and believes that
sysfs_readlink() and read_sysfs_file() will sometimes return >= 0 when
the buffer has not been filled out.  This changes the check to also test
for a NULL pointer, hopefully pacifying it.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove verbosity headers to be public
Peter Jones [Tue, 12 Jun 2018 18:36:20 +0000 (14:36 -0400)]
Move verbosity headers to be public

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove the syntastic file I use out of the repo
Peter Jones [Tue, 12 Jun 2018 18:36:20 +0000 (14:36 -0400)]
Move the syntastic file I use out of the repo

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoBump version to 36
Peter Jones [Fri, 8 Jun 2018 19:14:27 +0000 (15:14 -0400)]
Bump version to 36

- Add NVDIMM support
- Re-written linux interface parser to handle how devices are
  partitioned better, and for cleaner code, with one file per device
  type.
- lots of verbosity updates
- better CI
- analysis with clang's analyzer as well as coverity
- Better handling of immutable bits in sysfs
- LIBEFIVAR_OPS=help
- lots of code cleanups.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMake ccc-analyzer get clang cflags
Peter Jones [Fri, 8 Jun 2018 19:04:45 +0000 (15:04 -0400)]
Make ccc-analyzer get clang cflags

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoFix some errors scan-build found.
Peter Jones [Fri, 8 Jun 2018 18:44:24 +0000 (14:44 -0400)]
Fix some errors scan-build found.

This fixes a couple of failures to check for NULL in string parsing, and
one failure to free a value in an error path.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agonvdimm: Use the namespace guid, not just the device guid
Peter Jones [Fri, 8 Jun 2018 17:44:37 +0000 (13:44 -0400)]
nvdimm: Use the namespace guid, not just the device guid

This makes long-form device paths for nvdimm be:

NVDIMM(pmem-namespace-guid)/NVDIMM(pmem-label-guid)/HD(...)/File(...)

It also conditionally removes our UUID swizzling, because nobody can
figure out what the correct encoding is, and only byteswaps if
LIBEFIBOOT_SWIZZLE_PMEM_UUID is set (to any value) in the environment.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoFix an edge case in finding the sysfs driver link
Peter Jones [Fri, 8 Jun 2018 18:06:28 +0000 (14:06 -0400)]
Fix an edge case in finding the sysfs driver link

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoUse the pci node's driver link to detect ATA in some cases
Peter Jones [Thu, 7 Jun 2018 20:19:22 +0000 (16:19 -0400)]
Use the pci node's driver link to detect ATA in some cases

5 years agoefivarfs: fix some minor immutability bugs
Peter Jones [Thu, 7 Jun 2018 20:18:09 +0000 (16:18 -0400)]
efivarfs: fix some minor immutability bugs

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoExpand tabs on the rest of linux.c
Peter Jones [Thu, 7 Jun 2018 17:47:43 +0000 (13:47 -0400)]
Expand tabs on the rest of linux.c

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoAlways build the .so.1 local symlink
Peter Jones [Thu, 7 Jun 2018 16:45:00 +0000 (12:45 -0400)]
Always build the .so.1 local symlink

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoaudit efi_error() for wrong newlines.
Peter Jones [Thu, 7 Jun 2018 16:43:51 +0000 (12:43 -0400)]
audit efi_error() for wrong newlines.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoUpdate our abixml files for new ABI bits and minor changes.
Peter Jones [Wed, 6 Jun 2018 21:52:53 +0000 (17:52 -0400)]
Update our abixml files for new ABI bits and minor changes.

Currently abidiff notices the following:

abidiff \
--suppr abignore \
--headers-dir2 /home/pjones/devel/github.com/efivar/master/src/include/efivar/ \
libefivar.abixml \
libefivar.so
Functions changes summary: 0 Removed, 1 Changed, 3 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

3 Added functions:

  'function FILE* efi_get_logfile()'    {efi_get_logfile@@LIBEFIVAR_1.36}
  'function int efi_get_verbose()'    {efi_get_verbose@@LIBEFIVAR_1.36}
  'function void efi_set_verbose(int, FILE*)'    {efi_set_verbose@@LIBEFIVAR_1.36}

1 function with some indirect sub-type change:

  [C]'function ssize_t efidp_make_acpi_hid_ex(uint8_t*, ssize_t, uint32_t, uint32_t, uint32_t, char*, char*, char*)' at <built-in>:263:1 has some indirect sub-type changes:
    parameter 6 of type 'char*' changed:
      in pointed to type 'char':
        entity changed from 'char' to 'const char'
        type size hasn't changed
    parameter 7 of type 'char*' changed:
      in pointed to type 'char':
        entity changed from 'char' to 'const char'
        type size hasn't changed
    parameter 8 of type 'char*' changed:
      in pointed to type 'char':
        entity changed from 'char' to 'const char'
        type size hasn't changed

The 3 added functions are as they should be.  The
efidp_make_acpi_hid_ex() changes are all from making arguments "const"
that weren't before, and that's fine as well.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoAdd a make target to rebuild our abidw .abixml files
Peter Jones [Wed, 6 Jun 2018 21:37:03 +0000 (17:37 -0400)]
Add a make target to rebuild our abidw .abixml files

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoRebuild efivar-35's abixml files with newer abidw.
Peter Jones [Wed, 6 Jun 2018 21:27:13 +0000 (17:27 -0400)]
Rebuild efivar-35's abixml files with newer abidw.

abidiff is not that good at recognizing its own format changes, so if we
just do the normal abicheck we get a lot of:

  [C]'function ssize_t efidp_make_atapi(uint8_t*, ssize_t, uint16_t, uint16_t, uint16_t)' has some indirect sub-type changes:
    parameter 6 of type 'uint8_t*' was added
    parameter 7 of type 'typedef ssize_t' was added
    parameter 8 of type 'typedef uint16_t' was added
    parameter 9 of type 'typedef uint16_t' was added
    parameter 10 of type 'typedef uint16_t' was added

Which is obviously just plain wrong (efidp_make_atapi()'s arguments have
not changed at all, and it still has only 5 of them.)

So the answer is to re-build efivar-35's .abixml files with newer abidw,
and *then* do abicheck.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agolibefiboot: make everything use "struct device" and kill "struct disk_info"
Peter Jones [Wed, 6 Jun 2018 21:18:31 +0000 (17:18 -0400)]
libefiboot: make everything use "struct device" and kill "struct disk_info"

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agolinux.h: Make some decls HIDDEN as they should be
Peter Jones [Wed, 6 Jun 2018 21:12:58 +0000 (17:12 -0400)]
linux.h: Make some decls HIDDEN as they should be

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoFix decl for get_sector_size()
Peter Jones [Wed, 6 Jun 2018 21:12:16 +0000 (17:12 -0400)]
Fix decl for get_sector_size()

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoConstify efidp_make_acpi_hid_ex() args and make its prototype more readible
Peter Jones [Wed, 6 Jun 2018 21:09:30 +0000 (17:09 -0400)]
Constify efidp_make_acpi_hid_ex() args and make its prototype more readible

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove the PMEM device parser to linux-pmem.c
Peter Jones [Wed, 6 Jun 2018 20:53:37 +0000 (16:53 -0400)]
Move the PMEM device parser to linux-pmem.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoAdd a PCI parser that's independent of the other stuff.
Peter Jones [Wed, 6 Jun 2018 20:51:08 +0000 (16:51 -0400)]
Add a PCI parser that's independent of the other stuff.

This doesn't actually remove the old one, but a later patch will when
it's replacing all that stuff.

This won't actually *work* yet, either, because the infrastructure to
use it (replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove SAS parsing to linux-sas.c
Peter Jones [Wed, 6 Jun 2018 20:47:11 +0000 (16:47 -0400)]
Move SAS parsing to linux-sas.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove SATA parsing to linux-sata.c
Peter Jones [Wed, 6 Jun 2018 20:45:21 +0000 (16:45 -0400)]
Move SATA parsing to linux-sata.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove nvme parsing to linux-nvme.c
Peter Jones [Wed, 6 Jun 2018 20:43:30 +0000 (16:43 -0400)]
Move nvme parsing to linux-nvme.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove virtblk device parsing to linux-virtblk.c
Peter Jones [Wed, 6 Jun 2018 20:41:50 +0000 (16:41 -0400)]
Move virtblk device parsing to linux-virtblk.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove i2o device parsing to linux-i2o.c
Peter Jones [Wed, 6 Jun 2018 20:40:05 +0000 (16:40 -0400)]
Move i2o device parsing to linux-i2o.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove traditional SCSI parsing to linux-scsi.c
Peter Jones [Wed, 6 Jun 2018 20:37:46 +0000 (16:37 -0400)]
Move traditional SCSI parsing to linux-scsi.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove ATA parsing to linux-ata.c
Peter Jones [Wed, 6 Jun 2018 20:32:26 +0000 (16:32 -0400)]
Move ATA parsing to linux-ata.c

This won't actually *work* yet, because the infrastructure to use it
(replacing "struct disk_info") won't land for a few more patches.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoAdd a (not great) macro to print parser debugging arrows.
Peter Jones [Thu, 7 Jun 2018 17:07:55 +0000 (13:07 -0400)]
Add a (not great) macro to print parser debugging arrows.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoAdd "struct device" in preperation for removing "struct disk_info".
Peter Jones [Wed, 6 Jun 2018 20:15:35 +0000 (16:15 -0400)]
Add "struct device" in preperation for removing "struct disk_info".

Also adds src/linux-*.c to the makefile

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoefi_loadopt_create(): add some debugging
Peter Jones [Wed, 6 Jun 2018 20:55:58 +0000 (16:55 -0400)]
efi_loadopt_create(): add some debugging

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoucs2.h: there's no reason ucs2_to_utf8 shouldn't malloc directly.
Peter Jones [Wed, 30 May 2018 20:59:46 +0000 (16:59 -0400)]
ucs2.h: there's no reason ucs2_to_utf8 shouldn't malloc directly.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agorename the pci_root_info fields to match the struct name
Peter Jones [Tue, 22 May 2018 14:04:52 +0000 (10:04 -0400)]
rename the pci_root_info fields to match the struct name

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMove get_sector_size() to the linux specific code
Peter Jones [Tue, 22 May 2018 13:57:25 +0000 (09:57 -0400)]
Move get_sector_size() to the linux specific code

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agolinux.h: add some more sysfs helpers, and improve their error handling.
Peter Jones [Tue, 22 May 2018 13:55:05 +0000 (09:55 -0400)]
linux.h: add some more sysfs helpers, and improve their error handling.

... this also moves them from util.h

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoMore fixups for CONSTRUCTOR/DESTRUCTOR/HIDDEN/PUBLIC/etc.
Peter Jones [Mon, 21 May 2018 19:53:30 +0000 (15:53 -0400)]
More fixups for CONSTRUCTOR/DESTRUCTOR/HIDDEN/PUBLIC/etc.

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoAdd some helpers for file path mangling
Peter Jones [Mon, 21 May 2018 18:23:52 +0000 (14:23 -0400)]
Add some helpers for file path mangling

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoutil.h: Add error reporting in read_file()
Peter Jones [Mon, 21 May 2018 15:18:00 +0000 (11:18 -0400)]
util.h: Add error reporting in read_file()

Signed-off-by: Peter Jones <pjones@redhat.com>
5 years agoTemporary hack in get_partition_number
Peter Jones [Wed, 6 Jun 2018 20:30:08 +0000 (16:30 -0400)]
Temporary hack in get_partition_number

This code has been wrong for a while, but it's getting removed, so
really don't bother *fixing* it so much as appeasing newer gcc's
noticing that it's uninitialized.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMake LIBEFIVAR_OPS=help work
Peter Jones [Mon, 21 May 2018 13:40:01 +0000 (09:40 -0400)]
Make LIBEFIVAR_OPS=help work

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd some more debug facilities.
Peter Jones [Thu, 26 Apr 2018 19:57:48 +0000 (15:57 -0400)]
Add some more debug facilities.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd hexdumper
Peter Jones [Thu, 26 Apr 2018 19:05:38 +0000 (15:05 -0400)]
Add hexdumper

6 years agoMake all of our Make.* files have vim:ft=make
Peter Jones [Mon, 21 May 2018 14:08:55 +0000 (10:08 -0400)]
Make all of our Make.* files have vim:ft=make

... except Make.version because it's fully automated.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agofix some dumb stuff in 'make install' targets
Peter Jones [Mon, 21 May 2018 13:53:15 +0000 (09:53 -0400)]
fix some dumb stuff in 'make install' targets

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agogpt.h: minor cleanups (mostly formatting/whitespace)
Peter Jones [Fri, 18 May 2018 17:23:01 +0000 (13:23 -0400)]
gpt.h: minor cleanups (mostly formatting/whitespace)

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoget_partition_info(): fix the return code error path.
Peter Jones [Wed, 18 Apr 2018 21:47:26 +0000 (17:47 -0400)]
get_partition_info(): fix the return code error path.

Half the code thinks >= 0 is success, half the code things <= 0 is
success...

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoclang: ?e64_to_cpu() and cpu_to_?e64(): cast to uint64_t.
Peter Jones [Thu, 17 May 2018 21:57:10 +0000 (17:57 -0400)]
clang: ?e64_to_cpu() and cpu_to_?e64(): cast to uint64_t.

On x86_64, clang makes __builtin_bswap64() return "unsigned long"
instead of "unsigned long long", so using PRIx64 complains all over the
place.  Casting to uint64_t satisfies both compilers.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoMore aggressively use macros for compiler attributes
Peter Jones [Thu, 17 May 2018 20:37:57 +0000 (16:37 -0400)]
More aggressively use macros for compiler attributes

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoSimplify our include files
Peter Jones [Thu, 17 May 2018 20:31:59 +0000 (16:31 -0400)]
Simplify our include files

Make everything just include src/efivar.h or src/efiboot.h, and let
those sort out the correct things to include.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoutil.h: whitespace cleanup
Peter Jones [Thu, 19 Apr 2018 14:25:16 +0000 (10:25 -0400)]
util.h: whitespace cleanup

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agogpt: get rid of ad-hoc warning reporting; use efi_error()
Peter Jones [Wed, 18 Apr 2018 21:46:45 +0000 (17:46 -0400)]
gpt: get rid of ad-hoc warning reporting; use efi_error()

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agogpt: don't use the __ versions of cpu_to_le??()/le??_to_cpu()
Peter Jones [Thu, 17 May 2018 20:34:49 +0000 (16:34 -0400)]
gpt: don't use the __ versions of cpu_to_le??()/le??_to_cpu()

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoefivar: fix efi_well_known_guids and efi_well_known_guids_end definitions
Peter Jones [Thu, 17 May 2018 19:10:40 +0000 (15:10 -0400)]
efivar: fix efi_well_known_guids and efi_well_known_guids_end definitions

From github:

build command: make CROSS_COMPILE=aarch64-linux-gnu- prefix=/home/b58867/Desktop/ls1043ardb/efivar/efivar_arm64 static

compilation error:
aarch64-linux-gnu-gcc -O2 -flto -g3 -I/home/b58867/Desktop/ls1043ardb/efivar/src/include/ -specs=/home/b58867/Desktop/ls1043ardb/efivar/gcc.specs -L. -Wl,-z,muldefs -static -o efivar-static efivar.c dp.static.o dp-acpi.static.o dp-hw.static.o dp-media.static.o dp-message.static.o efivarfs.static.o error.static.o export.static.o guid.static.o guids.static.o guid-symbols.static.o lib.static.o vars.static.o -ldl
guid.c:112:24: error: type of ‘efi_well_known_guids_end’ does not match original declaration [-Werror]
extern struct guidname efi_well_known_guids_end
^
efivar.c:490:28: note: previously declared here
extern struct guidname *efi_well_known_guids_end;
^
efivar.c:489:27: error: type of ‘efi_well_known_guids’ does not match original declaration [-Werror]
extern struct guidname efi_well_known_guids[];
^
guid.c:108:24: note: previously declared here
extern struct guidname efi_well_known_guids
^
lto1: all warnings being treated as errors
lto-wrapper: fatal error: aarch64-linux-gnu-gcc returned 1 exit status

Fixes github issue #102

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoFix our pkg-config-ldflags invocation.
Peter Jones [Wed, 18 Apr 2018 21:44:22 +0000 (17:44 -0400)]
Fix our pkg-config-ldflags invocation.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoWe don't use list.h at all; axe it.
Peter Jones [Wed, 9 May 2018 20:14:52 +0000 (16:14 -0400)]
We don't use list.h at all; axe it.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAnother minor docs typo fix.
Peter Jones [Thu, 17 May 2018 15:44:25 +0000 (11:44 -0400)]
Another minor docs typo fix.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agominor correction to the efi_variable_import and efi_variable_export man-page
Robert Bisewski [Sun, 29 Apr 2018 19:08:45 +0000 (14:08 -0500)]
minor correction to the efi_variable_import and efi_variable_export man-page

6 years agorewrite efivarfs_set_variable() [9896c26c7e68-based]
Laszlo Ersek [Wed, 16 May 2018 17:21:27 +0000 (19:21 +0200)]
rewrite efivarfs_set_variable() [9896c26c7e68-based]

This patch rewrites the efivarfs_set_variable() function, to address the
following issues:

- a size_t value is printed with %zd -- size_t is unsigned, so it should
  be printed with %zu or %zx,

- a VLA is used for storing input of basically unbounded size -- we should
  use a range-checked malloc() call instead,

- the efivarfs file is opened for writing while it may be immutable --
  this is the trickiest issue to resolve,

- passing just O_APPEND|O_CREAT to open() is undefined -- O_WRONLY is
  required, and O_APPEND and (O_CREAT | O_EXCL) should both be independent
  of it (and of each other),

- some error branches call efi_error() without setting errno first,

- the variable is removed on any write failure, even if we didn't create
  the variable -- failed writes are expected to be atomic (from the kernel
  side and from the firmware side) and not to leave behind side effects;
  so only delete the variable on error if we created it.

A small helper function efivarfs_make_fd_mutable() is introduced as well.

(It's best to review the new efivarfs_set_variable() function in its
entirety, with the patch applied, rather than comparing old vs. new, hunk
for hunk.)

Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1516599
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
6 years agoSilence some trivial clang-analyzer/coverity complaints.
Peter Jones [Tue, 17 Apr 2018 17:49:19 +0000 (13:49 -0400)]
Silence some trivial clang-analyzer/coverity complaints.

One minor memory leak in /usr/bin/efivar, a couple of places where the
analyzers make assumptions without being able to figure out the data
flow.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agodp-acpi: improve formatting of AcpiEx() device paths.
Peter Jones [Tue, 17 Apr 2018 17:44:58 +0000 (13:44 -0400)]
dp-acpi: improve formatting of AcpiEx() device paths.

This also fixes a minor scan-build complaint about cidlen being assigned
but not used.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoAdd a clang-analyzer scan-build make targets as well.
Peter Jones [Tue, 17 Apr 2018 17:26:45 +0000 (13:26 -0400)]
Add a clang-analyzer scan-build make targets as well.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoWork around coverity being a pretty lazy and poor tool.
Peter Jones [Tue, 17 Apr 2018 16:28:24 +0000 (12:28 -0400)]
Work around coverity being a pretty lazy and poor tool.

I mean, come on, at least dynamically import the types you've missed
from the version of GCC that's installed on the system and you're
pretending to emulate.

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoUpdate travis to use some better build scripts
Peter Jones [Wed, 11 Apr 2018 20:46:23 +0000 (16:46 -0400)]
Update travis to use some better build scripts

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoSimplify the docker/travis stuff some
Peter Jones [Mon, 9 Apr 2018 19:33:44 +0000 (15:33 -0400)]
Simplify the docker/travis stuff some

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agotry to make travis work again...
Peter Jones [Mon, 9 Apr 2018 19:04:13 +0000 (15:04 -0400)]
try to make travis work again...

6 years agoBump version to 35
Peter Jones [Mon, 9 Apr 2018 18:52:25 +0000 (14:52 -0400)]
Bump version to 35

Signed-off-by: Peter Jones <pjones@redhat.com>
6 years agoDon't use _Generic because gcc 4.x doesn't have it...
Peter Jones [Mon, 13 Mar 2017 17:36:55 +0000 (13:36 -0400)]
Don't use _Generic because gcc 4.x doesn't have it...

Signed-off-by: Peter Jones <pjones@redhat.com>