OSDN Git Service

android-x86/external-efivar.git
7 years agoDon't use __pure__ on efidp_*() functions.
Peter Jones [Tue, 27 Sep 2016 19:41:21 +0000 (15:41 -0400)]
Don't use __pure__ on efidp_*() functions.

The compiler keeps introducing off by one errors with -O2 but not with
-Og and I'm not sure why, so just don't do this optimization.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agolinux: Fix NVMe EUI parsing from sysfs
Peter Jones [Tue, 27 Sep 2016 18:21:13 +0000 (14:21 -0400)]
linux: Fix NVMe EUI parsing from sysfs

The kernel uses space as separators, whereas for some reason I'd coded
the parser to expect dashes.

Fixes the last thing from https://github.com/rhinstaller/efibootmgr/issues/48

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoBump version to 29
Peter Jones [Tue, 27 Sep 2016 18:01:18 +0000 (14:01 -0400)]
Bump version to 29

- Use -pie not -PIE in our linker config
- Fix some overflow checks for gcc < 5.x
- Make variable class probes other than the first one actually work
- Move -flto to CFLAGS
- Pack all of the efi device path headers
- Fix redundant decl of efi_guid_zero()

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefivar-dp.h: Actually add the packed attribute everywhere.
Peter Jones [Tue, 27 Sep 2016 17:48:14 +0000 (13:48 -0400)]
efivar-dp.h: Actually add the packed attribute everywhere.

Apparently 9b3155b095 was not enough, so pack all the device path
structures.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoFix redundant decl of efi_guid_zero.
Peter Jones [Tue, 13 Sep 2016 20:30:40 +0000 (16:30 -0400)]
Fix redundant decl of efi_guid_zero.

This fixes github issue #62

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoAll of our efi device path headers need to be packed.
Peter Jones [Tue, 13 Sep 2016 20:20:49 +0000 (16:20 -0400)]
All of our efi device path headers need to be packed.

So just pack efidp_header and be done with it.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoMove -flto to CFLAGS
Mike Gilbert [Tue, 23 Aug 2016 14:14:39 +0000 (10:14 -0400)]
Move -flto to CFLAGS

LTO is an optimization that is not always desired. This allows it to be
easily disabled.

7 years agolibefivar/libs.c:probe(): Fix the case where the first probe fails.
Peter Jones [Mon, 22 Aug 2016 15:42:50 +0000 (11:42 -0400)]
libefivar/libs.c:probe(): Fix the case where the first probe fails.

When adding efi_set_error() support, I accidentally changed it to treat
a probe failure as a success, which winds up meaning you always try
efivarfs even if the probe failed.

Fixes github issue https://github.com/rhinstaller/efibootmgr/issues/54
Fixes https://bugs.gentoo.org/show_bug.cgi?id=591864

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoFix some cases of our overflow checkers in add_int() etc for gcc < 5
Peter Jones [Mon, 22 Aug 2016 15:20:07 +0000 (11:20 -0400)]
Fix some cases of our overflow checkers in add_int() etc for gcc < 5

Basically do all the comparisons in our add checkers in "unsigned long
long" space.

Resolves github issue #58.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agogcc.specs: link: change '-PIE' to '-pie' and drop '-PIC'
Mike Gilbert [Sat, 20 Aug 2016 22:13:32 +0000 (18:13 -0400)]
gcc.specs: link: change '-PIE' to '-pie' and drop '-PIC'

The ld manual does not mention -PIE or -PIC, and ld.gold fails when passed
either option.

The gcc manual mentions that -pie should be passed when linking objects
compiled with -fPIE.

Resolves: https://github.com/rhinstaller/efivar/issues/57

7 years agoBump version to 28
Peter Jones [Wed, 17 Aug 2016 13:01:38 +0000 (09:01 -0400)]
Bump version to 28

But bump our soname to lib$FOO.1 so it doesn't change constantly.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoMake soname always libfoo.1 not libfoo.102312231.
Peter Jones [Wed, 17 Aug 2016 12:59:58 +0000 (08:59 -0400)]
Make soname always libfoo.1 not libfoo.102312231.

Having the minor version change all the time makes sense.  Having the
soname change does not.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefivar 27
Peter Jones [Tue, 16 Aug 2016 20:33:03 +0000 (16:33 -0400)]
efivar 27

- Bug fix for 086eeb17 in efivar 26.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agocreator/find_file(): fix the fix in 086eeb17
Peter Jones [Tue, 16 Aug 2016 20:31:07 +0000 (16:31 -0400)]
creator/find_file(): fix the fix in 086eeb17

086eeb17 was right about needing a continue, but it still did actually
need >= instead of !=, because it's looking for a subset.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoutil.h: add int_add for 32-bit platforms
Peter Jones [Thu, 11 Aug 2016 19:46:06 +0000 (15:46 -0400)]
util.h: add int_add for 32-bit platforms

7 years agoRelease efivar 26
Peter Jones [Thu, 11 Aug 2016 15:47:24 +0000 (11:47 -0400)]
Release efivar 26

- Rework version numbers.
- Add error tracking API.
- Remove use of deprecated readdir_r
- SATA device path fixes.
- Use symmacros.h to make newer compilers happy
- Fix a bug in efidp_size() double-counting End nodes sometimes.
- Handle nonnull comparisons in the headers more gracefully.

7 years agogcc: handle the nonnull comparison issue more gracefully.
Peter Jones [Thu, 11 Aug 2016 18:09:44 +0000 (14:09 -0400)]
gcc: handle the nonnull comparison issue more gracefully.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefi_loadopt_optional_data_size: add efi_error() trace code
Peter Jones [Thu, 11 Aug 2016 15:45:45 +0000 (11:45 -0400)]
efi_loadopt_optional_data_size: add efi_error() trace code

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefidp_size: don't count the end node twice.
Peter Jones [Thu, 11 Aug 2016 15:44:37 +0000 (11:44 -0400)]
efidp_size: don't count the end node twice.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agolibefivar: use sysmacros.h
Peter Jones [Wed, 10 Aug 2016 20:47:41 +0000 (16:47 -0400)]
libefivar: use sysmacros.h

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoUse efi_error() at lots of places.
Peter Jones [Tue, 9 Aug 2016 14:59:04 +0000 (10:59 -0400)]
Use efi_error() at lots of places.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefivar: add an api to inspect errors that occurred in more detail.
Peter Jones [Thu, 4 Aug 2016 17:48:34 +0000 (13:48 -0400)]
efivar: add an api to inspect errors that occurred in more detail.

I'm tired of manually debugging everything in the world, so add this API
that gives our callers more detail and verbosity about errors that
occur.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agodp.h: make our format() macro adjust "off" automatically.
Peter Jones [Tue, 9 Aug 2016 15:06:40 +0000 (11:06 -0400)]
dp.h: make our format() macro adjust "off" automatically.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefivar-dp.h: add a bunch of compiler hints as function attributes.
Peter Jones [Tue, 9 Aug 2016 14:47:47 +0000 (10:47 -0400)]
efivar-dp.h: add a bunch of compiler hints as function attributes.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefivar-dp.h: make our iterators/size checkers a bit saner
Peter Jones [Tue, 9 Aug 2016 14:44:07 +0000 (10:44 -0400)]
efivar-dp.h: make our iterators/size checkers a bit saner

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agodp-message: make format_ipv6_port_helper() use the common formatting macros.
Peter Jones [Tue, 9 Aug 2016 14:00:24 +0000 (10:00 -0400)]
dp-message: make format_ipv6_port_helper() use the common formatting macros.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agodp-*: fix some wrong size_t vs ssize_t usage.
Peter Jones [Tue, 9 Aug 2016 13:55:06 +0000 (09:55 -0400)]
dp-*: fix some wrong size_t vs ssize_t usage.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoutil.h: add some math utilities
Peter Jones [Fri, 5 Aug 2016 21:06:29 +0000 (17:06 -0400)]
util.h: add some math utilities

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agosata device paths: treat the kernel's ata device number as 1-indexed.
Peter Jones [Thu, 4 Aug 2016 15:24:15 +0000 (11:24 -0400)]
sata device paths: treat the kernel's ata device number as 1-indexed.

Fix yet another place where this being 1-indexed in the linux kernel but
not anywhere else burns us.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoCorrectly handle Sata() device paths PMPN sentinal value.
Peter Jones [Thu, 4 Aug 2016 15:21:22 +0000 (11:21 -0400)]
Correctly handle Sata() device paths PMPN sentinal value.

We rarely wind up writing a full Sata() device path, so nobody noticed
that for the SATA PMPN (port multiplier number) sentinal value that
means "no port multiplier", i.e. the normal case, we were storing 0x8000
instead of 0xffff, and that's not correct.

Partially fixes github issue#47 .

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agocreator/find_file(): fix an incorrect error that gets raised.
Peter Jones [Thu, 4 Aug 2016 17:49:57 +0000 (13:49 -0400)]
creator/find_file(): fix an incorrect error that gets raised.

In find_file(), when we're trying to find the device that matches a
mountpoint, we incorrectly raise an error when we find an entry that's
got a longer name than the one we want.  This is incorrect - it's a
special case of what Lans Zhang was fixing in 8eac2d51, in fact.

This case should just reject *that* entry, not set an error and end the
iteration.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoRemove use of deprecated readdir_r
Andreas Schwab [Tue, 12 Jul 2016 08:34:50 +0000 (10:34 +0200)]
Remove use of deprecated readdir_r

Signed-off-by: Andreas Schwab <schwab@suse.de>
7 years agoGet rid of "0." and just make the next version be 25.
Peter Jones [Tue, 19 Jul 2016 15:02:01 +0000 (11:02 -0400)]
Get rid of "0." and just make the next version be 25.

Seemed easier than deciding what a 1.0 will look like ;)

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoallow deprecated declarations for now to let readdir_r work...
Peter Jones [Thu, 30 Jun 2016 15:32:03 +0000 (11:32 -0400)]
allow deprecated declarations for now to let readdir_r work...

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoRelease 0.24
Peter Jones [Thu, 30 Jun 2016 14:50:32 +0000 (10:50 -0400)]
Release 0.24

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoPromote efi_guid_cmp() and friends to not be inlined.
Peter Jones [Thu, 30 Jun 2016 14:34:14 +0000 (10:34 -0400)]
Promote efi_guid_cmp() and friends to not be inlined.

Some compilers seem to get confused with the current efi_guid_cmp()
invocation, so just make it real API.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoFix a couple of places where we overuse const.
Peter Jones [Thu, 30 Jun 2016 14:25:28 +0000 (10:25 -0400)]
Fix a couple of places where we overuse const.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoMake efivar-dp.h inlines compatible with --std=c89
Peter Jones [Thu, 30 Jun 2016 14:16:17 +0000 (10:16 -0400)]
Make efivar-dp.h inlines compatible with --std=c89

Some people still insist on compiling programs with a C standard from
the beginning of time, and that doesn't allow mixed declarations and
code.

We don't heavily depend on that, so this just fixes up the places where
we use it.

Fixes issue #54

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoclang++ efi_guid_is_empty alias issue
Jeremy Compostella [Wed, 25 May 2016 14:50:47 +0000 (16:50 +0200)]
clang++ efi_guid_is_empty alias issue

As efi_guid_is_zero is static function, its name is mangled and the
__attribute__ ((weak, alias ("efi_guid_is_zero"))) is failing with
clang++.

Making efi_guid_is_zero a non-static function.

Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
7 years agoloadopt: add some clarifying comments
Peter Jones [Tue, 24 May 2016 15:32:57 +0000 (11:32 -0400)]
loadopt: add some clarifying comments

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoefivar: typo, missing comma
Peter Jones [Tue, 24 May 2016 14:58:36 +0000 (10:58 -0400)]
efivar: typo, missing comma

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agolibefivar: make it possible to override the filesystem paths
Peter Jones [Thu, 19 May 2016 18:04:32 +0000 (14:04 -0400)]
libefivar: make it possible to override the filesystem paths

7 years agoFix some deginerate load option parsing cases.
Peter Jones [Thu, 19 May 2016 14:54:06 +0000 (10:54 -0400)]
Fix some deginerate load option parsing cases.

Signed-off-by: Peter Jones <pjones@redhat.com>
7 years agoMake it easier to turn optimization off without other changes.
Peter Jones [Thu, 19 May 2016 14:53:51 +0000 (10:53 -0400)]
Make it easier to turn optimization off without other changes.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefivar: add decimal variable printing support
Ioan-Adrian Ratiu [Tue, 17 May 2016 11:47:34 +0000 (14:47 +0300)]
efivar: add decimal variable printing support

Default printing behaviour remains unchanged, however when one of the
print-decimal/d args is given, efivar will print in a simpler less
terse decimal format.

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
8 years agoefivar: add variable writing support
Ioan-Adrian Ratiu [Tue, 17 May 2016 11:01:51 +0000 (14:01 +0300)]
efivar: add variable writing support

Transform append_variable() into a more generic edit_variable()
to handle both append and writing based on a flag. Define a new
write/w parameter which triggers the writing logic.

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
8 years agoInclude sys/sysmacros.h when sys/types.h does not define major
Mike Gilbert [Fri, 15 Apr 2016 21:58:15 +0000 (17:58 -0400)]
Include sys/sysmacros.h when sys/types.h does not define major

glibc is planning to drop this from sys/types.h.

8 years agoMake.rules: fix build with make <= 3.81
Erico Nunes [Wed, 23 Mar 2016 00:43:44 +0000 (21:43 -0300)]
Make.rules: fix build with make <= 3.81

Building with host make 3.81 resulted in an issue where src/efivar.pc
was never generated.
Even by running 'make efivar.pc' inside the src directory, make always
returned that there was nothing to do.
This was not observed when using make 3.82 or 4.x.
It is apparently caused by the assignment operators in the multi-line
defines in Make.rules, which do not seem to be supported by make 3.81.
By omitting the assignment operators, the rule works with both versions
of make.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
8 years agoefidp_format_device_path: add enough input argument checking to avoid coredump
Aaron Luft [Wed, 16 Mar 2016 22:53:59 +0000 (18:53 -0400)]
efidp_format_device_path: add enough input argument checking to avoid coredump

8 years agoDebug some of our immutable bit hackery.
Peter Jones [Mon, 2 May 2016 20:46:23 +0000 (16:46 -0400)]
Debug some of our immutable bit hackery.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoClean up some license confusion.
Peter Jones [Tue, 12 Apr 2016 13:54:16 +0000 (09:54 -0400)]
Clean up some license confusion.

Basically when some of this got relicensed as LGPL, some of the license
text didn't get changed correctly.  But it's still all LGPL, because
that's what COPYING says.

So fix the language in the individual files.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefivar: make efi loadopt path functions have useful limit checks
Peter Jones [Thu, 10 Mar 2016 20:51:31 +0000 (15:51 -0500)]
libefivar: make efi loadopt path functions have useful limit checks

Make efi_loadopt_pathlen() and efi_loadopt_path() actually bounds check
against something useful, not just "does some possibly unallocated space
extend into some other possibly unallocated space".

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoMake sure -D_GNU_SOURCE is used on clang.
Peter Jones [Thu, 10 Mar 2016 16:08:30 +0000 (11:08 -0500)]
Make sure -D_GNU_SOURCE is used on clang.

asprintf() requires _GNU_SOURCE to be defined, because the C standard
library is a joke.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoFix our "make deps" dependencies.
Peter Jones [Thu, 10 Mar 2016 16:00:14 +0000 (11:00 -0500)]
Fix our "make deps" dependencies.

This should fix issue #32, finally.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoFixes for compilation with gcc 6
Steve McIntyre [Wed, 20 Jan 2016 17:44:28 +0000 (17:44 +0000)]
Fixes for compilation with gcc 6

linux.c: Fix warnings about dereferencing type-punned pointers: switch
from char * to uint8_t * in various places

(Adapted from
https://github.com/steve-mcintyre/efivar-devel/commit/67320177d01b872df4cc714a5fe20f6cadc54319
aka c82b13556ae142cec420258b8563f0dabb3dad83 , where it originally
lived, by pjones.)

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoPass correct expected devpath to efi_va_generate_file_device_path_from_esp
Mario Limonciello [Sat, 5 Mar 2016 22:14:52 +0000 (16:14 -0600)]
Pass correct expected devpath to efi_va_generate_file_device_path_from_esp

When using efi_generate_file_device_path, the devpath found by find_file
points to a partition.

efi_va_generate_file_device_path_from_esp and further downsteam code
expects to find the parent node of that partition.

Prior to this fix, tools that used efi_generate_file_device_path would
generate invalid paths with NVMe disks.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoUse detected partition number in call to efi_va_generate_file_device_path_from_esp
Mario Limonciello [Sat, 5 Mar 2016 18:57:32 +0000 (12:57 -0600)]
Use detected partition number in call to efi_va_generate_file_device_path_from_esp

In efi_generate_file_device_path get_partition_number detects what
partition number is used for that device, but this doesn't actually get
used.

This potentially masks problems that might not be caught later on some
device types (such as NVMe - where this was initally found)

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefivar: get rid of our variadic mess in efi_set_variable()
Peter Jones [Wed, 2 Mar 2016 19:46:15 +0000 (14:46 -0500)]
libefivar: get rid of our variadic mess in efi_set_variable()

Sometimes the linked output wasn't correctly choosing the right
functions, and we'd get undefined behavior and the result was random
file modes on efi variables.

Instead, require the mode, and provide a compatibility symbol with the
older version that will use a safe (if mildly annoying) mode of
(0600 & ~umask).

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefivar: make the nvme sysfs bits look even more like the sas bits
Peter Jones [Wed, 2 Mar 2016 19:23:21 +0000 (14:23 -0500)]
libefivar: make the nvme sysfs bits look even more like the sas bits

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefivar: fix some leaked symbols
Peter Jones [Wed, 2 Mar 2016 16:17:48 +0000 (11:17 -0500)]
efivar: fix some leaked symbols

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoGet rid of the fd in make_blockdev_path()
Peter Jones [Tue, 1 Mar 2016 20:41:53 +0000 (15:41 -0500)]
Get rid of the fd in make_blockdev_path()

Since we don't do the nvme ioctl any more, we don't need this.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agofix source URL
Thierry Vignaud [Sat, 20 Feb 2016 06:00:04 +0000 (07:00 +0100)]
fix source URL

8 years agolibefiboot: rework NVME so we get EUI right and don't need kernel headers
Peter Jones [Fri, 19 Feb 2016 23:53:00 +0000 (18:53 -0500)]
libefiboot: rework NVME so we get EUI right and don't need kernel headers

The headers are broken enough on various distros that it's better to
avoid them entirely.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefiboot: limit check everywhere, not just where it looked safe once.
Peter Jones [Thu, 25 Feb 2016 19:15:18 +0000 (14:15 -0500)]
libefiboot: limit check everywhere, not just where it looked safe once.

'cause duh.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefiboot: Fix the types the compiler complains about.
Peter Jones [Thu, 25 Feb 2016 19:14:41 +0000 (14:14 -0500)]
libefiboot: Fix the types the compiler complains about.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefiboot: loadopt.c: include the loadopt header.
Peter Jones [Thu, 25 Feb 2016 19:13:42 +0000 (14:13 -0500)]
libefiboot: loadopt.c: include the loadopt header.

This lets the compiler complain about our types being wrong.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefivar: simplify efi_name_to_guid()'s string termination.
Peter Jones [Thu, 25 Feb 2016 19:12:50 +0000 (14:12 -0500)]
libefivar: simplify efi_name_to_guid()'s string termination.

There's no reason to try to set the whole string end to 0 when just the
character in question will do, and the arithmetic is way easier this
way.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefiboot: Fix efidp_format_device_path()'s limit test.
Peter Jones [Thu, 25 Feb 2016 19:11:46 +0000 (14:11 -0500)]
libefiboot: Fix efidp_format_device_path()'s limit test.

A limit of 0 means 0, not no limit.  That's why it's ssize_t.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefivar: be safe for -Werror=missing-field-initializers
Peter Jones [Thu, 18 Feb 2016 15:42:56 +0000 (10:42 -0500)]
efivar: be safe for -Werror=missing-field-initializers

Caught as part of -Wextra

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoUse -Wextra
Peter Jones [Thu, 18 Feb 2016 15:28:54 +0000 (10:28 -0500)]
Use -Wextra

 A sign was given but
 many years have passed
 Cost a little bit to love you but I
 won't can't stop
 Such a happy day
 for me...

Sure, -Wextra is a little annoying, but in GCC 6 it has a lot of really
nice code verification options in it, and I don't want to turn those on
individually and break GCC 5 building.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefivar: be safe for -Werror=missing-field-initializers
Peter Jones [Thu, 18 Feb 2016 15:26:31 +0000 (10:26 -0500)]
libefivar: be safe for -Werror=missing-field-initializers

Caught as part of -Wextra

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefiboot: efi_loadopt_desc() isn't const, the returned string is.
Peter Jones [Thu, 18 Feb 2016 15:15:28 +0000 (10:15 -0500)]
libefiboot: efi_loadopt_desc() isn't const, the returned string is.

Caught by -Werror=ignored-qualifiers as part of -Wextra

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefivar: be safe for -Werror=unused-parameter
Peter Jones [Thu, 18 Feb 2016 15:11:32 +0000 (10:11 -0500)]
libefivar: be safe for -Werror=unused-parameter

Caught by -Werror=unused-parameter as part of -Wextra.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agolibefiboot: be safe for -Werror=unused-parameter
Peter Jones [Thu, 18 Feb 2016 15:33:40 +0000 (10:33 -0500)]
libefiboot: be safe for -Werror=unused-parameter

Caught by -Werror=ignored-qualifiers as part of -Wextra.  Some of them
may actually also be /errors/, so that's nice.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agothis condition should be error before change, should be rc instead of ret
btian1 [Fri, 19 Feb 2016 01:33:38 +0000 (09:33 +0800)]
this condition should be error before change, should be rc instead of ret

8 years agoWorkaround rename of linux/nvme.h
Mike Gilbert [Thu, 14 Jan 2016 22:02:31 +0000 (17:02 -0500)]
Workaround rename of linux/nvme.h

Bug: https://bugs.gentoo.org/571548

8 years agoTry to pretend 0.22 didn't happen by making 0.23 the next day.
Peter Jones [Mon, 15 Feb 2016 18:38:55 +0000 (13:38 -0500)]
Try to pretend 0.22 didn't happen by making 0.23 the next day.

Because c0a2b3db1088af888d98c2223a648bc6f6274eea had 2 fairly serious
but quite subtle bugs.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoMake df78c364 actually work.
Peter Jones [Mon, 15 Feb 2016 19:27:36 +0000 (14:27 -0500)]
Make df78c364 actually work.

Yeah, discovered in testing that it has to be O_RDONLY not O_WRONLY, and
apparently fixed it in the kernel tree but not here.  Woops.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoMake gcc.specs work with gcc 6 / binutils 2.26
Peter Jones [Mon, 15 Feb 2016 19:15:40 +0000 (14:15 -0500)]
Make gcc.specs work with gcc 6 / binutils 2.26

Apparently binutils 2.26 gets real picky about "ld -PIC" vs "ld -fPIC".

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoPut "-L." is in LDFLAGS so we don't need installed libefivar to build.
Peter Jones [Mon, 15 Feb 2016 18:46:23 +0000 (13:46 -0500)]
Put "-L." is in LDFLAGS so we don't need installed libefivar to build.

Resolves issue #40

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoMake guids be in correct byte order both in text and ram...
Peter Jones [Mon, 15 Feb 2016 18:27:41 +0000 (13:27 -0500)]
Make guids be in correct byte order both in text and ram...

This is all because the EFI spec defines:

typedef struct {
UINT32 Data1;
UINT16 Data2;
UINT16 Data3;
UINT8
Data4[8];
} EFI_GUID;

{0x8BE4DF61,0x93CA,0x11d2,\
{0xAA,0x0D,0x00,0xE0,0x98,0x03,0x2B,0x8C}}

but prints:
8BE4DF61-93CA-11d2-AA0D-00E098032B8C

But we decided to be "smart" and did:

typedef struct {
uint32_t        a;
uint16_t        b;
uint16_t        c;
uint16_t        d;
uint8_t         e[6];
} efi_guid_t;

Which means d is effectively in big endian while a, b, and c are little
endian.  This is awful.

We also have efi_guid_t in the public header, so things can take
sizeof() on it, which seems ill advised in hindsight.

Thankfully, we also have the EFI_GUID() macro, which was getting things
right, so if things memcmp()'d or efi_guid_cmp()'d on that, it'd get it
right, and efibootmgr is, in fact, using that (via EFI_GUID_GLOBAL)
instead.

So now, keep them all in memory as le32-le16-le16-be16-b-b-b-b-b-b at
all times.  The only programs that should break were ther ones that were
already broken, and they'll need a rebuild.

Also fix a bug introduced in c0a2b3db1088af888d98c2223a648bc6f6274eea
which introduced at "1" into some definitions of efi_guid_empty.

(yes, it really says "d2" not "D2")

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoCompile without -fshort-wchar
Felix Janda [Wed, 20 Jan 2016 19:35:42 +0000 (20:35 +0100)]
Compile without -fshort-wchar

-fshort-wchar makes wchar_t 16bit. By removing the last indirect
occurences of wchar_t as L'\0', the option becomes superfluous.
Furthermore, this fixes an compilation error with musl libc due to
incompatibility with -fshort-wchar.

8 years agoMake.defaults: Improve gcc/clang detection
Mike Gilbert [Fri, 12 Feb 2016 18:22:13 +0000 (13:22 -0500)]
Make.defaults: Improve gcc/clang detection

The old filter only matched "gcc" or "clang".

The new findstring call matches any occurance of gcc or clang. This is
useful when CC includes the full host tuple, like x86_64-pc-linux-gnu-gcc.

Signed-off-by: Mike Gilbert <floppym@gentoo.org>
8 years agoRelease 0.22
Peter Jones [Wed, 10 Feb 2016 20:58:18 +0000 (15:58 -0500)]
Release 0.22

This has some new things in it:
- various build fixes for several compilers
- hopefully getting SATA PMP IDs right
- Reworked makefiles
- better handling of device node numbers
- devices mounted at more than one path work now
- make -j works better now
- lots of device path fixes
- fixes to efivar -L
- better nvme handling in libefiboot
- efivar (and libefivar) will now work transparently with immutable
  efivarfs files.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoMake efivar work with immutable efivarfs files.
Peter Jones [Tue, 2 Feb 2016 14:40:44 +0000 (09:40 -0500)]
Make efivar work with immutable efivarfs files.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoMultiple fixes for compilation with gcc 6
Steve McIntyre [Wed, 20 Jan 2016 17:44:28 +0000 (17:44 +0000)]
Multiple fixes for compilation with gcc 6

Multiple instances of non-NULL sanity checks against function
arguments declared as __attribute__((__nonnull__)); gcc 6 now triggers
warnings on these.

dp.c: Remove Unused variable end_instance

linux.c: Fix warnings about dereferencing type-punned pointers: switch
from char * to uint8_t * in various places

Signed-off-by: Steve McIntyre <steve@einval.com>
8 years agoRename endian.h into efivar_endian.h to avoid conflicts
Sylvain Chouleur [Wed, 16 Dec 2015 13:21:29 +0000 (14:21 +0100)]
Rename endian.h into efivar_endian.h to avoid conflicts

When compiling efivar from another directory than the sources's one, we
will have to add ./src/ in the include path to be able to resolve
the include "endian.h" from ./src/dp-message.c. Then, when include
<endian.h> is done from ./src/guid.h, ./src/endian.h will be used
instead of system wide endian.h, which is wrong.

To avoid this situation, this patch renames ./src/endian.h into
./src/efivar_endian.h

Signed-off-by: Sylvain Chouleur <sylvain.chouleur@intel.com>
8 years agolibefiboot: figure out nvme device paths better.
Peter Jones [Wed, 18 Nov 2015 22:33:34 +0000 (17:33 -0500)]
libefiboot: figure out nvme device paths better.

Figure out that an nvme device is the nvme device and make the path to a
partition correctly.

Something is also wrong on the failure path there - we should fail with
an error if we legit can't figure out a device path and never get valid
sizes etc., not write a bogus HD() paths filled with zeros.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoUse gcc -specs= for most command line stuff normally.
Peter Jones [Mon, 16 Nov 2015 16:09:49 +0000 (11:09 -0500)]
Use gcc -specs= for most command line stuff normally.

This makes the -fPIC/-pie/etc stuff *somewhat* easier to get right.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoMake -fPIC and -fPIE work as they should, and default correctly
Peter Jones [Mon, 16 Nov 2015 18:29:20 +0000 (13:29 -0500)]
Make -fPIC and -fPIE work as they should, and default correctly

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoMake LDFLAGS get set right from the rpm build
Peter Jones [Mon, 16 Nov 2015 16:38:06 +0000 (11:38 -0500)]
Make LDFLAGS get set right from the rpm build

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoefivar: Don't list padding from the end of efi_well_known_guids with -L
Peter Jones [Mon, 16 Nov 2015 20:53:16 +0000 (15:53 -0500)]
efivar: Don't list padding from the end of efi_well_known_guids with -L

Sometimes gcc seems to put stuff at the end of that array, and I don't
know why, but the way we're iterating displays it.  Instead, stick a
real sentinal there.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoMake makeguids generate guid-symbols.c instead of .S
Peter Jones [Mon, 16 Nov 2015 16:09:03 +0000 (11:09 -0500)]
Make makeguids generate guid-symbols.c instead of .S

Just makes it a little easier to debug.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoMark more of our exports with "default" visibility.
Peter Jones [Fri, 13 Nov 2015 20:14:10 +0000 (15:14 -0500)]
Mark more of our exports with "default" visibility.

Some of the things we're exporting aren't always getting marked "D"
instead of "d" correclty on some compilers, because the decl doesn't
have the visibility attribute.  Add it.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoIgnore efivar-static in the rpm .spec
Peter Jones [Fri, 13 Nov 2015 23:06:48 +0000 (18:06 -0500)]
Ignore efivar-static in the rpm .spec

For now, anyway.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoTemporarily use --add-needed when linking libefivar.so
Peter Jones [Thu, 12 Nov 2015 20:25:33 +0000 (15:25 -0500)]
Temporarily use --add-needed when linking libefivar.so

Details on why are here:

https://sourceware.org/bugzilla/show_bug.cgi?id=19249

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoShow a closing ) on vendor console device paths.
Peter Jones [Thu, 12 Nov 2015 15:54:56 +0000 (10:54 -0500)]
Show a closing ) on vendor console device paths.

Signed-off-by: root <root@pjones3.install.bos.redhat.com>
8 years agolibefiboot: Make efidp multi-instance iteration actually work.
Peter Jones [Thu, 12 Nov 2015 15:06:17 +0000 (10:06 -0500)]
libefiboot: Make efidp multi-instance iteration actually work.

Make efidp_is_multiinstance() not forever loop, and make
efidp_instance_size() test for error correctly when calling
efidp_next_node()

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoReturn the right offset in format_vendor_helper()
Peter Jones [Thu, 12 Nov 2015 15:05:39 +0000 (10:05 -0500)]
Return the right offset in format_vendor_helper()

This could cause the space allocated for buffers to be much larger than
needed, and cause some parts of those buffers to be after the last NUL
character present, so they won't be displayed right when printed.

Signed-off-by: Peter Jones <pjones@redhat.com>
8 years agoFormat ACPI _ADR device lists in hex, not decimal.
Peter Jones [Thu, 12 Nov 2015 15:03:45 +0000 (10:03 -0500)]
Format ACPI _ADR device lists in hex, not decimal.

These are structured values, and looking at them in decimal doesn't
really work.

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