New upstream release (38)
Resolves: #2024374 Signed-off-by: Robbie Harwood <rharwood@redhat.com>
This commit is contained in:
parent
208915b0dc
commit
abaa5ad465
@ -1,90 +0,0 @@
|
||||
From e9b282cbd147eac515c53aa500720de3a43366f3 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||||
Date: Tue, 27 Oct 2020 13:06:15 +0100
|
||||
Subject: [PATCH] Fix abidw output for missing variadic arguments
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
GCC forgets to add the varidic arguments into debugging data if the
|
||||
compilation unit is built with -flto option. As a result, the prebuilt
|
||||
XML ABI dumps were missing the last argument at 4 functions (e.g.
|
||||
efi_error_set()).
|
||||
|
||||
This was unnoticed until Fedora enabled LTO globally and had to
|
||||
disable LTO in efivar explicitly because efivar uses symbol versioning
|
||||
with top-level assembler statements which is not compatible with LTO.
|
||||
|
||||
Since then the abicheck failed:
|
||||
|
||||
make[2]: Leaving directory '/builddir/build/BUILD/efivar-37/src'
|
||||
abidiff \
|
||||
--suppr abignore \
|
||||
--headers-dir2 /builddir/build/BUILD/efivar-37/src/include/efivar/ \
|
||||
libefivar.abixml \
|
||||
libefivar.so
|
||||
Functions changes summary: 0 Removed, 2 Changed (8 filtered out), 0 Added functions
|
||||
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
|
||||
2 functions with some indirect sub-type change:
|
||||
[C]'function int _efi_set_variable_variadic(efi_guid_t, const char*, uint8_t*, size_t, uint32_t)' at lib.c:44:1 has some indirect sub-type changes:
|
||||
parameter 6 of type '...' was added
|
||||
[C]'function int efi_error_set(const char*, const char*, int, int, const char*)' at error.c:86:1 has some indirect sub-type changes:
|
||||
parameter 6 of type '...' was added
|
||||
make[1]: *** [/builddir/build/BUILD/efivar-37/src/include/rules.mk:41: libefivar.abicheck] Error 4
|
||||
make[1]: Leaving directory '/builddir/build/BUILD/efivar-37/src'
|
||||
|
||||
This patch corrects the pregenerated abixml files that were probably
|
||||
generated with the faulty GCC.
|
||||
|
||||
<https://bugzilla.redhat.com/show_bug.cgi?id=1863475>
|
||||
<https://bugzilla.redhat.com/show_bug.cgi?id=1891787>
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
src/libefiboot.abixml | 2 ++
|
||||
src/libefivar.abixml | 2 ++
|
||||
2 files changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/libefiboot.abixml b/src/libefiboot.abixml
|
||||
index 4a0253b..ab75cbb 100644
|
||||
--- a/src/libefiboot.abixml
|
||||
+++ b/src/libefiboot.abixml
|
||||
@@ -1800,6 +1800,7 @@
|
||||
<parameter type-id='type-id-18' name='size'/>
|
||||
<parameter type-id='type-id-215' name='filepath'/>
|
||||
<parameter type-id='type-id-5' name='options'/>
|
||||
+ <parameter is-variadic='yes'/>
|
||||
<return type-id='type-id-18'/>
|
||||
</function-decl>
|
||||
<function-decl name='efi_generate_file_device_path_from_esp' mangled-name='efi_generate_file_device_path_from_esp' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='efi_generate_file_device_path_from_esp@@libefiboot.so.0'>
|
||||
@@ -1809,6 +1810,7 @@
|
||||
<parameter type-id='type-id-25' name='partition'/>
|
||||
<parameter type-id='type-id-214' name='relpath'/>
|
||||
<parameter type-id='type-id-5' name='options'/>
|
||||
+ <parameter is-variadic='yes'/>
|
||||
<return type-id='type-id-18'/>
|
||||
</function-decl>
|
||||
<function-decl name='efidp_make_hd' mangled-name='efidp_make_hd' filepath='src/include/efivar/efivar-dp.h' line='735' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
diff --git a/src/libefivar.abixml b/src/libefivar.abixml
|
||||
index a719b8b..2dbb838 100644
|
||||
--- a/src/libefivar.abixml
|
||||
+++ b/src/libefivar.abixml
|
||||
@@ -393,6 +393,7 @@
|
||||
<parameter type-id='type-id-4' name='line' filepath='/usr/include/string.h' line='102' column='1'/>
|
||||
<parameter type-id='type-id-4' name='error' filepath='/usr/include/string.h' line='103' column='1'/>
|
||||
<parameter type-id='type-id-58' name='fmt' filepath='/usr/include/string.h' line='104' column='1'/>
|
||||
+ <parameter is-variadic='yes'/>
|
||||
<return type-id='type-id-4'/>
|
||||
</function-decl>
|
||||
<typedef-decl name='__mode_t' type-id='type-id-1' filepath='/usr/include/bits/types.h' line='150' column='1' id='type-id-59'/>
|
||||
@@ -467,6 +468,7 @@
|
||||
<parameter type-id='type-id-22' name='data' filepath='/usr/include/unistd.h' line='58' column='1'/>
|
||||
<parameter type-id='type-id-23' name='data_size' filepath='/usr/include/unistd.h' line='59' column='1'/>
|
||||
<parameter type-id='type-id-3' name='attributes' filepath='/usr/include/unistd.h' line='59' column='1'/>
|
||||
+ <parameter is-variadic='yes'/>
|
||||
<return type-id='type-id-4'/>
|
||||
</function-decl>
|
||||
<function-decl name='_efi_set_variable' mangled-name='_efi_set_variable' filepath='/usr/include/unistd.h' line='46' column='1' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='_efi_set_variable@libefivar.so.0'>
|
||||
--
|
||||
2.25.4
|
||||
|
@ -1,55 +0,0 @@
|
||||
From 54dad567c41b57c4843329856ca5047e63325a9f Mon Sep 17 00:00:00 2001
|
||||
From: Hans de Goede <hdegoede@redhat.com>
|
||||
Date: Wed, 22 Apr 2020 19:33:01 +0200
|
||||
Subject: [PATCH] Fix /sys/block sysfs parsing for eMMC-s
|
||||
|
||||
Commit 471869409464 ("sysfs parsers: make all the /sys/block link
|
||||
parsers work the same way") has broken sysfs parsing for eMMC-s when
|
||||
the passed in path points to the whole block device.
|
||||
|
||||
In that case pos2 will stay at its -1 initializaton value, because we
|
||||
only do 4 conversions; and when we then do:
|
||||
|
||||
current += pos2
|
||||
|
||||
We end up moving current one char position backwards and we end up
|
||||
returning -1.
|
||||
|
||||
The correct positing to use is always pos1 independent if we got
|
||||
passed the whole disk; or a parition, as we always want to return
|
||||
only the part which points to whole disk which ends at pos1.
|
||||
|
||||
Note that it seems that before commit 471869409464, the case where
|
||||
path points to the partition was likely broken as the old code then
|
||||
would return the entire path including the partition element.
|
||||
|
||||
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1826864
|
||||
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
||||
---
|
||||
src/linux-emmc.c | 9 +++------
|
||||
1 file changed, 3 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/linux-emmc.c b/src/linux-emmc.c
|
||||
index 800dc14..65557b4 100644
|
||||
--- a/src/linux-emmc.c
|
||||
+++ b/src/linux-emmc.c
|
||||
@@ -56,13 +56,10 @@ parse_emmc(struct device *dev, const char *path, const char *root UNUSED)
|
||||
dev->emmc_info.slot_id = slot_id;
|
||||
dev->interface_type = emmc;
|
||||
|
||||
- if (rc == 6) {
|
||||
- if (dev->part == -1)
|
||||
- dev->part = partition;
|
||||
+ if (rc == 6 && dev->part == -1)
|
||||
+ dev->part = partition;
|
||||
|
||||
- pos2 = pos1;
|
||||
- }
|
||||
- current += pos2;
|
||||
+ current += pos1;
|
||||
|
||||
debug("current:'%s' sz:%zd", current, current - path);
|
||||
return current - path;
|
||||
--
|
||||
2.26.0
|
||||
|
@ -1,33 +0,0 @@
|
||||
From cb0b1c30103abc17dbbed14210bbc59a73802206 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 7 Jan 2019 10:30:23 -0500
|
||||
Subject: [PATCH 01/86] util.h: add unlikely() and likely() macros
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/util.h | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/src/util.h b/src/util.h
|
||||
index f63a8907611..ba8fee35ae9 100644
|
||||
--- a/src/util.h
|
||||
+++ b/src/util.h
|
||||
@@ -52,6 +52,15 @@
|
||||
#define PACKED __attribute__((__packed__))
|
||||
#define VERSION(sym, ver) __asm__(".symver " # sym "," # ver)
|
||||
|
||||
+#define __branch_check__(x, expect, is_constant) \
|
||||
+ __builtin_expect(!!(x), expect)
|
||||
+#ifndef likely
|
||||
+#define likely(x) (__branch_check__(x, 1, __builtin_constant_p(x)))
|
||||
+#endif
|
||||
+#ifndef unlikely
|
||||
+#define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x)))
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
* I'm not actually sure when these appear, but they're present in the
|
||||
* version in front of me.
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,59 +0,0 @@
|
||||
From b98ba8921010d03f46704a476c69861515deb1ca Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 7 Jan 2019 10:30:59 -0500
|
||||
Subject: [PATCH 02/86] dp.h: make format_guid() handle misaligned guid
|
||||
pointers safely.
|
||||
|
||||
GCC 9 adds -Werror=address-of-packed-member, which causes us to see the
|
||||
build error reported at
|
||||
https://bugzilla.opensuse.org/show_bug.cgi?id=1120862 .
|
||||
|
||||
That bug report shows us the following:
|
||||
|
||||
In file included from dp.c:26:
|
||||
dp.h: In function 'format_vendor_helper':
|
||||
dp.h:120:37: error: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Werror=address-of-packed-member]
|
||||
120 | format_guid(buf, size, off, label, &dp->hw_vendor.vendor_guid);
|
||||
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
dp.h:74:25: note: in definition of macro 'format_guid'
|
||||
74 | _rc = efi_guid_to_str(guid, &_guidstr); \
|
||||
| ^~~~
|
||||
cc1: all warnings being treated as errors
|
||||
|
||||
This patch makes format_guid() use a local variable as a bounce buffer
|
||||
in the case that the guid we're passed is aligned as chaotic neutral.
|
||||
|
||||
Note that this only fixes this instance and there may be others that bz
|
||||
didn't show because it exited too soon, and I don't have a gcc 9 build
|
||||
in front of me right now.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/dp.h | 11 +++++++++--
|
||||
1 file changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/dp.h b/src/dp.h
|
||||
index aa4e3902992..20cb608d05f 100644
|
||||
--- a/src/dp.h
|
||||
+++ b/src/dp.h
|
||||
@@ -70,8 +70,15 @@
|
||||
#define format_guid(buf, size, off, dp_type, guid) ({ \
|
||||
int _rc; \
|
||||
char *_guidstr = NULL; \
|
||||
- \
|
||||
- _rc = efi_guid_to_str(guid, &_guidstr); \
|
||||
+ efi_guid_t _guid; \
|
||||
+ const efi_guid_t * const _guid_p = \
|
||||
+ likely(__alignof__(guid) == sizeof(guid)) \
|
||||
+ ? guid \
|
||||
+ : &_guid; \
|
||||
+ \
|
||||
+ if (unlikely(__alignof__(guid) == sizeof(guid))) \
|
||||
+ memmove(&_guid, guid, sizeof(_guid)); \
|
||||
+ _rc = efi_guid_to_str(_guid_p, &_guidstr); \
|
||||
if (_rc < 0) { \
|
||||
efi_error("could not build %s GUID DP string", \
|
||||
dp_type); \
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,27 +0,0 @@
|
||||
From 8f803791a1c97a4d1bce049264218a94c46d7838 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 7 Jan 2019 11:32:41 -0500
|
||||
Subject: [PATCH 03/86] linux-pci-root: remove an unused assignment
|
||||
|
||||
scan-build gripes about this, and it's pointless, so it can go.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/linux-pci-root.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/src/linux-pci-root.c b/src/linux-pci-root.c
|
||||
index a2d9fb04a11..5d1df06119d 100644
|
||||
--- a/src/linux-pci-root.c
|
||||
+++ b/src/linux-pci-root.c
|
||||
@@ -115,7 +115,6 @@ dp_create_pci_root(struct device *dev UNUSED,
|
||||
return new;
|
||||
}
|
||||
}
|
||||
- off += new;
|
||||
sz += new;
|
||||
|
||||
debug("returning %zd", sz);
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,172 +0,0 @@
|
||||
From c3c553db85ff10890209d0fe48fb4856ad68e4e0 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Thu, 21 Feb 2019 15:20:12 -0500
|
||||
Subject: [PATCH 04/86] Fix all the places -Werror=address-of-packed-member
|
||||
catches.
|
||||
|
||||
This gets rid of all the places GCC 9's -Werror=address-of-packed-member
|
||||
flags as problematic.
|
||||
|
||||
Fixes github issue #123
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/dp-message.c | 6 ++++--
|
||||
src/dp.h | 12 ++++--------
|
||||
src/guid.c | 2 +-
|
||||
src/include/efivar/efivar.h | 2 +-
|
||||
src/ucs2.h | 27 +++++++++++++++++++--------
|
||||
5 files changed, 29 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/src/dp-message.c b/src/dp-message.c
|
||||
index 3724e5f57bd..9f964663de8 100644
|
||||
--- a/src/dp-message.c
|
||||
+++ b/src/dp-message.c
|
||||
@@ -620,11 +620,13 @@ _format_message_dn(char *buf, size_t size, const_efidp dp)
|
||||
) / sizeof(efi_ip_addr_t);
|
||||
format(buf, size, off, "Dns", "Dns(");
|
||||
for (int i=0; i < end; i++) {
|
||||
- const efi_ip_addr_t *addr = &dp->dns.addrs[i];
|
||||
+ efi_ip_addr_t addr;
|
||||
+
|
||||
+ memcpy(&addr, &dp->dns.addrs[i], sizeof(addr));
|
||||
if (i != 0)
|
||||
format(buf, size, off, "Dns", ",");
|
||||
format_ip_addr(buf, size, off, "Dns",
|
||||
- dp->dns.is_ipv6, addr);
|
||||
+ dp->dns.is_ipv6, &addr);
|
||||
}
|
||||
format(buf, size, off, "Dns", ")");
|
||||
break;
|
||||
diff --git a/src/dp.h b/src/dp.h
|
||||
index 20cb608d05f..1f921d524aa 100644
|
||||
--- a/src/dp.h
|
||||
+++ b/src/dp.h
|
||||
@@ -71,13 +71,9 @@
|
||||
int _rc; \
|
||||
char *_guidstr = NULL; \
|
||||
efi_guid_t _guid; \
|
||||
- const efi_guid_t * const _guid_p = \
|
||||
- likely(__alignof__(guid) == sizeof(guid)) \
|
||||
- ? guid \
|
||||
- : &_guid; \
|
||||
- \
|
||||
- if (unlikely(__alignof__(guid) == sizeof(guid))) \
|
||||
- memmove(&_guid, guid, sizeof(_guid)); \
|
||||
+ const efi_guid_t * const _guid_p = &_guid; \
|
||||
+ \
|
||||
+ memmove(&_guid, guid, sizeof(_guid)); \
|
||||
_rc = efi_guid_to_str(_guid_p, &_guidstr); \
|
||||
if (_rc < 0) { \
|
||||
efi_error("could not build %s GUID DP string", \
|
||||
@@ -86,7 +82,7 @@
|
||||
_guidstr = onstack(_guidstr, \
|
||||
strlen(_guidstr)+1); \
|
||||
_rc = format(buf, size, off, dp_type, "%s", \
|
||||
- _guidstr); \
|
||||
+ _guidstr); \
|
||||
} \
|
||||
_rc; \
|
||||
})
|
||||
diff --git a/src/guid.c b/src/guid.c
|
||||
index 306c9ff8287..3156b3b7c60 100644
|
||||
--- a/src/guid.c
|
||||
+++ b/src/guid.c
|
||||
@@ -31,7 +31,7 @@
|
||||
extern const efi_guid_t efi_guid_zero;
|
||||
|
||||
int NONNULL(1, 2) PUBLIC
|
||||
-efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b)
|
||||
+efi_guid_cmp(const void * const a, const void * const b)
|
||||
{
|
||||
return memcmp(a, b, sizeof (efi_guid_t));
|
||||
}
|
||||
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
|
||||
index 316891ccae9..ad6449d9d93 100644
|
||||
--- a/src/include/efivar/efivar.h
|
||||
+++ b/src/include/efivar/efivar.h
|
||||
@@ -128,7 +128,7 @@ extern int efi_symbol_to_guid(const char *symbol, efi_guid_t *guid)
|
||||
|
||||
extern int efi_guid_is_zero(const efi_guid_t *guid);
|
||||
extern int efi_guid_is_empty(const efi_guid_t *guid);
|
||||
-extern int efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b);
|
||||
+extern int efi_guid_cmp(const void * const a, const void * const b);
|
||||
|
||||
/* import / export functions */
|
||||
typedef struct efi_variable efi_variable_t;
|
||||
diff --git a/src/ucs2.h b/src/ucs2.h
|
||||
index dbb59004b7c..edd8367b4bc 100644
|
||||
--- a/src/ucs2.h
|
||||
+++ b/src/ucs2.h
|
||||
@@ -23,16 +23,21 @@
|
||||
(((val) & ((mask) << (shift))) >> (shift))
|
||||
|
||||
static inline size_t UNUSED
|
||||
-ucs2len(const uint16_t * const s, ssize_t limit)
|
||||
+ucs2len(const void *vs, ssize_t limit)
|
||||
{
|
||||
ssize_t i;
|
||||
- for (i = 0; i < (limit >= 0 ? limit : i+1) && s[i] != (uint16_t)0; i++)
|
||||
+ const uint16_t *s = vs;
|
||||
+ const uint8_t *s8 = vs;
|
||||
+
|
||||
+ for (i = 0;
|
||||
+ i < (limit >= 0 ? limit : i+1) && s8[0] != 0 && s8[1] != 0;
|
||||
+ i++, s8 += 2, s++)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
static inline size_t UNUSED
|
||||
-ucs2size(const uint16_t * const s, ssize_t limit)
|
||||
+ucs2size(const void *s, ssize_t limit)
|
||||
{
|
||||
size_t rc = ucs2len(s, limit);
|
||||
rc *= sizeof (uint16_t);
|
||||
@@ -69,10 +74,11 @@ utf8size(uint8_t *s, ssize_t limit)
|
||||
}
|
||||
|
||||
static inline unsigned char * UNUSED
|
||||
-ucs2_to_utf8(const uint16_t * const chars, ssize_t limit)
|
||||
+ucs2_to_utf8(const void * const voidchars, ssize_t limit)
|
||||
{
|
||||
ssize_t i, j;
|
||||
unsigned char *ret;
|
||||
+ const uint16_t * const chars = voidchars;
|
||||
|
||||
if (limit < 0)
|
||||
limit = ucs2len(chars, -1);
|
||||
@@ -124,10 +130,12 @@ ucs2_to_utf8(const uint16_t * const chars, ssize_t limit)
|
||||
}
|
||||
|
||||
static inline ssize_t UNUSED NONNULL(4)
|
||||
-utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8)
|
||||
+utf8_to_ucs2(void *ucs2void, ssize_t size, int terminate, uint8_t *utf8)
|
||||
{
|
||||
ssize_t req;
|
||||
ssize_t i, j;
|
||||
+ uint16_t *ucs2 = ucs2void;
|
||||
+ uint16_t val16;
|
||||
|
||||
if (!ucs2 && size > 0) {
|
||||
errno = EINVAL;
|
||||
@@ -162,10 +170,13 @@ utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8)
|
||||
val = utf8[i] & 0x7f;
|
||||
i += 1;
|
||||
}
|
||||
- ucs2[j] = val;
|
||||
+ val16 = val;
|
||||
+ ucs2[j] = val16;
|
||||
+ }
|
||||
+ if (terminate) {
|
||||
+ val16 = 0;
|
||||
+ ucs2[j++] = val16;
|
||||
}
|
||||
- if (terminate)
|
||||
- ucs2[j++] = (uint16_t)0;
|
||||
return j;
|
||||
};
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,372 +0,0 @@
|
||||
From e39fb5b9e590c6616459c15b5d95fbc09fb077d6 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Thu, 21 Feb 2019 15:26:23 -0500
|
||||
Subject: [PATCH 05/86] Get rid of the arrows in our debug messages.
|
||||
|
||||
They're not *that* useful, and the code is clever and problematic.
|
||||
|
||||
Resolves github issue #124
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/linux-acpi-root.c | 7 -------
|
||||
src/linux-emmc.c | 9 ---------
|
||||
src/linux-md.c | 8 --------
|
||||
src/linux-nvme.c | 9 ---------
|
||||
src/linux-pci-root.c | 7 -------
|
||||
src/linux-pci.c | 8 --------
|
||||
src/linux-sata.c | 11 -----------
|
||||
src/linux-scsi.c | 24 ------------------------
|
||||
src/linux-soc-root.c | 7 -------
|
||||
src/linux-virtblk.c | 8 --------
|
||||
src/util.h | 1 -
|
||||
11 files changed, 99 deletions(-)
|
||||
|
||||
diff --git a/src/linux-acpi-root.c b/src/linux-acpi-root.c
|
||||
index 06e69eebe78..30728ded671 100644
|
||||
--- a/src/linux-acpi-root.c
|
||||
+++ b/src/linux-acpi-root.c
|
||||
@@ -51,13 +51,6 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED
|
||||
char *colon;
|
||||
|
||||
const char *devpart = current;
|
||||
- char *spaces;
|
||||
-
|
||||
- pos = strlen(current);
|
||||
- spaces = alloca(pos+1);
|
||||
- memset(spaces, ' ', pos+1);
|
||||
- spaces[pos] = '\0';
|
||||
- pos = 0;
|
||||
|
||||
debug("entry");
|
||||
|
||||
diff --git a/src/linux-emmc.c b/src/linux-emmc.c
|
||||
index 87e92477554..b290ed0a2bd 100644
|
||||
--- a/src/linux-emmc.c
|
||||
+++ b/src/linux-emmc.c
|
||||
@@ -50,13 +50,6 @@ parse_emmc(struct device *dev, const char *current, const char *root UNUSED)
|
||||
int rc;
|
||||
int32_t tosser0, tosser1, tosser2, tosser3, slot_id, partition;
|
||||
int pos0 = 0, pos1 = 0;
|
||||
- char *spaces;
|
||||
-
|
||||
- pos0 = strlen(current);
|
||||
- spaces = alloca(pos0+1);
|
||||
- memset(spaces, ' ', pos0+1);
|
||||
- spaces[pos0] = '\0';
|
||||
- pos0 = 0;
|
||||
|
||||
debug("entry");
|
||||
|
||||
@@ -65,8 +58,6 @@ parse_emmc(struct device *dev, const char *current, const char *root UNUSED)
|
||||
&tosser0, &tosser1, &tosser2, &slot_id,
|
||||
&pos0, &tosser3, &partition, &pos1);
|
||||
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 4);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos1, rc, 6);
|
||||
/*
|
||||
* If it isn't of that form, it's not one of our emmc devices.
|
||||
*/
|
||||
diff --git a/src/linux-md.c b/src/linux-md.c
|
||||
index 0a5c1cdb435..cb584c96c4b 100644
|
||||
--- a/src/linux-md.c
|
||||
+++ b/src/linux-md.c
|
||||
@@ -44,13 +44,6 @@ parse_md(struct device *dev, const char *current, const char *root UNUSED)
|
||||
int rc;
|
||||
int32_t md, tosser0, part;
|
||||
int pos0 = 0, pos1 = 0;
|
||||
- char *spaces;
|
||||
-
|
||||
- pos0 = strlen(current);
|
||||
- spaces = alloca(pos0+1);
|
||||
- memset(spaces, ' ', pos0+1);
|
||||
- spaces[pos0] = '\0';
|
||||
- pos0 = 0;
|
||||
|
||||
debug("entry");
|
||||
|
||||
@@ -58,7 +51,6 @@ parse_md(struct device *dev, const char *current, const char *root UNUSED)
|
||||
rc = sscanf(current, "md%d/%nmd%dp%d%n",
|
||||
&md, &pos0, &tosser0, &part, &pos1);
|
||||
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
|
||||
/*
|
||||
* If it isn't of that form, it's not one of our partitioned md devices.
|
||||
*/
|
||||
diff --git a/src/linux-nvme.c b/src/linux-nvme.c
|
||||
index d68d11a3409..1d8fc654f76 100644
|
||||
--- a/src/linux-nvme.c
|
||||
+++ b/src/linux-nvme.c
|
||||
@@ -54,13 +54,6 @@ parse_nvme(struct device *dev, const char *current, const char *root UNUSED)
|
||||
int32_t tosser0, tosser1, tosser2, ctrl_id, ns_id, partition;
|
||||
uint8_t *filebuf = NULL;
|
||||
int pos0 = 0, pos1 = 0;
|
||||
- char *spaces;
|
||||
-
|
||||
- pos0 = strlen(current);
|
||||
- spaces = alloca(pos0+1);
|
||||
- memset(spaces, ' ', pos0+1);
|
||||
- spaces[pos0] = '\0';
|
||||
- pos0 = 0;
|
||||
|
||||
debug("entry");
|
||||
|
||||
@@ -69,8 +62,6 @@ parse_nvme(struct device *dev, const char *current, const char *root UNUSED)
|
||||
&tosser0, &ctrl_id, &ns_id, &pos0,
|
||||
&tosser1, &tosser2, &partition, &pos1);
|
||||
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos1, rc, 6);
|
||||
/*
|
||||
* If it isn't of that form, it's not one of our nvme devices.
|
||||
*/
|
||||
diff --git a/src/linux-pci-root.c b/src/linux-pci-root.c
|
||||
index 5d1df06119d..0605acfc7cb 100644
|
||||
--- a/src/linux-pci-root.c
|
||||
+++ b/src/linux-pci-root.c
|
||||
@@ -48,13 +48,6 @@ parse_pci_root(struct device *dev, const char *current, const char *root UNUSED)
|
||||
uint16_t root_domain;
|
||||
uint8_t root_bus;
|
||||
const char *devpart = current;
|
||||
- char *spaces;
|
||||
-
|
||||
- pos = strlen(current);
|
||||
- spaces = alloca(pos+1);
|
||||
- memset(spaces, ' ', pos+1);
|
||||
- spaces[pos] = '\0';
|
||||
- pos = 0;
|
||||
|
||||
debug("entry");
|
||||
|
||||
diff --git a/src/linux-pci.c b/src/linux-pci.c
|
||||
index f63f5914d9f..64aaefb461c 100644
|
||||
--- a/src/linux-pci.c
|
||||
+++ b/src/linux-pci.c
|
||||
@@ -48,13 +48,6 @@ parse_pci(struct device *dev, const char *current, const char *root)
|
||||
int rc;
|
||||
int pos;
|
||||
const char *devpart = current;
|
||||
- char *spaces;
|
||||
-
|
||||
- pos = strlen(current);
|
||||
- spaces = alloca(pos+1);
|
||||
- memset(spaces, ' ', pos+1);
|
||||
- spaces[pos] = '\0';
|
||||
- pos = 0;
|
||||
|
||||
debug("entry");
|
||||
|
||||
@@ -75,7 +68,6 @@ parse_pci(struct device *dev, const char *current, const char *root)
|
||||
rc = sscanf(devpart, "%hx:%hhx:%hhx.%hhx/%n",
|
||||
&domain, &bus, &device, &function, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d", devpart, rc, pos);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
|
||||
if (rc != 4)
|
||||
break;
|
||||
devpart += pos;
|
||||
diff --git a/src/linux-sata.c b/src/linux-sata.c
|
||||
index 85265022f89..356411724bb 100644
|
||||
--- a/src/linux-sata.c
|
||||
+++ b/src/linux-sata.c
|
||||
@@ -148,13 +148,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
|
||||
uint64_t scsi_lun, tosser3;
|
||||
int pos = 0;
|
||||
int rc;
|
||||
- char *spaces;
|
||||
-
|
||||
- pos = strlen(current);
|
||||
- spaces = alloca(pos+1);
|
||||
- memset(spaces, ' ', pos+1);
|
||||
- spaces[pos] = '\0';
|
||||
- pos = 0;
|
||||
|
||||
debug("entry");
|
||||
if (is_pata(dev)) {
|
||||
@@ -169,7 +162,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
|
||||
debug("searching for ata1/");
|
||||
rc = sscanf(current, "ata%"PRIu32"/%n", &print_id, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
|
||||
/*
|
||||
* If we don't find this one, it isn't an ata device, so return 0 not
|
||||
* error. Later errors mean it is an ata device, but we can't parse
|
||||
@@ -183,7 +175,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
|
||||
debug("searching for host0/");
|
||||
rc = sscanf(current, "host%"PRIu32"/%n", &scsi_bus, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
|
||||
if (rc != 1)
|
||||
return -1;
|
||||
current += pos;
|
||||
@@ -193,7 +184,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
|
||||
rc = sscanf(current, "target%"PRIu32":%"PRIu32":%"PRIu64"/%n",
|
||||
&scsi_device, &scsi_target, &scsi_lun, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
|
||||
if (rc != 3)
|
||||
return -1;
|
||||
current += pos;
|
||||
@@ -203,7 +193,6 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
|
||||
rc = sscanf(current, "%"PRIu32":%"PRIu32":%"PRIu32":%"PRIu64"/%n",
|
||||
&tosser0, &tosser1, &tosser2, &tosser3, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 4);
|
||||
if (rc != 4)
|
||||
return -1;
|
||||
current += pos;
|
||||
diff --git a/src/linux-scsi.c b/src/linux-scsi.c
|
||||
index a5e81cf9cb6..04892f02b4e 100644
|
||||
--- a/src/linux-scsi.c
|
||||
+++ b/src/linux-scsi.c
|
||||
@@ -45,13 +45,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
int rc;
|
||||
int sz = 0;
|
||||
int pos0 = 0, pos1 = 0;
|
||||
- char *spaces;
|
||||
-
|
||||
- sz = strlen(current);
|
||||
- spaces = alloca(sz+1);
|
||||
- memset(spaces, ' ', sz+1);
|
||||
- spaces[sz] = '\0';
|
||||
- sz = 0;
|
||||
|
||||
debug("entry");
|
||||
/*
|
||||
@@ -108,7 +101,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
debug("searching for host4/");
|
||||
rc = sscanf(current, "host%d/%n", scsi_host, &pos0);
|
||||
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 1);
|
||||
if (rc != 1)
|
||||
return -1;
|
||||
sz += pos0;
|
||||
@@ -126,8 +118,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
rc = sscanf(current+sz, "port-%d:%d%n:%d%n", &tosser0,
|
||||
&tosser1, &pos0, &tosser2, &pos1);
|
||||
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current+sz, rc, pos0, pos1);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos1, rc, 3);
|
||||
if (rc == 2 || rc == 3) {
|
||||
sz += pos0;
|
||||
pos0 = 0;
|
||||
@@ -153,7 +143,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
debug("searching for expander-4:0/");
|
||||
rc = sscanf(current+sz, "expander-%d:%d/%n", &tosser0, &tosser1, &pos0);
|
||||
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
|
||||
if (rc == 2) {
|
||||
if (!remote_target_id) {
|
||||
efi_error("Device is PHY is a remote target, but remote_target_id is NULL");
|
||||
@@ -169,7 +158,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
debug("searching for port-2:0:2/");
|
||||
rc = sscanf(current+sz, "port-%d:%d:%d/%n", &tosser0, &tosser1, &tosser2, &pos0);
|
||||
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
|
||||
if (rc != 3) {
|
||||
efi_error("Couldn't parse port expander port string");
|
||||
return -1;
|
||||
@@ -192,8 +180,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
|
||||
pos1 = 0;
|
||||
rc = sscanf(current + sz + pos0, ":%d%n", &tosser2, &pos1);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos0, rc + 2, 2);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos0 + pos1, rc + 2, 3);
|
||||
if (rc != 0 && rc != 1)
|
||||
return -1;
|
||||
if (remote_port_id && rc == 1)
|
||||
@@ -217,7 +203,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
rc = sscanf(current + sz, "target%d:%d:%"PRIu64"/%n", &tosser0, &tosser1,
|
||||
&tosser3, &pos0);
|
||||
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
|
||||
if (rc != 3)
|
||||
return -1;
|
||||
sz += pos0;
|
||||
@@ -230,7 +215,6 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
rc = sscanf(current + sz, "%d:%d:%d:%"PRIu64"/%n",
|
||||
scsi_bus, scsi_device, scsi_target, scsi_lun, &pos0);
|
||||
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos0, rc, 4);
|
||||
if (rc != 4)
|
||||
return -1;
|
||||
sz += pos0;
|
||||
@@ -247,13 +231,6 @@ parse_scsi(struct device *dev, const char *current, const char *root UNUSED)
|
||||
ssize_t sz;
|
||||
int pos;
|
||||
int rc;
|
||||
- char *spaces;
|
||||
-
|
||||
- pos = strlen(current);
|
||||
- spaces = alloca(pos+1);
|
||||
- memset(spaces, ' ', pos+1);
|
||||
- spaces[pos] = '\0';
|
||||
- pos = 0;
|
||||
|
||||
debug("entry");
|
||||
|
||||
@@ -265,7 +242,6 @@ parse_scsi(struct device *dev, const char *current, const char *root UNUSED)
|
||||
&dev->scsi_info.scsi_lun,
|
||||
&pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", dev->device, rc, pos);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
|
||||
if (rc != 4)
|
||||
return 0;
|
||||
|
||||
diff --git a/src/linux-soc-root.c b/src/linux-soc-root.c
|
||||
index 394f496a453..373cd59521a 100644
|
||||
--- a/src/linux-soc-root.c
|
||||
+++ b/src/linux-soc-root.c
|
||||
@@ -43,13 +43,6 @@ parse_soc_root(struct device *dev UNUSED, const char *current, const char *root
|
||||
int rc;
|
||||
int pos;
|
||||
const char *devpart = current;
|
||||
- char *spaces;
|
||||
-
|
||||
- pos = strlen(current);
|
||||
- spaces = alloca(pos+1);
|
||||
- memset(spaces, ' ', pos+1);
|
||||
- spaces[pos] = '\0';
|
||||
- pos = 0;
|
||||
|
||||
debug("entry");
|
||||
|
||||
diff --git a/src/linux-virtblk.c b/src/linux-virtblk.c
|
||||
index c54a813a947..2e9889def2f 100644
|
||||
--- a/src/linux-virtblk.c
|
||||
+++ b/src/linux-virtblk.c
|
||||
@@ -50,20 +50,12 @@ parse_virtblk(struct device *dev, const char *current, const char *root UNUSED)
|
||||
uint32_t tosser;
|
||||
int pos;
|
||||
int rc;
|
||||
- char *spaces;
|
||||
-
|
||||
- pos = strlen(current);
|
||||
- spaces = alloca(pos+1);
|
||||
- memset(spaces, ' ', pos+1);
|
||||
- spaces[pos] = '\0';
|
||||
- pos = 0;
|
||||
|
||||
debug("entry");
|
||||
|
||||
debug("searching for virtio0/");
|
||||
rc = sscanf(current, "virtio%x/%n", &tosser, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
|
||||
- arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
|
||||
/*
|
||||
* If we couldn't find virtioX/ then it isn't a virtio device.
|
||||
*/
|
||||
diff --git a/src/util.h b/src/util.h
|
||||
index ba8fee35ae9..6d3c10e946e 100644
|
||||
--- a/src/util.h
|
||||
+++ b/src/util.h
|
||||
@@ -388,7 +388,6 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
|
||||
#undef log
|
||||
#endif
|
||||
#define log(level, fmt, args...) log_(__FILE__, __LINE__, __func__, level, fmt, ## args)
|
||||
-#define arrow(l,b,o,p,n,m) ({if(n==m){char c_=b[p+1]; b[o]='^'; b[p+o]='^';b[p+o+1]='\0';log(l,"%s",b);b[o]=' ';b[p+o]=' ';b[p+o+1]=c_;}})
|
||||
#define debug(fmt, args...) log(LOG_DEBUG, fmt, ## args)
|
||||
|
||||
#endif /* EFIVAR_UTIL_H */
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,38 +0,0 @@
|
||||
From 25d73605b36933004b0266183de8051af30612ca Mon Sep 17 00:00:00 2001
|
||||
From: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
Date: Thu, 10 Jan 2019 16:44:38 +0800
|
||||
Subject: [PATCH 06/86] Define strdupa if it is not defined
|
||||
|
||||
Android does not include strdupa in <string.h>. Define strdupa if it has
|
||||
not already been defined.
|
||||
|
||||
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
---
|
||||
src/util.h | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/src/util.h b/src/util.h
|
||||
index 6d3c10e946e..d98bfa1beed 100644
|
||||
--- a/src/util.h
|
||||
+++ b/src/util.h
|
||||
@@ -252,6 +252,17 @@ lcm(uint64_t x, uint64_t y)
|
||||
return (x / n) * y;
|
||||
}
|
||||
|
||||
+#ifndef strdupa
|
||||
+#define strdupa(s) \
|
||||
+ (__extension__ ({ \
|
||||
+ const char *__in = (s); \
|
||||
+ size_t __len = strlen (__in); \
|
||||
+ char *__out = (char *) alloca (__len + 1); \
|
||||
+ strcpy(__out, __in); \
|
||||
+ __out; \
|
||||
+ }))
|
||||
+#endif
|
||||
+
|
||||
#ifndef strndupa
|
||||
#define strndupa(s, l) \
|
||||
(__extension__ ({ \
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,82 +0,0 @@
|
||||
From 1a0ea5da82d8be7d05338bb42e8e71cdba7866f4 Mon Sep 17 00:00:00 2001
|
||||
From: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
Date: Thu, 10 Jan 2019 16:48:30 +0800
|
||||
Subject: [PATCH 07/86] Android: inital porting of libefivar
|
||||
|
||||
The static library is linked by efibootmgr.
|
||||
|
||||
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
---
|
||||
src/Android.mk | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 60 insertions(+)
|
||||
create mode 100644 src/Android.mk
|
||||
|
||||
diff --git a/src/Android.mk b/src/Android.mk
|
||||
new file mode 100644
|
||||
index 00000000000..b3410e1f3e7
|
||||
--- /dev/null
|
||||
+++ b/src/Android.mk
|
||||
@@ -0,0 +1,60 @@
|
||||
+#
|
||||
+# Copyright (C) 2019 The Android-x86 Open Source Project
|
||||
+#
|
||||
+# Licensed under the GNU Lesser General Public License Version 2.1.
|
||||
+# You may not use this file except in compliance with the License.
|
||||
+# You may obtain a copy of the License at
|
||||
+#
|
||||
+# https://www.gnu.org/licenses/lgpl-2.1.html
|
||||
+#
|
||||
+
|
||||
+LOCAL_PATH := $(call my-dir)
|
||||
+
|
||||
+include $(CLEAR_VARS)
|
||||
+
|
||||
+LOCAL_MODULE := makeguids
|
||||
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
+LOCAL_CFLAGS := -DEFIVAR_BUILD_ENVIRONMENT
|
||||
+LOCAL_SRC_FILES := guid.c makeguids.c
|
||||
+LOCAL_LDLIBS := -ldl
|
||||
+include $(BUILD_HOST_EXECUTABLE)
|
||||
+
|
||||
+include $(CLEAR_VARS)
|
||||
+
|
||||
+LOCAL_MODULE := libefivar
|
||||
+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
|
||||
+LIBEFIBOOT_SOURCES := \
|
||||
+ crc32.c \
|
||||
+ creator.c \
|
||||
+ disk.c \
|
||||
+ gpt.c \
|
||||
+ loadopt.c \
|
||||
+ path-helpers.c \
|
||||
+ $(notdir $(wildcard $(LOCAL_PATH)/linux*.c))
|
||||
+
|
||||
+LIBEFIVAR_SOURCES := \
|
||||
+ dp.c \
|
||||
+ dp-acpi.c \
|
||||
+ dp-hw.c \
|
||||
+ dp-media.c \
|
||||
+ dp-message.c \
|
||||
+ efivarfs.c \
|
||||
+ error.c \
|
||||
+ export.c \
|
||||
+ guid.c \
|
||||
+ guids.S \
|
||||
+ lib.c \
|
||||
+ vars.c
|
||||
+
|
||||
+LOCAL_SRC_FILES := $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES)
|
||||
+LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu11
|
||||
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES) $(LOCAL_C_INCLUDES)/efivar $(local-generated-sources-dir)
|
||||
+LIBEFIVAR_GUIDS_H := $(local-generated-sources-dir)/efivar/efivar-guids.h
|
||||
+LOCAL_GENERATED_SOURCES := $(LIBEFIVAR_GUIDS_H) $(local-generated-sources-dir)/guid-symbols.c
|
||||
+$(LIBEFIVAR_GUIDS_H): PRIVATE_CUSTOM_TOOL = $^ $(addprefix $(dir $(@D)),guids.bin names.bin guid-symbols.c efivar/efivar-guids.h)
|
||||
+$(LIBEFIVAR_GUIDS_H): $(BUILD_OUT_EXECUTABLES)/makeguids $(LOCAL_PATH)/guids.txt
|
||||
+ $(transform-generated-source)
|
||||
+$(lastword $(LOCAL_GENERATED_SOURCES)): $(LIBEFIVAR_GUIDS_H)
|
||||
+
|
||||
+include $(BUILD_STATIC_LIBRARY)
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,40 +0,0 @@
|
||||
From 22da79a45a0c3a1437255c813b0b86a7b7925ae3 Mon Sep 17 00:00:00 2001
|
||||
From: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
Date: Tue, 26 Feb 2019 14:57:00 +0800
|
||||
Subject: [PATCH 08/86] Remove an unused function
|
||||
|
||||
This gets rid of an error from Android 9 clang:
|
||||
|
||||
external/efivar/src/linux.c:256:1: error: unused function 'supports_iface' [-Werror,-Wunused-function]
|
||||
supports_iface(struct dev_probe *probe, enum interface_type iftype)
|
||||
^
|
||||
1 error generated.
|
||||
|
||||
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
---
|
||||
src/linux.c | 9 ---------
|
||||
1 file changed, 9 deletions(-)
|
||||
|
||||
diff --git a/src/linux.c b/src/linux.c
|
||||
index 6d405af8a76..4bb453be834 100644
|
||||
--- a/src/linux.c
|
||||
+++ b/src/linux.c
|
||||
@@ -252,15 +252,6 @@ static struct dev_probe *dev_probes[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
-static inline bool
|
||||
-supports_iface(struct dev_probe *probe, enum interface_type iftype)
|
||||
-{
|
||||
- for (unsigned int i = 0; probe->iftypes[i] != unknown; i++)
|
||||
- if (probe->iftypes[i] == iftype)
|
||||
- return true;
|
||||
- return false;
|
||||
-}
|
||||
-
|
||||
void HIDDEN
|
||||
device_free(struct device *dev)
|
||||
{
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,54 +0,0 @@
|
||||
From 0dad6d78a7fb5f6c5fb4a1d646040539db6cf865 Mon Sep 17 00:00:00 2001
|
||||
From: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
Date: Tue, 26 Feb 2019 18:42:20 +0800
|
||||
Subject: [PATCH 09/86] Fix another error of -Werror=address-of-packed-member
|
||||
|
||||
Android 9 clang complains:
|
||||
|
||||
external/efivar/src/dp-message.c:367:24: error: taking address of packed member '' of class or structure 'efidp_infiniband' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member]
|
||||
(efi_guid_t *)&dp->infiniband.ioc_guid);
|
||||
^~~~~~~~~~~~~~~~~~~~~~~
|
||||
external/efivar/src/dp.h:76:19: note: expanded from macro 'format_guid'
|
||||
memmove(&_guid, guid, sizeof(_guid)); \
|
||||
^~~~
|
||||
1 error generated.
|
||||
|
||||
Since commit c3c553d the fifth parameter of format_guid() is treated as
|
||||
a const void *. The casting is unnecessary.
|
||||
|
||||
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
---
|
||||
src/dp-media.c | 3 +--
|
||||
src/dp-message.c | 2 +-
|
||||
2 files changed, 2 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/dp-media.c b/src/dp-media.c
|
||||
index 96a576fdc2a..be691c44326 100644
|
||||
--- a/src/dp-media.c
|
||||
+++ b/src/dp-media.c
|
||||
@@ -46,8 +46,7 @@ _format_media_dn(char *buf, size_t size, const_efidp dp)
|
||||
break;
|
||||
case EFIDP_HD_SIGNATURE_GUID:
|
||||
format(buf, size, off, "HD", "GPT,");
|
||||
- format_guid(buf, size, off, "HD",
|
||||
- (efi_guid_t *)dp->hd.signature);
|
||||
+ format_guid(buf, size, off, "HD", dp->hd.signature);
|
||||
format(buf, size, off, "HD",
|
||||
",0x%"PRIx64",0x%"PRIx64")",
|
||||
dp->hd.start, dp->hd.size);
|
||||
diff --git a/src/dp-message.c b/src/dp-message.c
|
||||
index 9f964663de8..6b8e9072594 100644
|
||||
--- a/src/dp-message.c
|
||||
+++ b/src/dp-message.c
|
||||
@@ -364,7 +364,7 @@ _format_message_dn(char *buf, size_t size, const_efidp dp)
|
||||
dp->infiniband.port_gid[1],
|
||||
dp->infiniband.port_gid[0]);
|
||||
format_guid(buf, size, off, "Infiniband",
|
||||
- (efi_guid_t *)&dp->infiniband.ioc_guid);
|
||||
+ &dp->infiniband.ioc_guid);
|
||||
format(buf, size, off, "Infiniband",
|
||||
",%"PRIu64",%"PRIu64")",
|
||||
dp->infiniband.target_port_id,
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,34 +0,0 @@
|
||||
From fdb803402fb32fa6d020bac57a40c7efe4aabb7d Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 5 Mar 2019 17:23:24 +0100
|
||||
Subject: [PATCH 10/86] ucs2.h: remove unused variable
|
||||
|
||||
The const uint16_t pointer is not used since now the two bytes of the
|
||||
UCS-2 chars are checked to know if is the termination of the string.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
src/ucs2.h | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/ucs2.h b/src/ucs2.h
|
||||
index edd8367b4bc..e0390c34985 100644
|
||||
--- a/src/ucs2.h
|
||||
+++ b/src/ucs2.h
|
||||
@@ -26,12 +26,11 @@ static inline size_t UNUSED
|
||||
ucs2len(const void *vs, ssize_t limit)
|
||||
{
|
||||
ssize_t i;
|
||||
- const uint16_t *s = vs;
|
||||
const uint8_t *s8 = vs;
|
||||
|
||||
for (i = 0;
|
||||
i < (limit >= 0 ? limit : i+1) && s8[0] != 0 && s8[1] != 0;
|
||||
- i++, s8 += 2, s++)
|
||||
+ i++, s8 += 2)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,32 +0,0 @@
|
||||
From 4e04afc2df9bbc26e5ab524b53a6f4f1e61d7c9e Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 5 Mar 2019 17:23:32 +0100
|
||||
Subject: [PATCH 11/86] ucs2.h: fix logic that checks for UCS-2 string
|
||||
termination
|
||||
|
||||
Currently the loop to count the lenght of the UCS-2 string ends if either
|
||||
of the two bytes are 0, but 0 is a valid value for UCS-2 character codes.
|
||||
|
||||
So only break the loop when 0 is the value for both UCS-2 char bytes.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
src/ucs2.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/ucs2.h b/src/ucs2.h
|
||||
index e0390c34985..fd8b056ad25 100644
|
||||
--- a/src/ucs2.h
|
||||
+++ b/src/ucs2.h
|
||||
@@ -29,7 +29,7 @@ ucs2len(const void *vs, ssize_t limit)
|
||||
const uint8_t *s8 = vs;
|
||||
|
||||
for (i = 0;
|
||||
- i < (limit >= 0 ? limit : i+1) && s8[0] != 0 && s8[1] != 0;
|
||||
+ i < (limit >= 0 ? limit : i+1) && !(s8[0] == 0 && s8[1] == 0);
|
||||
i++, s8 += 2)
|
||||
;
|
||||
return i;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,44 +0,0 @@
|
||||
From 836461e480e2249de134efeaef79588cab045d5c Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 5 Mar 2019 17:23:36 +0100
|
||||
Subject: [PATCH 12/86] dp-message: fix efidp_ipv4_addr fields assignment
|
||||
|
||||
The efidp_ipv4_addr structure has some 4-byte array fields to store IPv4
|
||||
addresses and network mask. But the efidp_make_ipv4() function wrongly
|
||||
casts these as a char * before dereferencing them to store a value.
|
||||
|
||||
Instead, cast it to a uint32_t * so the 32-bit value is correctly stored.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
src/dp-message.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/dp-message.c b/src/dp-message.c
|
||||
index 6b8e9072594..55fa7810439 100644
|
||||
--- a/src/dp-message.c
|
||||
+++ b/src/dp-message.c
|
||||
@@ -678,16 +678,16 @@ efidp_make_ipv4(uint8_t *buf, ssize_t size, uint32_t local, uint32_t remote,
|
||||
EFIDP_MSG_IPv4, sizeof (*ipv4));
|
||||
ssize_t req = sizeof (*ipv4);
|
||||
if (size && sz == req) {
|
||||
- *((char *)ipv4->local_ipv4_addr) = htonl(local);
|
||||
- *((char *)ipv4->remote_ipv4_addr) = htonl(remote);
|
||||
+ *((uint32_t *)ipv4->local_ipv4_addr) = htonl(local);
|
||||
+ *((uint32_t *)ipv4->remote_ipv4_addr) = htonl(remote);
|
||||
ipv4->local_port = htons(local_port);
|
||||
ipv4->remote_port = htons(remote_port);
|
||||
ipv4->protocol = htons(protocol);
|
||||
ipv4->static_ip_addr = 0;
|
||||
if (is_static)
|
||||
ipv4->static_ip_addr = 1;
|
||||
- *((char *)ipv4->gateway) = htonl(gateway);
|
||||
- *((char *)ipv4->netmask) = htonl(netmask);
|
||||
+ *((uint32_t *)ipv4->gateway) = htonl(gateway);
|
||||
+ *((uint32_t *)ipv4->netmask) = htonl(netmask);
|
||||
}
|
||||
|
||||
if (sz < 0)
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,129 +0,0 @@
|
||||
From 038afd7a792df5d882d4ca29cc6f9723f3c3fc0f Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 13 Mar 2019 11:01:34 -0400
|
||||
Subject: [PATCH 13/86] Always refer to MBR and GPT fixed values as 'magic' not
|
||||
'signature'
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/disk.c | 5 +++--
|
||||
src/gpt.c | 22 +++++++++++-----------
|
||||
src/gpt.h | 8 ++++----
|
||||
3 files changed, 18 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/src/disk.c b/src/disk.c
|
||||
index 3efee03b804..519c2a19325 100644
|
||||
--- a/src/disk.c
|
||||
+++ b/src/disk.c
|
||||
@@ -52,10 +52,11 @@ is_mbr_valid(legacy_mbr *mbr)
|
||||
int ret;
|
||||
if (!mbr)
|
||||
return 0;
|
||||
- ret = (mbr->signature == MSDOS_MBR_SIGNATURE);
|
||||
+ ret = (mbr->magic == MSDOS_MBR_MAGIC);
|
||||
if (!ret) {
|
||||
errno = ENOTTY;
|
||||
- efi_error("mbr signature is not MSDOS_MBR_SIGNATURE");
|
||||
+ efi_error("mbr magic is 0x%04hx not MSDOS_MBR_MAGIC (0x%04hx)",
|
||||
+ mbr->magic, MSDOS_MBR_MAGIC);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
diff --git a/src/gpt.c b/src/gpt.c
|
||||
index ce8e638ab83..7bdb8ad1575 100644
|
||||
--- a/src/gpt.c
|
||||
+++ b/src/gpt.c
|
||||
@@ -72,24 +72,24 @@ efi_crc32(const void *buf, unsigned long len)
|
||||
*
|
||||
* Description: Returns 1 if PMBR is valid, 0 otherwise.
|
||||
* Validity depends on two things:
|
||||
- * 1) MSDOS signature is in the last two bytes of the MBR
|
||||
+ * 1) MSDOS magic is in the last two bytes of the MBR
|
||||
* 2) One partition of type 0xEE is found
|
||||
*/
|
||||
static int
|
||||
is_pmbr_valid(legacy_mbr *mbr)
|
||||
{
|
||||
- int i, found = 0, signature = 0;
|
||||
+ int i, found = 0, magic = 0;
|
||||
if (!mbr)
|
||||
return 0;
|
||||
- signature = (le16_to_cpu(mbr->signature) == MSDOS_MBR_SIGNATURE);
|
||||
- for (i = 0; signature && i < 4; i++) {
|
||||
+ magic = (le16_to_cpu(mbr->magic) == MSDOS_MBR_MAGIC);
|
||||
+ for (i = 0; magic && i < 4; i++) {
|
||||
if (mbr->partition[i].os_type ==
|
||||
EFI_PMBR_OSTYPE_EFI_GPT) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
- return (signature && found);
|
||||
+ return (magic && found);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -389,11 +389,11 @@ is_gpt_valid(int fd, uint64_t lba,
|
||||
if (!(*gpt = alloc_read_gpt_header(fd, lba)))
|
||||
return 0;
|
||||
|
||||
- /* Check the GUID Partition Table signature */
|
||||
- if (le64_to_cpu((*gpt)->signature) != GPT_HEADER_SIGNATURE) {
|
||||
- efi_error("GUID Partition Table Header signature is wrong: %"PRIx64" != %"PRIx64,
|
||||
- (uint64_t)le64_to_cpu((*gpt)->signature),
|
||||
- GPT_HEADER_SIGNATURE);
|
||||
+ /* Check the GUID Partition Table magic */
|
||||
+ if (le64_to_cpu((*gpt)->magic) != GPT_HEADER_MAGIC) {
|
||||
+ efi_error("GUID Partition Table Header magic is wrong: %"PRIx64" != %"PRIx64,
|
||||
+ (uint64_t)le64_to_cpu((*gpt)->magic),
|
||||
+ GPT_HEADER_MAGIC);
|
||||
free(*gpt);
|
||||
*gpt = NULL;
|
||||
return rc;
|
||||
@@ -673,7 +673,7 @@ find_valid_gpt(int fd, gpt_header ** gpt, gpt_entry ** ptes,
|
||||
|
||||
/* Would fail due to bad PMBR, but force GPT anyhow */
|
||||
if ((good_pgpt || good_agpt) && !good_pmbr && ignore_pmbr_err) {
|
||||
- efi_error(" Warning: Disk has a valid GPT signature but invalid PMBR.\n"
|
||||
+ efi_error(" Warning: Disk has a valid GPT magic but invalid PMBR.\n"
|
||||
" Use GNU Parted to correct disk.\n"
|
||||
" gpt option taken, disk treated as GPT.");
|
||||
}
|
||||
diff --git a/src/gpt.h b/src/gpt.h
|
||||
index 5eb5d1a732c..0d7d5e8a649 100644
|
||||
--- a/src/gpt.h
|
||||
+++ b/src/gpt.h
|
||||
@@ -29,10 +29,10 @@
|
||||
|
||||
#define EFI_PMBR_OSTYPE_EFI 0xEF
|
||||
#define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
|
||||
-#define MSDOS_MBR_SIGNATURE 0xaa55
|
||||
+#define MSDOS_MBR_MAGIC 0xaa55
|
||||
#define GPT_BLOCK_SIZE 512
|
||||
|
||||
-#define GPT_HEADER_SIGNATURE ((uint64_t)(0x5452415020494645ULL))
|
||||
+#define GPT_HEADER_MAGIC ((uint64_t)(0x5452415020494645ULL))
|
||||
#define GPT_HEADER_REVISION_V1_02 0x00010200
|
||||
#define GPT_HEADER_REVISION_V1_00 0x00010000
|
||||
#define GPT_HEADER_REVISION_V0_99 0x00009900
|
||||
@@ -61,7 +61,7 @@
|
||||
0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
|
||||
|
||||
typedef struct _gpt_header {
|
||||
- uint64_t signature;
|
||||
+ uint64_t magic;
|
||||
uint32_t revision;
|
||||
uint32_t header_size;
|
||||
uint32_t header_crc32;
|
||||
@@ -133,7 +133,7 @@ typedef struct _legacy_mbr {
|
||||
uint32_t unique_mbr_signature;
|
||||
uint16_t unknown;
|
||||
partition_record partition[4];
|
||||
- uint16_t signature;
|
||||
+ uint16_t magic;
|
||||
} PACKED legacy_mbr;
|
||||
|
||||
#define EFI_GPT_PRIMARY_PARTITION_TABLE_LBA 1
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,87 +0,0 @@
|
||||
From 48910a0cd39d7c08dab555fb464f9765163ad37b Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 13 Mar 2019 11:02:01 -0400
|
||||
Subject: [PATCH 14/86] Add more hexdump logging functions.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/hexdump.h | 30 ++++++++++++++++++++++++++++--
|
||||
src/util.h | 10 ++++++++++
|
||||
2 files changed, 38 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/hexdump.h b/src/hexdump.h
|
||||
index 4c45cb3732d..f8c32faa9e1 100644
|
||||
--- a/src/hexdump.h
|
||||
+++ b/src/hexdump.h
|
||||
@@ -63,8 +63,12 @@ prepare_text(uint8_t *data, unsigned long size, char *buf)
|
||||
buf[offset] = '\0';
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * variadic fhexdump formatted
|
||||
+ * think of it as: fprintf(f, %s%s\n", vformat(fmt, ap), hexdump(data,size));
|
||||
+ */
|
||||
static inline void UNUSED
|
||||
-hexdump(uint8_t *data, unsigned long size)
|
||||
+vfhexdumpf(FILE *f, const char * const fmt, uint8_t *data, unsigned long size, va_list ap)
|
||||
{
|
||||
unsigned long display_offset = (unsigned long)data & 0xffffffff;
|
||||
unsigned long offset = 0;
|
||||
@@ -80,11 +84,33 @@ hexdump(uint8_t *data, unsigned long size)
|
||||
return;
|
||||
|
||||
prepare_text(data+offset, size-offset, txtbuf);
|
||||
- printf("%016lx %s %s\n", display_offset, hexbuf, txtbuf);
|
||||
+ vfprintf(f, fmt, ap);
|
||||
+ fprintf(f, "%016lx %s %s\n", display_offset, hexbuf, txtbuf);
|
||||
|
||||
display_offset += sz;
|
||||
offset += sz;
|
||||
}
|
||||
+ fflush(f);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * fhexdump formatted
|
||||
+ * think of it as: fprintf(f, %s%s\n", format(fmt, ...), hexdump(data,size));
|
||||
+ */
|
||||
+static inline void UNUSED
|
||||
+fhexdumpf(FILE *f, const char * const fmt, uint8_t *data, unsigned long size, ...)
|
||||
+{
|
||||
+ va_list ap;
|
||||
+
|
||||
+ va_start(ap, size);
|
||||
+ vfhexdumpf(f, fmt, data, size, ap);
|
||||
+ va_end(ap);
|
||||
+}
|
||||
+
|
||||
+static inline void UNUSED
|
||||
+hexdump(uint8_t *data, unsigned long size)
|
||||
+{
|
||||
+ fhexdumpf(stdout, "", data, size);
|
||||
}
|
||||
|
||||
#endif /* STATIC_HEXDUMP_H */
|
||||
diff --git a/src/util.h b/src/util.h
|
||||
index d98bfa1beed..a6a80e754ec 100644
|
||||
--- a/src/util.h
|
||||
+++ b/src/util.h
|
||||
@@ -400,5 +400,15 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
|
||||
#endif
|
||||
#define log(level, fmt, args...) log_(__FILE__, __LINE__, __func__, level, fmt, ## args)
|
||||
#define debug(fmt, args...) log(LOG_DEBUG, fmt, ## args)
|
||||
+#define log_hex_(file, line, func, level, buf, size) \
|
||||
+ ({ \
|
||||
+ if (efi_get_verbose() >= level) { \
|
||||
+ fhexdumpf(efi_get_logfile(), "%s:%d %s(): ", \
|
||||
+ (uint8_t *)buf, size, \
|
||||
+ file, line, func); \
|
||||
+ } \
|
||||
+ })
|
||||
+#define log_hex(level, buf, size) log_hex_(__FILE__, __LINE__, __func__, level, buf, size)
|
||||
+#define debug_hex(buf, size) log_hex(LOG_DEBUG, buf, size)
|
||||
|
||||
#endif /* EFIVAR_UTIL_H */
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,147 +0,0 @@
|
||||
From 2b34ea97db8e42e2461981d812dd5e71b12f09c1 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 28 May 2019 14:02:12 -0400
|
||||
Subject: [PATCH 15/86] Add efi_error_pop() and pop some errors sometimes.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/error.c | 37 +++++++++++++++++++++++++++++--------
|
||||
src/include/efivar/efivar.h | 9 +++++++++
|
||||
src/libefivar.map.in | 7 +++++++
|
||||
src/linux.c | 4 ++++
|
||||
4 files changed, 49 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/error.c b/src/error.c
|
||||
index d1008a3d676..df03d7f45e0 100644
|
||||
--- a/src/error.c
|
||||
+++ b/src/error.c
|
||||
@@ -78,6 +78,22 @@ efi_error_get(unsigned int n,
|
||||
return 1;
|
||||
}
|
||||
|
||||
+static inline UNUSED void
|
||||
+clear_error_entry(error_table_entry *et)
|
||||
+{
|
||||
+ if (!et)
|
||||
+ return;
|
||||
+
|
||||
+ if (et->filename)
|
||||
+ free(et->filename);
|
||||
+ if (et->function)
|
||||
+ free(et->function);
|
||||
+ if (et->message)
|
||||
+ free(et->message);
|
||||
+
|
||||
+ memset(et, '\0', sizeof(*et));
|
||||
+}
|
||||
+
|
||||
int PUBLIC NONNULL(1, 2, 5) PRINTF(5, 6)
|
||||
efi_error_set(const char *filename,
|
||||
const char *function,
|
||||
@@ -136,6 +152,16 @@ err:
|
||||
return -1;
|
||||
}
|
||||
|
||||
+void PUBLIC
|
||||
+efi_error_pop(void)
|
||||
+{
|
||||
+ if (current <= 0)
|
||||
+ return;
|
||||
+
|
||||
+ current -= 1;
|
||||
+ clear_error_entry(&error_table[current]);
|
||||
+}
|
||||
+
|
||||
void PUBLIC DESTRUCTOR
|
||||
efi_error_clear(void)
|
||||
{
|
||||
@@ -143,14 +169,7 @@ efi_error_clear(void)
|
||||
for (unsigned int i = 0; i < current; i++) {
|
||||
error_table_entry *et = &error_table[i];
|
||||
|
||||
- if (et->filename)
|
||||
- free(et->filename);
|
||||
- if (et->function)
|
||||
- free(et->function);
|
||||
- if (et->message)
|
||||
- free(et->message);
|
||||
-
|
||||
- memset(et, '\0', sizeof(*et));
|
||||
+ clear_error_entry(et);
|
||||
}
|
||||
free(error_table);
|
||||
}
|
||||
@@ -182,3 +201,5 @@ efi_get_verbose(void)
|
||||
{
|
||||
return efi_verbose;
|
||||
}
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
|
||||
index ad6449d9d93..dabf41789e5 100644
|
||||
--- a/src/include/efivar/efivar.h
|
||||
+++ b/src/include/efivar/efivar.h
|
||||
@@ -187,6 +187,7 @@ extern int efi_error_set(const char *filename,
|
||||
__attribute__((__nonnull__ (1, 2, 5)))
|
||||
__attribute__((__format__ (printf, 5, 6)));
|
||||
extern void efi_error_clear(void);
|
||||
+extern void efi_error_pop(void);
|
||||
#else
|
||||
static inline int
|
||||
__attribute__((__nonnull__ (2, 3, 4, 5, 6)))
|
||||
@@ -218,6 +219,12 @@ efi_error_clear(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
+
|
||||
+static inline void
|
||||
+efi_error_pop(void)
|
||||
+{
|
||||
+ return;
|
||||
+}
|
||||
#endif
|
||||
|
||||
#define efi_error_real__(errval, file, function, line, fmt, args...) \
|
||||
@@ -238,3 +245,5 @@ extern FILE * efi_get_logfile(void)
|
||||
#include <efivar/efivar-dp.h>
|
||||
|
||||
#endif /* EFIVAR_H */
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/libefivar.map.in b/src/libefivar.map.in
|
||||
index b5ee1ce334a..8e50d574f10 100644
|
||||
--- a/src/libefivar.map.in
|
||||
+++ b/src/libefivar.map.in
|
||||
@@ -127,3 +127,10 @@ LIBEFIVAR_1.36 {
|
||||
efi_get_verbose;
|
||||
efi_get_logfile;
|
||||
} LIBEFIVAR_1.35;
|
||||
+
|
||||
+LIBEFIVAR_1.37 {
|
||||
+} LIBEFIVAR_1.36;
|
||||
+
|
||||
+LIBEFIVAR_1.38 {
|
||||
+ global: efi_error_pop;
|
||||
+} LIBEFIVAR_1.37;
|
||||
diff --git a/src/linux.c b/src/linux.c
|
||||
index 4bb453be834..4e102da5e24 100644
|
||||
--- a/src/linux.c
|
||||
+++ b/src/linux.c
|
||||
@@ -405,6 +405,8 @@ struct device HIDDEN
|
||||
rc = sysfs_readlink(&tmpbuf,
|
||||
"block/%s/device/device/driver",
|
||||
dev->disk_name);
|
||||
+ if (rc >= 0 && tmpbuf)
|
||||
+ efi_error_pop();
|
||||
}
|
||||
if (rc < 0 || !tmpbuf) {
|
||||
efi_error("readlink of /sys/block/%s/device/driver failed",
|
||||
@@ -626,3 +628,5 @@ get_sector_size(int filedes)
|
||||
sector_size = 512;
|
||||
return sector_size;
|
||||
}
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:et
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,215 +0,0 @@
|
||||
From 2bd7a0b4f54e74ac976c14d631643676bea70819 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 28 May 2019 15:42:37 -0400
|
||||
Subject: [PATCH 16/86] Always log to a memfd regardless of loglevel.
|
||||
|
||||
This writes all debug logs to a memfd, so that they'll always show up in
|
||||
strace.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/error.c | 88 ++++++++++++++++++++++++++++++++++---
|
||||
src/include/efivar/efivar.h | 7 +++
|
||||
src/libefivar.map.in | 1 +
|
||||
src/util.h | 26 +++++------
|
||||
4 files changed, 102 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/src/error.c b/src/error.c
|
||||
index df03d7f45e0..5dc43197c50 100644
|
||||
--- a/src/error.c
|
||||
+++ b/src/error.c
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
+#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "efiboot.h"
|
||||
@@ -162,7 +163,58 @@ efi_error_pop(void)
|
||||
clear_error_entry(&error_table[current]);
|
||||
}
|
||||
|
||||
-void PUBLIC DESTRUCTOR
|
||||
+static int efi_verbose;
|
||||
+static FILE *efi_errlog, *efi_dbglog;
|
||||
+static int efi_dbglog_fd = -1;
|
||||
+static int stashed_log_level;
|
||||
+static char efi_dbglog_buf[4096];
|
||||
+
|
||||
+void PUBLIC
|
||||
+efi_stash_loglevel_(int level)
|
||||
+{
|
||||
+ stashed_log_level = level;
|
||||
+}
|
||||
+
|
||||
+static ssize_t
|
||||
+dbglog_write(void *cookie UNUSED, const char *buf, size_t size)
|
||||
+{
|
||||
+ FILE *log = efi_errlog ? efi_errlog : stderr;
|
||||
+ ssize_t ret = size;
|
||||
+
|
||||
+ if (efi_get_verbose() >= stashed_log_level) {
|
||||
+ ret = fwrite(buf, 1, size, log);
|
||||
+ } else if (efi_dbglog_fd >= 0) {
|
||||
+ lseek(efi_dbglog_fd, 0, SEEK_SET);
|
||||
+ write(efi_dbglog_fd, buf, size);
|
||||
+ }
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+dbglog_seek(void *cookie UNUSED, off64_t *offset, int whence)
|
||||
+{
|
||||
+ FILE *log = efi_errlog ? efi_errlog : stderr;
|
||||
+ return fseek(log, *offset, whence);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+dbglog_close(void *cookie UNUSED)
|
||||
+{
|
||||
+ if (efi_dbglog_fd >= 0) {
|
||||
+ close(efi_dbglog_fd);
|
||||
+ efi_dbglog_fd = -1;
|
||||
+ }
|
||||
+ if (efi_errlog) {
|
||||
+ int ret = fclose(efi_errlog);
|
||||
+ efi_errlog = NULL;
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ errno = EBADF;
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+void PUBLIC
|
||||
efi_error_clear(void)
|
||||
{
|
||||
if (error_table) {
|
||||
@@ -177,15 +229,39 @@ efi_error_clear(void)
|
||||
current = 0;
|
||||
}
|
||||
|
||||
-static int efi_verbose;
|
||||
-static FILE *efi_errlog;
|
||||
+void DESTRUCTOR
|
||||
+efi_error_fini(void)
|
||||
+{
|
||||
+ efi_error_clear();
|
||||
+ if (efi_dbglog) {
|
||||
+ fclose(efi_dbglog);
|
||||
+ efi_dbglog = NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void CONSTRUCTOR
|
||||
+efi_error_init(void)
|
||||
+{
|
||||
+ cookie_io_functions_t io_funcs = {
|
||||
+ .write = dbglog_write,
|
||||
+ .seek = dbglog_seek,
|
||||
+ .close = dbglog_close,
|
||||
+ };
|
||||
+
|
||||
+ efi_dbglog_fd = memfd_create("efivar-debug.log", MFD_CLOEXEC);
|
||||
+ if (efi_dbglog_fd == -1)
|
||||
+ return;
|
||||
+
|
||||
+ efi_dbglog = fopencookie(NULL, "a", io_funcs);
|
||||
+ if (efi_dbglog)
|
||||
+ setvbuf(efi_dbglog, efi_dbglog_buf, _IOLBF,
|
||||
+ sizeof(efi_dbglog_buf));
|
||||
+}
|
||||
|
||||
FILE PUBLIC *
|
||||
efi_get_logfile(void)
|
||||
{
|
||||
- if (efi_errlog)
|
||||
- return efi_errlog;
|
||||
- return stderr;
|
||||
+ return efi_dbglog;
|
||||
}
|
||||
|
||||
void PUBLIC
|
||||
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
|
||||
index dabf41789e5..343d1c557da 100644
|
||||
--- a/src/include/efivar/efivar.h
|
||||
+++ b/src/include/efivar/efivar.h
|
||||
@@ -188,6 +188,7 @@ extern int efi_error_set(const char *filename,
|
||||
__attribute__((__format__ (printf, 5, 6)));
|
||||
extern void efi_error_clear(void);
|
||||
extern void efi_error_pop(void);
|
||||
+extern void efi_stash_loglevel_(int level);
|
||||
#else
|
||||
static inline int
|
||||
__attribute__((__nonnull__ (2, 3, 4, 5, 6)))
|
||||
@@ -225,6 +226,12 @@ efi_error_pop(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
+
|
||||
+static inline void
|
||||
+efi_stash_loglevel_(int level __attribute__((__unused__)))
|
||||
+{
|
||||
+ return;
|
||||
+}
|
||||
#endif
|
||||
|
||||
#define efi_error_real__(errval, file, function, line, fmt, args...) \
|
||||
diff --git a/src/libefivar.map.in b/src/libefivar.map.in
|
||||
index 8e50d574f10..8965b729917 100644
|
||||
--- a/src/libefivar.map.in
|
||||
+++ b/src/libefivar.map.in
|
||||
@@ -133,4 +133,5 @@ LIBEFIVAR_1.37 {
|
||||
|
||||
LIBEFIVAR_1.38 {
|
||||
global: efi_error_pop;
|
||||
+ efi_stash_loglevel_;
|
||||
} LIBEFIVAR_1.37;
|
||||
diff --git a/src/util.h b/src/util.h
|
||||
index a6a80e754ec..337762c9902 100644
|
||||
--- a/src/util.h
|
||||
+++ b/src/util.h
|
||||
@@ -382,15 +382,14 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
|
||||
|
||||
#define log_(file, line, func, level, fmt, args...) \
|
||||
({ \
|
||||
- if (efi_get_verbose() >= level) { \
|
||||
- FILE *logfile_ = efi_get_logfile(); \
|
||||
- int len_ = strlen(fmt); \
|
||||
- fprintf(logfile_, "%s:%d %s(): ", \
|
||||
- file, line, func); \
|
||||
- fprintf(logfile_, fmt, ## args); \
|
||||
- if (!len_ || fmt[len_ - 1] != '\n') \
|
||||
- fprintf(logfile_, "\n"); \
|
||||
- } \
|
||||
+ efi_stash_loglevel_(level); \
|
||||
+ FILE *logfile_ = efi_get_logfile(); \
|
||||
+ int len_ = strlen(fmt); \
|
||||
+ fprintf(logfile_, "%s:%d %s(): ", \
|
||||
+ file, line, func); \
|
||||
+ fprintf(logfile_, fmt, ## args); \
|
||||
+ if (!len_ || fmt[len_ - 1] != '\n') \
|
||||
+ fprintf(logfile_, "\n"); \
|
||||
})
|
||||
|
||||
#define LOG_VERBOSE 0
|
||||
@@ -402,11 +401,10 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
|
||||
#define debug(fmt, args...) log(LOG_DEBUG, fmt, ## args)
|
||||
#define log_hex_(file, line, func, level, buf, size) \
|
||||
({ \
|
||||
- if (efi_get_verbose() >= level) { \
|
||||
- fhexdumpf(efi_get_logfile(), "%s:%d %s(): ", \
|
||||
- (uint8_t *)buf, size, \
|
||||
- file, line, func); \
|
||||
- } \
|
||||
+ efi_stash_loglevel_(level); \
|
||||
+ fhexdumpf(efi_get_logfile(), "%s:%d %s(): ", \
|
||||
+ (uint8_t *)buf, size, \
|
||||
+ file, line, func); \
|
||||
})
|
||||
#define log_hex(level, buf, size) log_hex_(__FILE__, __LINE__, __func__, level, buf, size)
|
||||
#define debug_hex(buf, size) log_hex(LOG_DEBUG, buf, size)
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,82 +0,0 @@
|
||||
From 5dc12cc56c79d293cf68d12a0b84373a785745e7 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 28 May 2019 16:27:31 -0400
|
||||
Subject: [PATCH 17/86] Always initialize any variable we use with sscanf's %n
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/linux-acpi-root.c | 2 +-
|
||||
src/linux-pci-root.c | 2 +-
|
||||
src/linux-pci.c | 2 +-
|
||||
src/linux-soc-root.c | 2 +-
|
||||
src/linux-virtblk.c | 2 +-
|
||||
5 files changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/linux-acpi-root.c b/src/linux-acpi-root.c
|
||||
index 30728ded671..b237039685e 100644
|
||||
--- a/src/linux-acpi-root.c
|
||||
+++ b/src/linux-acpi-root.c
|
||||
@@ -44,7 +44,7 @@ static ssize_t
|
||||
parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED)
|
||||
{
|
||||
int rc;
|
||||
- int pos;
|
||||
+ int pos = 0;
|
||||
uint16_t pad0;
|
||||
uint8_t pad1;
|
||||
char *acpi_header = NULL;
|
||||
diff --git a/src/linux-pci-root.c b/src/linux-pci-root.c
|
||||
index 0605acfc7cb..0b5ad48d6db 100644
|
||||
--- a/src/linux-pci-root.c
|
||||
+++ b/src/linux-pci-root.c
|
||||
@@ -44,7 +44,7 @@ static ssize_t
|
||||
parse_pci_root(struct device *dev, const char *current, const char *root UNUSED)
|
||||
{
|
||||
int rc;
|
||||
- int pos;
|
||||
+ int pos = 0;
|
||||
uint16_t root_domain;
|
||||
uint8_t root_bus;
|
||||
const char *devpart = current;
|
||||
diff --git a/src/linux-pci.c b/src/linux-pci.c
|
||||
index 64aaefb461c..c3b9fcf9092 100644
|
||||
--- a/src/linux-pci.c
|
||||
+++ b/src/linux-pci.c
|
||||
@@ -46,7 +46,7 @@ static ssize_t
|
||||
parse_pci(struct device *dev, const char *current, const char *root)
|
||||
{
|
||||
int rc;
|
||||
- int pos;
|
||||
+ int pos = 0;
|
||||
const char *devpart = current;
|
||||
|
||||
debug("entry");
|
||||
diff --git a/src/linux-soc-root.c b/src/linux-soc-root.c
|
||||
index 373cd59521a..cbb4779b6fb 100644
|
||||
--- a/src/linux-soc-root.c
|
||||
+++ b/src/linux-soc-root.c
|
||||
@@ -41,7 +41,7 @@ static ssize_t
|
||||
parse_soc_root(struct device *dev UNUSED, const char *current, const char *root UNUSED)
|
||||
{
|
||||
int rc;
|
||||
- int pos;
|
||||
+ int pos = 0;
|
||||
const char *devpart = current;
|
||||
|
||||
debug("entry");
|
||||
diff --git a/src/linux-virtblk.c b/src/linux-virtblk.c
|
||||
index 2e9889def2f..fe6eb873a37 100644
|
||||
--- a/src/linux-virtblk.c
|
||||
+++ b/src/linux-virtblk.c
|
||||
@@ -48,7 +48,7 @@ static ssize_t
|
||||
parse_virtblk(struct device *dev, const char *current, const char *root UNUSED)
|
||||
{
|
||||
uint32_t tosser;
|
||||
- int pos;
|
||||
+ int pos = 0;
|
||||
int rc;
|
||||
|
||||
debug("entry");
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,126 +0,0 @@
|
||||
From 2763ad732781c9e8b36bdab25d04ca632c9b77fe Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 28 May 2019 16:08:25 -0400
|
||||
Subject: [PATCH 18/86] Add efi_get_libefivar_version() and
|
||||
efi_get_libefiboot_version()
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
Make.defaults | 2 +-
|
||||
src/Android.mk | 4 +++-
|
||||
src/creator.c | 6 ++++++
|
||||
src/include/efivar/efiboot.h | 3 +++
|
||||
src/include/efivar/efivar.h | 3 +++
|
||||
src/lib.c | 6 ++++++
|
||||
src/libefiboot.map.in | 4 ++++
|
||||
src/libefivar.map.in | 1 +
|
||||
8 files changed, 27 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Make.defaults b/Make.defaults
|
||||
index 57cee6e82b5..6c575846687 100644
|
||||
--- a/Make.defaults
|
||||
+++ b/Make.defaults
|
||||
@@ -18,7 +18,7 @@ CCLD_FOR_BUILD ?= $(CC_FOR_BUILD)
|
||||
CCLD := $(if $(filter undefined,$(origin CCLD)),$(CC),$(CCLD))
|
||||
OPTIMIZE ?= -O2 -flto
|
||||
CFLAGS ?= $(OPTIMIZE) -g3
|
||||
-CFLAGS := $(CFLAGS)
|
||||
+CFLAGS := $(CFLAGS) -DLIBEFIVAR_VERSION=$(VERSION)
|
||||
LDFLAGS ?=
|
||||
LDFLAGS := $(LDFLAGS)
|
||||
AR := $(CROSS_COMPILE)$(COMPILER)-ar
|
||||
diff --git a/src/Android.mk b/src/Android.mk
|
||||
index b3410e1f3e7..bf6cfb2e91b 100644
|
||||
--- a/src/Android.mk
|
||||
+++ b/src/Android.mk
|
||||
@@ -46,8 +46,10 @@ LIBEFIVAR_SOURCES := \
|
||||
lib.c \
|
||||
vars.c
|
||||
|
||||
+include $(LOCAL_PATH)/../Make.version
|
||||
+
|
||||
LOCAL_SRC_FILES := $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES)
|
||||
-LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu11
|
||||
+LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu11 -DLIBEFIVAR_VERSION=$(VERSION)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES) $(LOCAL_C_INCLUDES)/efivar $(local-generated-sources-dir)
|
||||
LIBEFIVAR_GUIDS_H := $(local-generated-sources-dir)/efivar/efivar-guids.h
|
||||
diff --git a/src/creator.c b/src/creator.c
|
||||
index 987fa033e5b..f4bb01bc4a6 100644
|
||||
--- a/src/creator.c
|
||||
+++ b/src/creator.c
|
||||
@@ -511,3 +511,9 @@ efi_generate_ipv4_device_path(uint8_t *buf, ssize_t size,
|
||||
|
||||
return off;
|
||||
}
|
||||
+
|
||||
+uint32_t PUBLIC
|
||||
+efi_get_libefiboot_version(void)
|
||||
+{
|
||||
+ return LIBEFIVAR_VERSION;
|
||||
+}
|
||||
diff --git a/src/include/efivar/efiboot.h b/src/include/efivar/efiboot.h
|
||||
index c2af55fbf45..2aee86d661e 100644
|
||||
--- a/src/include/efivar/efiboot.h
|
||||
+++ b/src/include/efivar/efiboot.h
|
||||
@@ -35,4 +35,7 @@
|
||||
#include <efivar/efiboot-creator.h>
|
||||
#include <efivar/efiboot-loadopt.h>
|
||||
|
||||
+extern uint32_t efi_get_libefiboot_version(void)
|
||||
+ __attribute__((__visibility__("default")));
|
||||
+
|
||||
#endif /* EFIBOOT_H */
|
||||
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
|
||||
index 343d1c557da..ff95cb10791 100644
|
||||
--- a/src/include/efivar/efivar.h
|
||||
+++ b/src/include/efivar/efivar.h
|
||||
@@ -249,6 +249,9 @@ extern int efi_get_verbose(void)
|
||||
extern FILE * efi_get_logfile(void)
|
||||
__attribute__((__visibility__("default")));
|
||||
|
||||
+extern uint32_t efi_get_libefivar_version(void)
|
||||
+ __attribute__((__visibility__("default")));
|
||||
+
|
||||
#include <efivar/efivar-dp.h>
|
||||
|
||||
#endif /* EFIVAR_H */
|
||||
diff --git a/src/lib.c b/src/lib.c
|
||||
index dc06fdb3c15..457a8604d5d 100644
|
||||
--- a/src/lib.c
|
||||
+++ b/src/lib.c
|
||||
@@ -265,3 +265,9 @@ libefivar_init(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+uint32_t PUBLIC
|
||||
+efi_get_libefivar_version(void)
|
||||
+{
|
||||
+ return LIBEFIVAR_VERSION;
|
||||
+}
|
||||
diff --git a/src/libefiboot.map.in b/src/libefiboot.map.in
|
||||
index cb19d65d0e4..0771eac5639 100644
|
||||
--- a/src/libefiboot.map.in
|
||||
+++ b/src/libefiboot.map.in
|
||||
@@ -33,3 +33,7 @@ LIBEFIBOOT_1.29 {
|
||||
|
||||
LIBEFIBOOT_1.30 {
|
||||
} LIBEFIBOOT_1.29;
|
||||
+
|
||||
+LIBEFIBOOT_1.31 {
|
||||
+ global: efi_get_libefiboot_version;
|
||||
+} LIBEFIBOOT_1.30;
|
||||
diff --git a/src/libefivar.map.in b/src/libefivar.map.in
|
||||
index 8965b729917..33196fefc64 100644
|
||||
--- a/src/libefivar.map.in
|
||||
+++ b/src/libefivar.map.in
|
||||
@@ -134,4 +134,5 @@ LIBEFIVAR_1.37 {
|
||||
LIBEFIVAR_1.38 {
|
||||
global: efi_error_pop;
|
||||
efi_stash_loglevel_;
|
||||
+ efi_get_libefivar_version;
|
||||
} LIBEFIVAR_1.37;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,32 +0,0 @@
|
||||
From ee17f35cc79a865d700c78f783a7aa886a89dc1d Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 29 May 2019 09:28:50 -0400
|
||||
Subject: [PATCH 19/86] Fix dbglog_seek() to update the offset.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/error.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/error.c b/src/error.c
|
||||
index 5dc43197c50..5eaee84599a 100644
|
||||
--- a/src/error.c
|
||||
+++ b/src/error.c
|
||||
@@ -194,7 +194,13 @@ static int
|
||||
dbglog_seek(void *cookie UNUSED, off64_t *offset, int whence)
|
||||
{
|
||||
FILE *log = efi_errlog ? efi_errlog : stderr;
|
||||
- return fseek(log, *offset, whence);
|
||||
+ int rc;
|
||||
+
|
||||
+ rc = fseek(log, *offset, whence);
|
||||
+ if (rc < 0)
|
||||
+ return rc;
|
||||
+ *offset = ftell(log);
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
--
|
||||
2.24.1
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,70 +0,0 @@
|
||||
From 8a003f0c495da3719338881286bc2976b2d086aa Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 29 May 2019 10:11:24 -0400
|
||||
Subject: [PATCH 21/86] Fix up efi_guid_cmp()'s alignment problem a different
|
||||
way
|
||||
|
||||
With the prior fix for efi_guid_cmp()'s alignment issue, abicheck shows:
|
||||
|
||||
1 function with some indirect sub-type change:
|
||||
|
||||
[C]'function int efi_guid_cmp(void* const, void* const)' at <built-in>:34:1 has some indirect sub-type changes:
|
||||
parameter 1 of type 'void* const' changed:
|
||||
entity changed from 'void* const' to 'const efi_guid_t*'
|
||||
type size hasn't changed
|
||||
parameter 2 of type 'void* const' changed:
|
||||
entity changed from 'void* const' to 'const efi_guid_t*'
|
||||
type size hasn't changed
|
||||
|
||||
While this isn't a meaningful ABI difference in terms of linking, it is
|
||||
definitely worse than having the type actually specified.
|
||||
|
||||
This patch changes the type back to the previous type, but also changes
|
||||
the typedef to require a 1-byte alignment. This will guarantee that all
|
||||
new builds of efi_guid_cmp() and related code have code generated in a
|
||||
way that's compatible with any alignment, thus alleviating the issue.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/guid.c | 2 +-
|
||||
src/include/efivar/efivar.h | 4 ++--
|
||||
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/guid.c b/src/guid.c
|
||||
index 3156b3b7c60..306c9ff8287 100644
|
||||
--- a/src/guid.c
|
||||
+++ b/src/guid.c
|
||||
@@ -31,7 +31,7 @@
|
||||
extern const efi_guid_t efi_guid_zero;
|
||||
|
||||
int NONNULL(1, 2) PUBLIC
|
||||
-efi_guid_cmp(const void * const a, const void * const b)
|
||||
+efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b)
|
||||
{
|
||||
return memcmp(a, b, sizeof (efi_guid_t));
|
||||
}
|
||||
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
|
||||
index ff95cb10791..11d9a9d7b78 100644
|
||||
--- a/src/include/efivar/efivar.h
|
||||
+++ b/src/include/efivar/efivar.h
|
||||
@@ -37,7 +37,7 @@ typedef struct {
|
||||
uint16_t c;
|
||||
uint16_t d;
|
||||
uint8_t e[6];
|
||||
-} efi_guid_t;
|
||||
+} efi_guid_t __attribute__((__aligned__(1)));
|
||||
|
||||
typedef struct {
|
||||
uint8_t addr[4];
|
||||
@@ -128,7 +128,7 @@ extern int efi_symbol_to_guid(const char *symbol, efi_guid_t *guid)
|
||||
|
||||
extern int efi_guid_is_zero(const efi_guid_t *guid);
|
||||
extern int efi_guid_is_empty(const efi_guid_t *guid);
|
||||
-extern int efi_guid_cmp(const void * const a, const void * const b);
|
||||
+extern int efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b);
|
||||
|
||||
/* import / export functions */
|
||||
typedef struct efi_variable efi_variable_t;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,27 +0,0 @@
|
||||
From 2ed65b6801e0c7eb24d32b338f035c5b5d684205 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 29 May 2019 10:18:56 -0400
|
||||
Subject: [PATCH 22/86] Fix dbglog_write() to always return the status of
|
||||
write()
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/error.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/error.c b/src/error.c
|
||||
index 5eaee84599a..a77b0df1feb 100644
|
||||
--- a/src/error.c
|
||||
+++ b/src/error.c
|
||||
@@ -185,7 +185,7 @@ dbglog_write(void *cookie UNUSED, const char *buf, size_t size)
|
||||
ret = fwrite(buf, 1, size, log);
|
||||
} else if (efi_dbglog_fd >= 0) {
|
||||
lseek(efi_dbglog_fd, 0, SEEK_SET);
|
||||
- write(efi_dbglog_fd, buf, size);
|
||||
+ ret = write(efi_dbglog_fd, buf, size);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,36 +0,0 @@
|
||||
From 15a379e4764ae5a3f5d8fdf224410c7eaa74c66a Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 29 May 2019 10:21:32 -0400
|
||||
Subject: [PATCH 23/86] Do a better job of making sure -DLIBEFIVAR_VERSION
|
||||
happens...
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
Make.defaults | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Make.defaults b/Make.defaults
|
||||
index 6c575846687..80fd99eba71 100644
|
||||
--- a/Make.defaults
|
||||
+++ b/Make.defaults
|
||||
@@ -18,7 +18,7 @@ CCLD_FOR_BUILD ?= $(CC_FOR_BUILD)
|
||||
CCLD := $(if $(filter undefined,$(origin CCLD)),$(CC),$(CCLD))
|
||||
OPTIMIZE ?= -O2 -flto
|
||||
CFLAGS ?= $(OPTIMIZE) -g3
|
||||
-CFLAGS := $(CFLAGS) -DLIBEFIVAR_VERSION=$(VERSION)
|
||||
+CFLAGS := $(CFLAGS)
|
||||
LDFLAGS ?=
|
||||
LDFLAGS := $(LDFLAGS)
|
||||
AR := $(CROSS_COMPILE)$(COMPILER)-ar
|
||||
@@ -29,6 +29,8 @@ ABIDIFF := abidiff
|
||||
|
||||
PKGS =
|
||||
|
||||
+CPPFLAGS += -DLIBEFIVAR_VERSION=$(VERSION)
|
||||
+
|
||||
clang_cflags = -D_GNU_SOURCE -std=gnu11 -Wno-address-of-packed-member
|
||||
gcc_cflags = -specs=$(TOPDIR)/gcc.specs
|
||||
cflags = $(CFLAGS) -I${TOPDIR}/src/include/ \
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,102 +0,0 @@
|
||||
From e0ded4593e57657837dfcf110985eabaa37bc492 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 29 May 2019 10:28:41 -0400
|
||||
Subject: [PATCH 24/86] efi_stash_loglevel_() -> efi_set_loglevel()
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/error.c | 8 ++++----
|
||||
src/include/efivar/efivar.h | 4 ++--
|
||||
src/libefivar.map.in | 2 +-
|
||||
src/util.h | 4 ++--
|
||||
4 files changed, 9 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/error.c b/src/error.c
|
||||
index a77b0df1feb..083de15e984 100644
|
||||
--- a/src/error.c
|
||||
+++ b/src/error.c
|
||||
@@ -166,13 +166,13 @@ efi_error_pop(void)
|
||||
static int efi_verbose;
|
||||
static FILE *efi_errlog, *efi_dbglog;
|
||||
static int efi_dbglog_fd = -1;
|
||||
-static int stashed_log_level;
|
||||
+static int log_level;
|
||||
static char efi_dbglog_buf[4096];
|
||||
|
||||
void PUBLIC
|
||||
-efi_stash_loglevel_(int level)
|
||||
+efi_set_loglevel(int level)
|
||||
{
|
||||
- stashed_log_level = level;
|
||||
+ log_level = level;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
@@ -181,7 +181,7 @@ dbglog_write(void *cookie UNUSED, const char *buf, size_t size)
|
||||
FILE *log = efi_errlog ? efi_errlog : stderr;
|
||||
ssize_t ret = size;
|
||||
|
||||
- if (efi_get_verbose() >= stashed_log_level) {
|
||||
+ if (efi_get_verbose() >= log_level) {
|
||||
ret = fwrite(buf, 1, size, log);
|
||||
} else if (efi_dbglog_fd >= 0) {
|
||||
lseek(efi_dbglog_fd, 0, SEEK_SET);
|
||||
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
|
||||
index 11d9a9d7b78..2fdf5b93b29 100644
|
||||
--- a/src/include/efivar/efivar.h
|
||||
+++ b/src/include/efivar/efivar.h
|
||||
@@ -188,7 +188,7 @@ extern int efi_error_set(const char *filename,
|
||||
__attribute__((__format__ (printf, 5, 6)));
|
||||
extern void efi_error_clear(void);
|
||||
extern void efi_error_pop(void);
|
||||
-extern void efi_stash_loglevel_(int level);
|
||||
+extern void efi_set_loglevel(int level);
|
||||
#else
|
||||
static inline int
|
||||
__attribute__((__nonnull__ (2, 3, 4, 5, 6)))
|
||||
@@ -228,7 +228,7 @@ efi_error_pop(void)
|
||||
}
|
||||
|
||||
static inline void
|
||||
-efi_stash_loglevel_(int level __attribute__((__unused__)))
|
||||
+efi_set_loglevel(int level __attribute__((__unused__)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
diff --git a/src/libefivar.map.in b/src/libefivar.map.in
|
||||
index 33196fefc64..682e622c302 100644
|
||||
--- a/src/libefivar.map.in
|
||||
+++ b/src/libefivar.map.in
|
||||
@@ -133,6 +133,6 @@ LIBEFIVAR_1.37 {
|
||||
|
||||
LIBEFIVAR_1.38 {
|
||||
global: efi_error_pop;
|
||||
- efi_stash_loglevel_;
|
||||
+ efi_set_loglevel;
|
||||
efi_get_libefivar_version;
|
||||
} LIBEFIVAR_1.37;
|
||||
diff --git a/src/util.h b/src/util.h
|
||||
index 337762c9902..ec1c5f1a69a 100644
|
||||
--- a/src/util.h
|
||||
+++ b/src/util.h
|
||||
@@ -382,7 +382,7 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
|
||||
|
||||
#define log_(file, line, func, level, fmt, args...) \
|
||||
({ \
|
||||
- efi_stash_loglevel_(level); \
|
||||
+ efi_set_loglevel(level); \
|
||||
FILE *logfile_ = efi_get_logfile(); \
|
||||
int len_ = strlen(fmt); \
|
||||
fprintf(logfile_, "%s:%d %s(): ", \
|
||||
@@ -401,7 +401,7 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
|
||||
#define debug(fmt, args...) log(LOG_DEBUG, fmt, ## args)
|
||||
#define log_hex_(file, line, func, level, buf, size) \
|
||||
({ \
|
||||
- efi_stash_loglevel_(level); \
|
||||
+ efi_set_loglevel(level); \
|
||||
fhexdumpf(efi_get_logfile(), "%s:%d %s(): ", \
|
||||
(uint8_t *)buf, size, \
|
||||
file, line, func); \
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,38 +0,0 @@
|
||||
From fdf91db0e35bcc48164c8778fcd0f3ace7ab9403 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 17 Jun 2019 13:59:29 -0400
|
||||
Subject: [PATCH 25/86] guids: add 'grub' guid for grubenv.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/guids.txt | 1 +
|
||||
src/libefivar.map.in | 3 +++
|
||||
2 files changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/guids.txt b/src/guids.txt
|
||||
index 0d48ddbad30..2486255b26c 100644
|
||||
--- a/src/guids.txt
|
||||
+++ b/src/guids.txt
|
||||
@@ -21,6 +21,7 @@
|
||||
826ca512-cf10-4ac9-b187-be01496631bd sha1 SHA-1
|
||||
82988420-7467-4490-9059-feb448dd1963 lenovo_me_config Lenovo ME Configuration Menu
|
||||
8be4df61-93ca-11d2-aa0d-00e098032b8c global EFI Global Variable
|
||||
+91376aff-cba6-42be-949d-06fde81128e8 grub GRUB
|
||||
a5c059a1-94e4-4aa7-87b5-ab155c2bf072 x509_cert X.509 Certificate
|
||||
a7717414-c616-4977-9420-844712a735bf rsa2048_sha256_cert RSA 2048 with SHA-256 Certificate
|
||||
a7d8d9a6-6ab0-4aeb-ad9d-163e59a7a380 lenovo_diag_splash Lenovo Diagnostic Splash Screen
|
||||
diff --git a/src/libefivar.map.in b/src/libefivar.map.in
|
||||
index 682e622c302..54bfb765998 100644
|
||||
--- a/src/libefivar.map.in
|
||||
+++ b/src/libefivar.map.in
|
||||
@@ -135,4 +135,7 @@ LIBEFIVAR_1.38 {
|
||||
global: efi_error_pop;
|
||||
efi_set_loglevel;
|
||||
efi_get_libefivar_version;
|
||||
+ efi_guid_grub;
|
||||
+ efi_variable_alloc;
|
||||
+ efi_variable_export_dmpstore;
|
||||
} LIBEFIVAR_1.37;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,30 +0,0 @@
|
||||
From 4c419d91d9b81c6223a1d44b4ed759197fd2aab5 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 17 Jun 2019 14:00:05 -0400
|
||||
Subject: [PATCH 26/86] gcc.specs: add -grecord-gcc-switches
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
gcc.specs | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/gcc.specs b/gcc.specs
|
||||
index 45d43d11294..d06a8e096fc 100644
|
||||
--- a/gcc.specs
|
||||
+++ b/gcc.specs
|
||||
@@ -8,10 +8,10 @@
|
||||
+ %(efivar_cpp_options)
|
||||
|
||||
*cc1_options:
|
||||
-+ %(efivar_cpp_options) -Wmaybe-uninitialized -fno-merge-constants -fvisibility=hidden %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}}
|
||||
++ %(efivar_cpp_options) -Wmaybe-uninitialized -fno-merge-constants -fvisibility=hidden %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}} -grecord-gcc-switches
|
||||
|
||||
*self_spec:
|
||||
-+ %{!shared:%{!static:%{!r:-pie}}} %{static:-Wl,-no-fatal-warnings -Wl,-static -static -Wl,-z,relro,-z,now}
|
||||
++ %{!shared:%{!static:%{!r:-pie}}} %{static:-Wl,-no-fatal-warnings -Wl,-static -static -Wl,-z,relro,-z,now} -grecord-gcc-switches
|
||||
|
||||
*link:
|
||||
+ %{!static:--fatal-warnings} --no-undefined-version --no-allow-shlib-undefined --add-needed -z now --build-id %{!static:%{!shared:-pie}} %{shared:-z relro} %{static:%<pie}
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,26 +0,0 @@
|
||||
From f4258e12c75c446dab98c71354ae38c6bb9a7979 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 18 Jun 2019 10:05:11 -0400
|
||||
Subject: [PATCH 27/86] Makefile: don't echo our deps submake invocation
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/Makefile | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index 76bc4748eb1..ecbbc02e1f7 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -84,7 +84,7 @@ libefiboot.so : LIBS=efivar
|
||||
libefiboot.so : MAP=libefiboot.map
|
||||
|
||||
deps : $(ALL_SOURCES)
|
||||
- $(MAKE) -f $(SRCDIR)/Make.deps deps SOURCES="$(ALL_SOURCES)"
|
||||
+ @$(MAKE) -f $(SRCDIR)/Make.deps deps SOURCES="$(ALL_SOURCES)"
|
||||
|
||||
clean :
|
||||
@rm -rfv *~ *.o *.a *.E *.so *.so.* *.pc *.bin .*.d *.map \
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,26 +0,0 @@
|
||||
From 1ab255ac8be670c55c7c0dbf329801093c206f3e Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 18 Jun 2019 11:06:09 -0400
|
||||
Subject: [PATCH 28/86] Make: Add some more stuff to the toplevel 'clean'
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
Makefile | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 8c67b9d2654..9c2620cb485 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -49,7 +49,7 @@ clean :
|
||||
@set -e ; for x in $(SUBDIRS) ; do \
|
||||
$(MAKE) -C $$x $@ ; \
|
||||
done
|
||||
- @rm -vf efivar.spec
|
||||
+ @rm -vf efivar.spec vgcore.* core.*
|
||||
|
||||
test-archive: abicheck efivar.spec
|
||||
@rm -rf /tmp/efivar-$(GITTAG) /tmp/efivar-$(GITTAG)-tmp
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,31 +0,0 @@
|
||||
From 47351ed986d8cb2c04c0447e62419b3ef5eebc78 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 19 Jun 2019 11:35:28 -0400
|
||||
Subject: [PATCH 29/86] Make scan build rules slightly more intuitive.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
Make.scan-build | 7 +++----
|
||||
1 file changed, 3 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/Make.scan-build b/Make.scan-build
|
||||
index 7d684f7539f..f508e30be16 100644
|
||||
--- a/Make.scan-build
|
||||
+++ b/Make.scan-build
|
||||
@@ -12,10 +12,9 @@ scan-build : | scan-test
|
||||
scan-build : clean
|
||||
scan-build -o scan-results make $(DASHJ) CC=clang all
|
||||
|
||||
-scan-build-all : | scan-test
|
||||
-scan-build-all : clean
|
||||
- scan-build -o scan-results make $(DASHJ) CC=clang all
|
||||
+scan-build-all: | scan-build
|
||||
+scan : | scan-build
|
||||
|
||||
-.PHONY : scan-build scan-clean
|
||||
+.PHONY : scan-build scan-clean scan-build-all scan
|
||||
|
||||
# vim:ft=make
|
||||
--
|
||||
2.24.1
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,97 +0,0 @@
|
||||
From 68dfc9ec98de261401deb88686cd35600d69b8a6 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 17 Jun 2019 14:27:08 -0400
|
||||
Subject: [PATCH 31/86] Exported header whitespace cleanup.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/include/efivar/efiboot-creator.h | 2 ++
|
||||
src/include/efivar/efiboot-loadopt.h | 2 ++
|
||||
src/include/efivar/efiboot.h | 4 +++-
|
||||
src/include/efivar/efivar-dp.h | 8 +++++---
|
||||
src/include/efivar/efivar.h | 8 ++++----
|
||||
5 files changed, 16 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/include/efivar/efiboot-creator.h b/src/include/efivar/efiboot-creator.h
|
||||
index b56e836d2e5..b6e094c637c 100644
|
||||
--- a/src/include/efivar/efiboot-creator.h
|
||||
+++ b/src/include/efivar/efiboot-creator.h
|
||||
@@ -58,3 +58,5 @@ extern ssize_t efi_generate_ipv4_device_path(uint8_t *buf, ssize_t size,
|
||||
__attribute__((__visibility__ ("default")));
|
||||
|
||||
#endif /* _EFIBOOT_CREATOR_H */
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/include/efivar/efiboot-loadopt.h b/src/include/efivar/efiboot-loadopt.h
|
||||
index efc29c69d47..97b7892f4b8 100644
|
||||
--- a/src/include/efivar/efiboot-loadopt.h
|
||||
+++ b/src/include/efivar/efiboot-loadopt.h
|
||||
@@ -74,3 +74,5 @@ extern int efi_loadopt_is_valid(efi_load_option *opt, size_t size)
|
||||
__attribute__((__visibility__ ("default")));
|
||||
|
||||
#endif /* _EFIBOOT_LOADOPT_H */
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/include/efivar/efiboot.h b/src/include/efivar/efiboot.h
|
||||
index 2aee86d661e..8ae51ffa2a7 100644
|
||||
--- a/src/include/efivar/efiboot.h
|
||||
+++ b/src/include/efivar/efiboot.h
|
||||
@@ -36,6 +36,8 @@
|
||||
#include <efivar/efiboot-loadopt.h>
|
||||
|
||||
extern uint32_t efi_get_libefiboot_version(void)
|
||||
- __attribute__((__visibility__("default")));
|
||||
+ __attribute__((__visibility__("default")));
|
||||
|
||||
#endif /* EFIBOOT_H */
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/include/efivar/efivar-dp.h b/src/include/efivar/efivar-dp.h
|
||||
index eab04f2dfac..57453548701 100644
|
||||
--- a/src/include/efivar/efivar-dp.h
|
||||
+++ b/src/include/efivar/efivar-dp.h
|
||||
@@ -135,9 +135,9 @@ typedef struct {
|
||||
} EFIVAR_PACKED efidp_acpi_hid_ex;
|
||||
extern ssize_t
|
||||
efidp_make_acpi_hid_ex(uint8_t *buf, ssize_t size,
|
||||
- uint32_t hid, uint32_t uid, uint32_t cid,
|
||||
- const char *hidstr, const char *uidstr,
|
||||
- const char *cidstr);
|
||||
+ uint32_t hid, uint32_t uid, uint32_t cid,
|
||||
+ const char *hidstr, const char *uidstr,
|
||||
+ const char *cidstr);
|
||||
|
||||
#define EFIDP_PNP_EISA_ID_CONST 0x41d0
|
||||
#define EFIDP_PNP_ACPI_ID_CONST 0x8e09
|
||||
@@ -1257,3 +1257,5 @@ extern ssize_t efidp_make_generic(uint8_t *buf, ssize_t size, uint8_t type,
|
||||
EFIDP_END_INSTANCE, sizeof (efidp_header));
|
||||
|
||||
#endif /* _EFIVAR_DP_H */
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
|
||||
index 2fdf5b93b29..caa4adf056c 100644
|
||||
--- a/src/include/efivar/efivar.h
|
||||
+++ b/src/include/efivar/efivar.h
|
||||
@@ -243,14 +243,14 @@ efi_set_loglevel(int level __attribute__((__unused__)))
|
||||
efi_error_real__(errval, __FILE__, __func__, __LINE__, (fmt), ## args)
|
||||
|
||||
extern void efi_set_verbose(int verbosity, FILE *errlog)
|
||||
- __attribute__((__visibility__("default")));
|
||||
+ __attribute__((__visibility__("default")));
|
||||
extern int efi_get_verbose(void)
|
||||
- __attribute__((__visibility__("default")));
|
||||
+ __attribute__((__visibility__("default")));
|
||||
extern FILE * efi_get_logfile(void)
|
||||
- __attribute__((__visibility__("default")));
|
||||
+ __attribute__((__visibility__("default")));
|
||||
|
||||
extern uint32_t efi_get_libefivar_version(void)
|
||||
- __attribute__((__visibility__("default")));
|
||||
+ __attribute__((__visibility__("default")));
|
||||
|
||||
#include <efivar/efivar-dp.h>
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,142 +0,0 @@
|
||||
From 7ff64fa2dc920659aebab34dc1ef91afaff9b632 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 17 Jun 2019 14:45:39 -0400
|
||||
Subject: [PATCH 33/86] efivar: rework usage()
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/efivar.c | 74 ++++++++++++++++++++++++++++------------------------
|
||||
1 file changed, 40 insertions(+), 34 deletions(-)
|
||||
|
||||
diff --git a/src/efivar.c b/src/efivar.c
|
||||
index df075809db5..7f16ab15bab 100644
|
||||
--- a/src/efivar.c
|
||||
+++ b/src/efivar.c
|
||||
@@ -39,10 +39,11 @@ extern int optind, opterr, optopt;
|
||||
|
||||
#include "efivar.h"
|
||||
|
||||
-#define ACTION_LIST 0x1
|
||||
-#define ACTION_PRINT 0x2
|
||||
-#define ACTION_APPEND 0x4
|
||||
-#define ACTION_LIST_GUIDS 0x8
|
||||
+#define ACTION_USAGE 0x00
|
||||
+#define ACTION_LIST 0x01
|
||||
+#define ACTION_PRINT 0x02
|
||||
+#define ACTION_APPEND 0x04
|
||||
+#define ACTION_LIST_GUIDS 0x08
|
||||
#define ACTION_WRITE 0x10
|
||||
#define ACTION_PRINT_DEC 0x20
|
||||
|
||||
@@ -326,7 +327,7 @@ validate_name(const char *name)
|
||||
}
|
||||
|
||||
static void
|
||||
-prepare_data(const char *filename, void **data, size_t *data_size)
|
||||
+prepare_data(const char *filename, uint8_t **data, size_t *data_size)
|
||||
{
|
||||
int fd = -1;
|
||||
void *buf;
|
||||
@@ -365,25 +366,29 @@ err:
|
||||
exit(1);
|
||||
}
|
||||
|
||||
-static void
|
||||
-usage(const char *progname)
|
||||
+static void __attribute__((__noreturn__))
|
||||
+usage(int ret)
|
||||
{
|
||||
- printf("Usage: %s [OPTION...]\n", basename(progname));
|
||||
- printf(" -l, --list list current variables\n");
|
||||
- printf(" -p, --print print variable specified by --name\n");
|
||||
- printf(" -d, --print-decimal print variable in decimal values specified\n");
|
||||
- printf(" by --name\n");
|
||||
- printf(" -n, --name=<guid-name> variable to manipulate, in the form\n");
|
||||
- printf(" 8be4df61-93ca-11d2-aa0d-00e098032b8c-Boot0000\n");
|
||||
- printf(" -a, --append append to variable specified by --name\n");
|
||||
- printf(" -f, --fromfile=<file> use data from <file>\n");
|
||||
- printf(" -t, --attributes=<attributes> attributes to use on append\n");
|
||||
- printf(" -L, --list-guids show internal guid list\n");
|
||||
- printf(" -w, --write write to variable specified by --name\n\n");
|
||||
- printf("Help options:\n");
|
||||
- printf(" -?, --help Show this help message\n");
|
||||
- printf(" --usage Display brief usage message\n");
|
||||
- return;
|
||||
+ FILE *out = ret == 0 ? stdout : stderr;
|
||||
+ fprintf(out,
|
||||
+ "Usage: %s [OPTION...]\n"
|
||||
+ " -l, --list list current variables\n"
|
||||
+ " -p, --print print variable specified by --name\n"
|
||||
+ " -d, --print-decimal print variable in decimal values specified\n"
|
||||
+ " by --name\n"
|
||||
+ " -n, --name=<guid-name> variable to manipulate, in the form\n"
|
||||
+ " 8be4df61-93ca-11d2-aa0d-00e098032b8c-Boot0000\n"
|
||||
+ " -a, --append append to variable specified by --name\n"
|
||||
+ " -e, --export=<file> export variable to <file>\n"
|
||||
+ " -f, --fromfile=<file> use data from <file>\n"
|
||||
+ " -t, --attributes=<attributes> attributes to use on append\n"
|
||||
+ " -L, --list-guids show internal guid list\n"
|
||||
+ " -w, --write write to variable specified by --name\n\n"
|
||||
+ "Help options:\n"
|
||||
+ " -?, --help Show this help message\n"
|
||||
+ " --usage Display brief usage message\n",
|
||||
+ program_invocation_short_name);
|
||||
+ exit(ret);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -391,7 +396,7 @@ int main(int argc, char *argv[])
|
||||
int c = 0;
|
||||
int i = 0;
|
||||
int action = 0;
|
||||
- void *data = NULL;
|
||||
+ uint8_t *data = NULL;
|
||||
size_t data_size = 0;
|
||||
char *name = NULL;
|
||||
char *file = NULL;
|
||||
@@ -434,10 +439,10 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
case 't':
|
||||
attributes = strtoul(optarg, NULL, 10);
|
||||
- if (errno == ERANGE || errno == EINVAL) {
|
||||
- fprintf(stderr, "invalid argument for -t: %s: %s\n", optarg, strerror(errno));
|
||||
- return EXIT_FAILURE;
|
||||
- }
|
||||
+ if (errno == ERANGE || errno == EINVAL)
|
||||
+ err(1,
|
||||
+ "invalid argument for -t: %s: %m\n",
|
||||
+ optarg);
|
||||
break;
|
||||
case 'L':
|
||||
action |= ACTION_LIST_GUIDS;
|
||||
@@ -446,13 +451,11 @@ int main(int argc, char *argv[])
|
||||
action |= ACTION_WRITE;
|
||||
break;
|
||||
case '?':
|
||||
- usage(argv[0]);
|
||||
- return EXIT_SUCCESS;
|
||||
+ usage(EXIT_SUCCESS);
|
||||
+ break;
|
||||
case 0:
|
||||
- if (strcmp(lopts[i].name, "usage")) {
|
||||
- usage(argv[0]);
|
||||
- return EXIT_SUCCESS;
|
||||
- }
|
||||
+ if (strcmp(lopts[i].name, "usage"))
|
||||
+ usage(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -506,6 +509,9 @@ int main(int argc, char *argv[])
|
||||
guid[i].symbol + strlen("efi_guid_"),
|
||||
guid[i].symbol, guid[i].name);
|
||||
}
|
||||
+ case ACTION_USAGE:
|
||||
+ default:
|
||||
+ usage(EXIT_FAILURE);
|
||||
}
|
||||
};
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,431 +0,0 @@
|
||||
From ba165d1482558005a16f4b44abaa1df5169727d1 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 17 Jun 2019 14:47:24 -0400
|
||||
Subject: [PATCH 34/86] Try to deal with some signof(char) != signof(uint8_t)
|
||||
madness.
|
||||
|
||||
The 3-sign "char" type in C is so so painful sometimes. This attempts
|
||||
to use -funsigned-char to avoid type-casting between (uint8_t *) and
|
||||
(char *) quite so much. I'm not sure it'll pay off. The fact that
|
||||
"char" is something that's not ever actually the same type as "unsigned
|
||||
char" or "signed char" is still the absolute worst thing.
|
||||
|
||||
Why do we need signed char at all again?
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
Make.defaults | 4 +++-
|
||||
gcc.specs | 4 ++--
|
||||
src/dp-acpi.c | 11 ++++++-----
|
||||
src/dp-hw.c | 5 +++--
|
||||
src/dp-media.c | 2 +-
|
||||
src/dp-message.c | 22 +++++++++++-----------
|
||||
src/dp.c | 8 +++++---
|
||||
src/dp.h | 18 ++++++++++--------
|
||||
src/export.c | 12 ++++++------
|
||||
src/include/efivar/efivar-dp.h | 10 ++++++----
|
||||
src/include/efivar/efivar.h | 4 ++--
|
||||
src/ucs2.h | 6 +++---
|
||||
12 files changed, 58 insertions(+), 48 deletions(-)
|
||||
|
||||
diff --git a/Make.defaults b/Make.defaults
|
||||
index 80fd99eba71..36e922f5ba7 100644
|
||||
--- a/Make.defaults
|
||||
+++ b/Make.defaults
|
||||
@@ -31,7 +31,9 @@ PKGS =
|
||||
|
||||
CPPFLAGS += -DLIBEFIVAR_VERSION=$(VERSION)
|
||||
|
||||
-clang_cflags = -D_GNU_SOURCE -std=gnu11 -Wno-address-of-packed-member
|
||||
+clang_cflags = -D_GNU_SOURCE -std=gnu11 -Wno-address-of-packed-member \
|
||||
+ -funsigned-char -Wall -Wno-nonnull-compare \
|
||||
+ -Werror -Wno-error=cpp
|
||||
gcc_cflags = -specs=$(TOPDIR)/gcc.specs
|
||||
cflags = $(CFLAGS) -I${TOPDIR}/src/include/ \
|
||||
$(if $(findstring clang,$(CC)),$(clang_cflags),) \
|
||||
diff --git a/gcc.specs b/gcc.specs
|
||||
index d06a8e096fc..9d2b145ee6e 100644
|
||||
--- a/gcc.specs
|
||||
+++ b/gcc.specs
|
||||
@@ -2,13 +2,13 @@
|
||||
+ -D_GNU_SOURCE
|
||||
|
||||
*efivar_cpp_options:
|
||||
- -Werror -Wall -std=gnu11 -Wextra
|
||||
+ -Wall -Wno-nonnull-compare -Werror -Wno-error=cpp -std=gnu11 -Wextra -funsigned-char
|
||||
|
||||
*cpp_options:
|
||||
+ %(efivar_cpp_options)
|
||||
|
||||
*cc1_options:
|
||||
-+ %(efivar_cpp_options) -Wmaybe-uninitialized -fno-merge-constants -fvisibility=hidden %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}} -grecord-gcc-switches
|
||||
++ %(efivar_cpp_options) -Wmaybe-uninitialized -fno-merge-constants -funsigned-char -fvisibility=hidden %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}} -grecord-gcc-switches
|
||||
|
||||
*self_spec:
|
||||
+ %{!shared:%{!static:%{!r:-pie}}} %{static:-Wl,-no-fatal-warnings -Wl,-static -static -Wl,-z,relro,-z,now} -grecord-gcc-switches
|
||||
diff --git a/src/dp-acpi.c b/src/dp-acpi.c
|
||||
index 2525fdfd073..02ec70eec7a 100644
|
||||
--- a/src/dp-acpi.c
|
||||
+++ b/src/dp-acpi.c
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "efivar.h"
|
||||
|
||||
static ssize_t
|
||||
-_format_acpi_adr(char *buf, size_t size,
|
||||
+_format_acpi_adr(unsigned char *buf, size_t size,
|
||||
const char *dp_type UNUSED,
|
||||
const_efidp dp)
|
||||
{
|
||||
@@ -45,9 +45,10 @@ _format_acpi_adr(char *buf, size_t size,
|
||||
format_helper(_format_acpi_adr, buf, size, off, "AcpiAdr", dp)
|
||||
|
||||
static ssize_t
|
||||
-_format_acpi_hid_ex(char *buf, size_t size, const char *dp_type UNUSED,
|
||||
- const_efidp dp,
|
||||
- const char *hidstr, const char *cidstr, const char *uidstr)
|
||||
+_format_acpi_hid_ex(unsigned char *buf, size_t size,
|
||||
+ const char *dp_type UNUSED, const_efidp dp,
|
||||
+ const char *hidstr, const char *cidstr,
|
||||
+ const char *uidstr)
|
||||
{
|
||||
ssize_t off = 0;
|
||||
|
||||
@@ -98,7 +99,7 @@ _format_acpi_hid_ex(char *buf, size_t size, const char *dp_type UNUSED,
|
||||
hidstr, cidstr, uidstr)
|
||||
|
||||
ssize_t
|
||||
-_format_acpi_dn(char *buf, size_t size, const_efidp dp)
|
||||
+_format_acpi_dn(unsigned char *buf, size_t size, const_efidp dp)
|
||||
{
|
||||
ssize_t off = 0;
|
||||
const char *hidstr = NULL;
|
||||
diff --git a/src/dp-hw.c b/src/dp-hw.c
|
||||
index 1fe0f66e871..28998316d9d 100644
|
||||
--- a/src/dp-hw.c
|
||||
+++ b/src/dp-hw.c
|
||||
@@ -26,7 +26,8 @@
|
||||
#include "efivar.h"
|
||||
|
||||
ssize_t
|
||||
-format_edd10_guid(char *buf, size_t size, const char *dp_type, const_efidp dp)
|
||||
+format_edd10_guid(unsigned char *buf, size_t size,
|
||||
+ const char *dp_type, const_efidp dp)
|
||||
{
|
||||
ssize_t off = 0;
|
||||
efidp_edd10 const *edd_dp = (efidp_edd10 *)dp;
|
||||
@@ -36,7 +37,7 @@ format_edd10_guid(char *buf, size_t size, const char *dp_type, const_efidp dp)
|
||||
}
|
||||
|
||||
ssize_t
|
||||
-_format_hw_dn(char *buf, size_t size, const_efidp dp)
|
||||
+_format_hw_dn(unsigned char *buf, size_t size, const_efidp dp)
|
||||
{
|
||||
efi_guid_t edd10_guid = EDD10_HARDWARE_VENDOR_PATH_GUID;
|
||||
ssize_t off = 0;
|
||||
diff --git a/src/dp-media.c b/src/dp-media.c
|
||||
index 4728c326100..7f5d1c678ce 100644
|
||||
--- a/src/dp-media.c
|
||||
+++ b/src/dp-media.c
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "efivar.h"
|
||||
|
||||
ssize_t
|
||||
-_format_media_dn(char *buf, size_t size, const_efidp dp)
|
||||
+_format_media_dn(unsigned char *buf, size_t size, const_efidp dp)
|
||||
{
|
||||
ssize_t off = 0;
|
||||
switch (dp->subtype) {
|
||||
diff --git a/src/dp-message.c b/src/dp-message.c
|
||||
index b88f17fb712..d00b2ad5d67 100644
|
||||
--- a/src/dp-message.c
|
||||
+++ b/src/dp-message.c
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "efivar.h"
|
||||
|
||||
static ssize_t
|
||||
-format_ipv4_addr_helper(char *buf, size_t size, const char *dp_type,
|
||||
+format_ipv4_addr_helper(unsigned char *buf, size_t size, const char *dp_type,
|
||||
const uint8_t *ipaddr, int32_t port)
|
||||
{
|
||||
ssize_t off = 0;
|
||||
@@ -40,7 +40,7 @@ format_ipv4_addr_helper(char *buf, size_t size, const char *dp_type,
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
-format_ipv6_addr_helper(char *buf, size_t size, const char *dp_type,
|
||||
+format_ipv6_addr_helper(unsigned char *buf, size_t size, const char *dp_type,
|
||||
const uint8_t *ipaddr, int32_t port)
|
||||
{
|
||||
uint16_t *ip = (uint16_t *)ipaddr;
|
||||
@@ -123,7 +123,7 @@ format_ipv6_addr_helper(char *buf, size_t size, const char *dp_type,
|
||||
"IPv6", addr, port)
|
||||
|
||||
static ssize_t
|
||||
-format_ip_addr_helper(char *buf, size_t size,
|
||||
+format_ip_addr_helper(unsigned char *buf, size_t size,
|
||||
const char *dp_type UNUSED,
|
||||
int is_ipv6, const efi_ip_addr_t *addr)
|
||||
{
|
||||
@@ -142,7 +142,7 @@ format_ip_addr_helper(char *buf, size_t size,
|
||||
dp_type, is_ipv6, addr)
|
||||
|
||||
static ssize_t
|
||||
-format_uart(char *buf, size_t size,
|
||||
+format_uart(unsigned char *buf, size_t size,
|
||||
const char *dp_type UNUSED,
|
||||
const_efidp dp)
|
||||
{
|
||||
@@ -162,7 +162,7 @@ format_uart(char *buf, size_t size,
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
-format_sas(char *buf, size_t size,
|
||||
+format_sas(unsigned char *buf, size_t size,
|
||||
const char *dp_type UNUSED,
|
||||
const_efidp dp)
|
||||
{
|
||||
@@ -232,7 +232,7 @@ format_sas(char *buf, size_t size,
|
||||
dp->usb_class.device_protocol)
|
||||
|
||||
static ssize_t
|
||||
-format_usb_class(char *buf, size_t size,
|
||||
+format_usb_class(unsigned char *buf, size_t size,
|
||||
const char *dp_type UNUSED,
|
||||
const_efidp dp)
|
||||
{
|
||||
@@ -312,7 +312,7 @@ format_usb_class(char *buf, size_t size,
|
||||
}
|
||||
|
||||
ssize_t
|
||||
-_format_message_dn(char *buf, size_t size, const_efidp dp)
|
||||
+_format_message_dn(unsigned char *buf, size_t size, const_efidp dp)
|
||||
{
|
||||
ssize_t off = 0;
|
||||
switch (dp->subtype) {
|
||||
@@ -393,7 +393,7 @@ _format_message_dn(char *buf, size_t size, const_efidp dp)
|
||||
struct {
|
||||
efi_guid_t guid;
|
||||
char label[40];
|
||||
- ssize_t (*formatter)(char *buf, size_t size,
|
||||
+ ssize_t (*formatter)(unsigned char *buf, size_t size,
|
||||
const char *dp_type UNUSED,
|
||||
const_efidp dp);
|
||||
} subtypes[] = {
|
||||
@@ -417,7 +417,7 @@ _format_message_dn(char *buf, size_t size, const_efidp dp)
|
||||
.label = "" }
|
||||
};
|
||||
char *label = NULL;
|
||||
- ssize_t (*formatter)(char *buf, size_t size,
|
||||
+ ssize_t (*formatter)(unsigned char *buf, size_t size,
|
||||
const char *dp_type UNUSED,
|
||||
const_efidp dp) = NULL;
|
||||
|
||||
@@ -455,8 +455,8 @@ _format_message_dn(char *buf, size_t size, const_efidp dp)
|
||||
}
|
||||
case EFIDP_MSG_IPv6: {
|
||||
efidp_ipv6_addr const *a = &dp->ipv6_addr;
|
||||
- char *addr0 = NULL;
|
||||
- char *addr1 = NULL;
|
||||
+ unsigned char *addr0 = NULL;
|
||||
+ unsigned char *addr1 = NULL;
|
||||
ssize_t tmpoff = 0;
|
||||
ssize_t sz;
|
||||
|
||||
diff --git a/src/dp.c b/src/dp.c
|
||||
index b6eea74878c..f6a4b2ddafa 100644
|
||||
--- a/src/dp.c
|
||||
+++ b/src/dp.c
|
||||
@@ -298,7 +298,8 @@ efidp_append_instance(const_efidp dp, const_efidp dpi, efidp *out)
|
||||
}
|
||||
|
||||
ssize_t PUBLIC
|
||||
-efidp_format_device_path(char *buf, size_t size, const_efidp dp, ssize_t limit)
|
||||
+efidp_format_device_path(unsigned char *buf, size_t size, const_efidp dp,
|
||||
+ ssize_t limit)
|
||||
{
|
||||
ssize_t off = 0;
|
||||
int first = 1;
|
||||
@@ -402,7 +403,8 @@ efidp_format_device_path(char *buf, size_t size, const_efidp dp, ssize_t limit)
|
||||
}
|
||||
|
||||
ssize_t PUBLIC
|
||||
-efidp_parse_device_node(char *path UNUSED, efidp out UNUSED, size_t size UNUSED)
|
||||
+efidp_parse_device_node(unsigned char *path UNUSED,
|
||||
+ efidp out UNUSED, size_t size UNUSED)
|
||||
{
|
||||
efi_error("not implented");
|
||||
errno = -ENOSYS;
|
||||
@@ -410,7 +412,7 @@ efidp_parse_device_node(char *path UNUSED, efidp out UNUSED, size_t size UNUSED)
|
||||
}
|
||||
|
||||
ssize_t PUBLIC
|
||||
-efidp_parse_device_path(char *path UNUSED, efidp out UNUSED,
|
||||
+efidp_parse_device_path(unsigned char *path UNUSED, efidp out UNUSED,
|
||||
size_t size UNUSED)
|
||||
{
|
||||
efi_error("not implented");
|
||||
diff --git a/src/dp.h b/src/dp.h
|
||||
index 33a29db0d5d..6609b0d827e 100644
|
||||
--- a/src/dp.h
|
||||
+++ b/src/dp.h
|
||||
@@ -88,8 +88,9 @@
|
||||
})
|
||||
|
||||
static inline ssize_t UNUSED
|
||||
-format_hex_helper(char *buf, size_t size, const char *dp_type, char *separator,
|
||||
- int stride, const void * const addr, const size_t len)
|
||||
+format_hex_helper(unsigned char *buf, size_t size, const char *dp_type,
|
||||
+ char *separator, int stride, const void * const addr,
|
||||
+ const size_t len)
|
||||
{
|
||||
ssize_t off = 0;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
@@ -110,7 +111,8 @@ format_hex_helper(char *buf, size_t size, const char *dp_type, char *separator,
|
||||
addr, len)
|
||||
|
||||
static inline ssize_t UNUSED
|
||||
-format_vendor_helper(char *buf, size_t size, char *label, const_efidp dp)
|
||||
+format_vendor_helper(unsigned char *buf, size_t size, char *label,
|
||||
+ const_efidp dp)
|
||||
{
|
||||
ssize_t off = 0;
|
||||
ssize_t bytes = efidp_node_size(dp)
|
||||
@@ -157,11 +159,11 @@ format_vendor_helper(char *buf, size_t size, char *label, const_efidp dp)
|
||||
off; \
|
||||
})
|
||||
|
||||
-extern ssize_t _format_hw_dn(char *buf, size_t size, const_efidp dp);
|
||||
-extern ssize_t _format_acpi_dn(char *buf, size_t size, const_efidp dp);
|
||||
-extern ssize_t _format_message_dn(char *buf, size_t size, const_efidp dp);
|
||||
-extern ssize_t _format_media_dn(char *buf, size_t size, const_efidp dp);
|
||||
-extern ssize_t _format_bios_boot_dn(char *buf, size_t size, const_efidp dp);
|
||||
+extern ssize_t _format_hw_dn(unsigned char *buf, size_t size, const_efidp dp);
|
||||
+extern ssize_t _format_acpi_dn(unsigned char *buf, size_t size, const_efidp dp);
|
||||
+extern ssize_t _format_message_dn(unsigned char *buf, size_t size, const_efidp dp);
|
||||
+extern ssize_t _format_media_dn(unsigned char *buf, size_t size, const_efidp dp);
|
||||
+extern ssize_t _format_bios_boot_dn(unsigned char *buf, size_t size, const_efidp dp);
|
||||
|
||||
#define format_helper_2(name, buf, size, off, dp) ({ \
|
||||
ssize_t _sz; \
|
||||
diff --git a/src/export.c b/src/export.c
|
||||
index 5b11ae883cf..6b78412cce1 100644
|
||||
--- a/src/export.c
|
||||
+++ b/src/export.c
|
||||
@@ -35,7 +35,7 @@
|
||||
struct efi_variable {
|
||||
uint64_t attrs;
|
||||
efi_guid_t *guid;
|
||||
- char *name;
|
||||
+ unsigned char *name;
|
||||
uint8_t *data;
|
||||
size_t data_size;
|
||||
};
|
||||
@@ -149,7 +149,7 @@ efi_variable_import(uint8_t *data, size_t size, efi_variable_t **var_out)
|
||||
ssize_t NONNULL(1) PUBLIC
|
||||
efi_variable_export(efi_variable_t *var, uint8_t *data, size_t size)
|
||||
{
|
||||
- size_t name_len = strlen(var->name);
|
||||
+ size_t name_len = strlen((char *)var->name);
|
||||
|
||||
size_t needed = sizeof (uint32_t) /* magic */
|
||||
+ sizeof (uint32_t) /* version */
|
||||
@@ -233,13 +233,13 @@ efi_variable_free(efi_variable_t *var, int free_data)
|
||||
}
|
||||
|
||||
int NONNULL(1, 2) PUBLIC
|
||||
-efi_variable_set_name(efi_variable_t *var, char *name)
|
||||
+efi_variable_set_name(efi_variable_t *var, unsigned char *name)
|
||||
{
|
||||
var->name = name;
|
||||
return 0;
|
||||
}
|
||||
|
||||
-char PUBLIC NONNULL(1) *
|
||||
+unsigned char PUBLIC NONNULL(1) *
|
||||
efi_variable_get_name(efi_variable_t *var)
|
||||
{
|
||||
if (!var->name) {
|
||||
@@ -329,10 +329,10 @@ efi_variable_realize(efi_variable_t *var)
|
||||
}
|
||||
uint32_t attrs = var->attrs & ATTRS_MASK;
|
||||
if (attrs & EFI_VARIABLE_APPEND_WRITE) {
|
||||
- return efi_append_variable(*var->guid, var->name,
|
||||
+ return efi_append_variable(*var->guid, (char *)var->name,
|
||||
var->data, var->data_size, attrs);
|
||||
}
|
||||
- return efi_set_variable(*var->guid, var->name, var->data,
|
||||
+ return efi_set_variable(*var->guid, (char *)var->name, var->data,
|
||||
var->data_size, attrs, 0600);
|
||||
}
|
||||
|
||||
diff --git a/src/include/efivar/efivar-dp.h b/src/include/efivar/efivar-dp.h
|
||||
index 57453548701..706d25bdebd 100644
|
||||
--- a/src/include/efivar/efivar-dp.h
|
||||
+++ b/src/include/efivar/efivar-dp.h
|
||||
@@ -1240,10 +1240,12 @@ efidp_is_valid(const_efidp dp, ssize_t limit)
|
||||
#endif
|
||||
|
||||
/* and now, printing and parsing */
|
||||
-extern ssize_t efidp_parse_device_node(char *path, efidp out, size_t size);
|
||||
-extern ssize_t efidp_parse_device_path(char *path, efidp out, size_t size);
|
||||
-extern ssize_t efidp_format_device_path(char *buf, size_t size, const_efidp dp,
|
||||
- ssize_t limit);
|
||||
+extern ssize_t efidp_parse_device_node(unsigned char *path,
|
||||
+ efidp out, size_t size);
|
||||
+extern ssize_t efidp_parse_device_path(unsigned char *path,
|
||||
+ efidp out, size_t size);
|
||||
+extern ssize_t efidp_format_device_path(unsigned char *buf, size_t size,
|
||||
+ const_efidp dp, ssize_t limit);
|
||||
extern ssize_t efidp_make_vendor(uint8_t *buf, ssize_t size, uint8_t type,
|
||||
uint8_t subtype, efi_guid_t vendor_guid,
|
||||
void *data, size_t data_size);
|
||||
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
|
||||
index caa4adf056c..729b6fe80f7 100644
|
||||
--- a/src/include/efivar/efivar.h
|
||||
+++ b/src/include/efivar/efivar.h
|
||||
@@ -144,9 +144,9 @@ extern efi_variable_t *efi_variable_alloc(void)
|
||||
__attribute__((__visibility__ ("default")));
|
||||
extern void efi_variable_free(efi_variable_t *var, int free_data);
|
||||
|
||||
-extern int efi_variable_set_name(efi_variable_t *var, char *name)
|
||||
+extern int efi_variable_set_name(efi_variable_t *var, unsigned char *name)
|
||||
__attribute__((__nonnull__ (1, 2)));
|
||||
-extern char *efi_variable_get_name(efi_variable_t *var)
|
||||
+extern unsigned char *efi_variable_get_name(efi_variable_t *var)
|
||||
__attribute__((__visibility__ ("default")))
|
||||
__attribute__((__nonnull__ (1)));
|
||||
|
||||
diff --git a/src/ucs2.h b/src/ucs2.h
|
||||
index 176f9ccac57..478de23b23f 100644
|
||||
--- a/src/ucs2.h
|
||||
+++ b/src/ucs2.h
|
||||
@@ -47,7 +47,7 @@ ucs2size(const void *s, ssize_t limit)
|
||||
}
|
||||
|
||||
static inline size_t UNUSED NONNULL(1)
|
||||
-utf8len(uint8_t *s, ssize_t limit)
|
||||
+utf8len(const unsigned char *s, ssize_t limit)
|
||||
{
|
||||
ssize_t i, j;
|
||||
for (i = 0, j = 0; i < (limit >= 0 ? limit : i+1) && s[i] != '\0';
|
||||
@@ -64,7 +64,7 @@ utf8len(uint8_t *s, ssize_t limit)
|
||||
}
|
||||
|
||||
static inline size_t UNUSED NONNULL(1)
|
||||
-utf8size(uint8_t *s, ssize_t limit)
|
||||
+utf8size(const unsigned char *s, ssize_t limit)
|
||||
{
|
||||
size_t ret = utf8len(s,limit);
|
||||
if (ret < (limit >= 0 ? (size_t)limit : ret+1))
|
||||
@@ -129,7 +129,7 @@ ucs2_to_utf8(const void * const voidchars, ssize_t limit)
|
||||
}
|
||||
|
||||
static inline ssize_t UNUSED NONNULL(4)
|
||||
-utf8_to_ucs2(void *ucs2void, ssize_t size, int terminate, uint8_t *utf8)
|
||||
+utf8_to_ucs2(void *ucs2void, ssize_t size, int terminate, const unsigned char *utf8)
|
||||
{
|
||||
ssize_t req;
|
||||
ssize_t i, j;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,219 +0,0 @@
|
||||
From 6b2b7e8803027b7089a853af0f47b53a7d20e950 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 18 Jun 2019 13:12:39 -0400
|
||||
Subject: [PATCH 35/86] ucs2: document things a little better
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/ucs2.h | 135 +++++++++++++++++++++++++++++++++++++++--------------
|
||||
1 file changed, 100 insertions(+), 35 deletions(-)
|
||||
|
||||
diff --git a/src/ucs2.h b/src/ucs2.h
|
||||
index 478de23b23f..3f8a41d8ccc 100644
|
||||
--- a/src/ucs2.h
|
||||
+++ b/src/ucs2.h
|
||||
@@ -22,11 +22,20 @@
|
||||
#define ev_bits(val, mask, shift) \
|
||||
(((val) & ((mask) << (shift))) >> (shift))
|
||||
|
||||
+/*
|
||||
+ * ucs2len(): Count the number of characters in a UCS-2 string.
|
||||
+ * s: a UCS-2 string
|
||||
+ * limit: the maximum number of uint16_t bytepairs to examine
|
||||
+ *
|
||||
+ * returns the number of characters before NUL is found (i.e., excluding
|
||||
+ * the NUL character). If limit is non-negative, no character index above
|
||||
+ * limit will be accessed, and the maximum return value is limit.
|
||||
+ */
|
||||
static inline size_t UNUSED
|
||||
-ucs2len(const void *vs, ssize_t limit)
|
||||
+ucs2len(const void *s, ssize_t limit)
|
||||
{
|
||||
ssize_t i;
|
||||
- const uint8_t *s8 = vs;
|
||||
+ const uint8_t *s8 = s;
|
||||
|
||||
for (i = 0;
|
||||
i < (limit >= 0 ? limit : i+1) && !(s8[0] == 0 && s8[1] == 0);
|
||||
@@ -35,6 +44,15 @@ ucs2len(const void *vs, ssize_t limit)
|
||||
return i;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * ucs2size(): count the number of bytes in use by a UCS-2 string.
|
||||
+ * s: a UCS-2 string
|
||||
+ * limit: the maximum number of uint16_t bytepairs to examine
|
||||
+ *
|
||||
+ * returns the number of bytes, including NUL, in the UCS-2 string s. If
|
||||
+ * limit is non-negative, no character index above limit will be accessed,
|
||||
+ * and the maximum return value is limit.
|
||||
+ */
|
||||
static inline size_t UNUSED
|
||||
ucs2size(const void *s, ssize_t limit)
|
||||
{
|
||||
@@ -46,6 +64,18 @@ ucs2size(const void *s, ssize_t limit)
|
||||
return rc;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * utf8len(): Count the number of characters in a UTF-8 string.
|
||||
+ * s: a UTF-8 string
|
||||
+ * limit: the maximum number of bytes to examine
|
||||
+ *
|
||||
+ * returns the number of UTF-8 charters before NUL is found (i.e.,
|
||||
+ * excluding the NUL character). If limit is non-negative, no character
|
||||
+ * index above limit will be accessed, and the maximum return value is
|
||||
+ * limit.
|
||||
+ *
|
||||
+ * Caveat: only good up to 3-byte sequences.
|
||||
+ */
|
||||
static inline size_t UNUSED NONNULL(1)
|
||||
utf8len(const unsigned char *s, ssize_t limit)
|
||||
{
|
||||
@@ -63,6 +93,15 @@ utf8len(const unsigned char *s, ssize_t limit)
|
||||
return j;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * utf8size(): count the number of bytes in use by a UTF-8 string.
|
||||
+ * s: a UTF-8 string
|
||||
+ * limit: the maximum number of bytes to examine
|
||||
+ *
|
||||
+ * returns the number of bytes, including NUL, in the UTF-8 string s.
|
||||
+ * If limit is non-negative, no character index above limit will be
|
||||
+ * accessed, and the maximum return value is limit.
|
||||
+ */
|
||||
static inline size_t UNUSED NONNULL(1)
|
||||
utf8size(const unsigned char *s, ssize_t limit)
|
||||
{
|
||||
@@ -72,68 +111,94 @@ utf8size(const unsigned char *s, ssize_t limit)
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * ucs2_to_utf8(): convert UCS-2 to UTF-8
|
||||
+ * s: the UCS-2 string
|
||||
+ * limit: the maximum number of characters to copy from s, including the
|
||||
+ * NUL terminator, or -1 for no limit.
|
||||
+ *
|
||||
+ * returns an allocated string, into which at most limit - 1 characters of
|
||||
+ * UTF-8 are translated from UCS-2. The return value is *always*
|
||||
+ * NUL-terminated.
|
||||
+ */
|
||||
static inline unsigned char * UNUSED
|
||||
-ucs2_to_utf8(const void * const voidchars, ssize_t limit)
|
||||
+ucs2_to_utf8(const void * const s, ssize_t limit)
|
||||
{
|
||||
ssize_t i, j;
|
||||
- unsigned char *ret;
|
||||
- const uint16_t * const chars = voidchars;
|
||||
+ unsigned char *out, *ret;
|
||||
+ const uint16_t * const chars = s;
|
||||
|
||||
if (limit < 0)
|
||||
limit = ucs2len(chars, -1);
|
||||
- ret = malloc(limit * 6 + 1);
|
||||
- if (!ret)
|
||||
+ out = malloc(limit * 6 + 1);
|
||||
+ if (!out)
|
||||
return NULL;
|
||||
- memset(ret, 0, limit * 6 +1);
|
||||
+ memset(out, 0, limit * 6 +1);
|
||||
|
||||
for (i=0, j=0; chars[i] && i < (limit >= 0 ? limit : i+1); i++,j++) {
|
||||
if (chars[i] <= 0x7f) {
|
||||
- ret[j] = chars[i];
|
||||
+ out[j] = chars[i];
|
||||
} else if (chars[i] > 0x7f && chars[i] <= 0x7ff) {
|
||||
- ret[j++] = 0xc0 | ev_bits(chars[i], 0x1f, 6);
|
||||
- ret[j] = 0x80 | ev_bits(chars[i], 0x3f, 0);
|
||||
+ out[j++] = 0xc0 | ev_bits(chars[i], 0x1f, 6);
|
||||
+ out[j] = 0x80 | ev_bits(chars[i], 0x3f, 0);
|
||||
#if 1
|
||||
} else if (chars[i] > 0x7ff) {
|
||||
- ret[j++] = 0xe0 | ev_bits(chars[i], 0xf, 12);
|
||||
- ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6);
|
||||
- ret[j] = 0x80| ev_bits(chars[i], 0x3f, 0);
|
||||
+ out[j++] = 0xe0 | ev_bits(chars[i], 0xf, 12);
|
||||
+ out[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6);
|
||||
+ out[j] = 0x80| ev_bits(chars[i], 0x3f, 0);
|
||||
}
|
||||
#else
|
||||
} else if (chars[i] > 0x7ff && chars[i] < 0x10000) {
|
||||
- ret[j++] = 0xe0 | ev_bits(chars[i], 0xf, 12);
|
||||
- ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6);
|
||||
- ret[j] = 0x80| ev_bits(chars[i], 0x3f, 0);
|
||||
+ out[j++] = 0xe0 | ev_bits(chars[i], 0xf, 12);
|
||||
+ out[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6);
|
||||
+ out[j] = 0x80| ev_bits(chars[i], 0x3f, 0);
|
||||
} else if (chars[i] > 0xffff && chars[i] < 0x200000) {
|
||||
- ret[j++] = 0xf0 | ev_bits(chars[i], 0x7, 18);
|
||||
- ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 12);
|
||||
- ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6);
|
||||
- ret[j] = 0x80| ev_bits(chars[i], 0x3f, 0);
|
||||
+ out[j++] = 0xf0 | ev_bits(chars[i], 0x7, 18);
|
||||
+ out[j++] = 0x80 | ev_bits(chars[i], 0x3f, 12);
|
||||
+ out[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6);
|
||||
+ out[j] = 0x80| ev_bits(chars[i], 0x3f, 0);
|
||||
} else if (chars[i] > 0x1fffff && chars[i] < 0x4000000) {
|
||||
- ret[j++] = 0xf8 | ev_bits(chars[i], 0x3, 24);
|
||||
- ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 18);
|
||||
- ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 12);
|
||||
- ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6);
|
||||
- ret[j] = 0x80 | ev_bits(chars[i], 0x3f, 0);
|
||||
+ out[j++] = 0xf8 | ev_bits(chars[i], 0x3, 24);
|
||||
+ out[j++] = 0x80 | ev_bits(chars[i], 0x3f, 18);
|
||||
+ out[j++] = 0x80 | ev_bits(chars[i], 0x3f, 12);
|
||||
+ out[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6);
|
||||
+ out[j] = 0x80 | ev_bits(chars[i], 0x3f, 0);
|
||||
} else if (chars[i] > 0x3ffffff) {
|
||||
- ret[j++] = 0xfc | ev_bits(chars[i], 0x1, 30);
|
||||
- ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 24);
|
||||
- ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 18);
|
||||
- ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 12);
|
||||
- ret[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6);
|
||||
- ret[j] = 0x80 | ev_bits(chars[i], 0x3f, 0);
|
||||
+ out[j++] = 0xfc | ev_bits(chars[i], 0x1, 30);
|
||||
+ out[j++] = 0x80 | ev_bits(chars[i], 0x3f, 24);
|
||||
+ out[j++] = 0x80 | ev_bits(chars[i], 0x3f, 18);
|
||||
+ out[j++] = 0x80 | ev_bits(chars[i], 0x3f, 12);
|
||||
+ out[j++] = 0x80 | ev_bits(chars[i], 0x3f, 6);
|
||||
+ out[j] = 0x80 | ev_bits(chars[i], 0x3f, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
- ret[j] = '\0';
|
||||
+ out[j++] = '\0';
|
||||
+ ret = realloc(out, j);
|
||||
+ if (!ret) {
|
||||
+ free(out);
|
||||
+ return NULL;
|
||||
+ }
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * utf8_to_ucs2(): convert UTF-8 to UCS-2
|
||||
+ * s: the destination buffer to write to.
|
||||
+ * size: the size of the allocation to write to
|
||||
+ * terminate: whether or not to add a terminator to the string
|
||||
+ * utf8: the utf8 source
|
||||
+ *
|
||||
+ * returns the number of characters written to s, including the NUL
|
||||
+ * terminator if "terminate" is true, or -1 on error. In the case of an
|
||||
+ * error, the buffer will not be modified.
|
||||
+ */
|
||||
static inline ssize_t UNUSED NONNULL(4)
|
||||
-utf8_to_ucs2(void *ucs2void, ssize_t size, int terminate, const unsigned char *utf8)
|
||||
+utf8_to_ucs2(void *s, ssize_t size, bool terminate, const unsigned char *utf8)
|
||||
{
|
||||
ssize_t req;
|
||||
ssize_t i, j;
|
||||
- uint16_t *ucs2 = ucs2void;
|
||||
+ uint16_t *ucs2 = s;
|
||||
uint16_t val16;
|
||||
|
||||
if (!ucs2 && size > 0) {
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,370 +0,0 @@
|
||||
From 3536ccae29c9079eeee99fd363c7dec8a243ab58 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 17 Jun 2019 16:37:29 -0400
|
||||
Subject: [PATCH 36/86] util.h: implement add()/mul()/sub() for more integer
|
||||
types.
|
||||
|
||||
This adds the following:
|
||||
uint_add()
|
||||
uint_mul()
|
||||
uint_sub()
|
||||
long_sub()
|
||||
ulong_sub()
|
||||
|
||||
Additionally it renames ulong_mult() to ulong_mul() and long_mult() to
|
||||
long_mul().
|
||||
|
||||
As before, all of these are available without caring about the types,
|
||||
as if declared:
|
||||
|
||||
bool add(TYPE addend, TYPE addend, TYPE *sum);
|
||||
bool mul(TYPE factor, TYPE factor, TYPE *product);
|
||||
bool sub(TYPE minuend, TYPE subtractahend, TYPE *difference);
|
||||
|
||||
If overflow would occur, the pointer target for the result is not
|
||||
changed and the function returns true, otherwise it returns false.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/efivar.h | 1 +
|
||||
src/safemath.h | 208 +++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
src/util.h | 96 -----------------------
|
||||
3 files changed, 209 insertions(+), 96 deletions(-)
|
||||
create mode 100644 src/safemath.h
|
||||
|
||||
diff --git a/src/efivar.h b/src/efivar.h
|
||||
index 3d4b429631e..646863d14c5 100644
|
||||
--- a/src/efivar.h
|
||||
+++ b/src/efivar.h
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <efivar/efivar.h>
|
||||
|
||||
#include "util.h"
|
||||
+#include "safemath.h"
|
||||
#include "efivar_endian.h"
|
||||
#include "lib.h"
|
||||
#include "guid.h"
|
||||
diff --git a/src/safemath.h b/src/safemath.h
|
||||
new file mode 100644
|
||||
index 00000000000..08dfef7ec0b
|
||||
--- /dev/null
|
||||
+++ b/src/safemath.h
|
||||
@@ -0,0 +1,208 @@
|
||||
+/*
|
||||
+ * safemath.h
|
||||
+ * Copyright 2016-2019 Peter Jones <pjones@redhat.com>
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public License as
|
||||
+ * published by the Free Software Foundation; either version 2.1 of the
|
||||
+ * License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, see
|
||||
+ * <http://www.gnu.org/licenses/>.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#ifndef SAFEMATH_H_
|
||||
+#define SAFEMATH_H_
|
||||
+
|
||||
+/*
|
||||
+ * I'm not actually sure when these appear, but they're present in the
|
||||
+ * version in front of me.
|
||||
+ */
|
||||
+#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
+#if __GNUC__ >= 5 && __GNUC_MINOR__ >= 1
|
||||
+#define int_add(a, b, c) __builtin_add_overflow(a, b, c)
|
||||
+#define uint_add(a, b, c) __builtin_add_overflow(a, b, c)
|
||||
+#define long_add(a, b, c) __builtin_add_overflow(a, b, c)
|
||||
+#define ulong_add(a, b, c) __builtin_add_overflow(a, b, c)
|
||||
+
|
||||
+#define int_mul(a, b, c) __builtin_mul_overflow(a, b, c)
|
||||
+#define uint_mul(a, b, c) __builtin_mul_overflow(a, b, c)
|
||||
+#define long_mul(a, b, c) __builtin_mul_overflow(a, b, c)
|
||||
+#define ulong_mul(a, b, c) __builtin_mul_overflow(a, b, c)
|
||||
+
|
||||
+#define int_sub(a, b, c) __builtin_sub_overflow(a, b, c)
|
||||
+#define uint_sub(a, b, c) __builtin_sub_overflow(a, b, c)
|
||||
+#define long_sub(a, b, c) __builtin_sub_overflow(a, b, c)
|
||||
+#define ulong_sub(a, b, c) __builtin_sub_overflow(a, b, c)
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
+#ifndef int_add
|
||||
+#define int_add(a, b, c) ({ \
|
||||
+ const int _limit = INT_MAX; \
|
||||
+ long int _ret = _limit - (a); \
|
||||
+ _ret = _ret > (b); \
|
||||
+ if (!_ret) \
|
||||
+ *(c) = ((a) + (b)); \
|
||||
+ (bool)_ret; \
|
||||
+ })
|
||||
+#endif
|
||||
+
|
||||
+#ifndef uint_add
|
||||
+#define uint_add(a, b, c) ({ \
|
||||
+ const unsigned int _limit = UINT_MAX; \
|
||||
+ unsigned int _ret = _limit - (a); \
|
||||
+ _ret = _ret > (b); \
|
||||
+ if (!_ret) \
|
||||
+ *(c) = ((a) + (b)); \
|
||||
+ (bool)_ret; \
|
||||
+ })
|
||||
+#endif
|
||||
+
|
||||
+#ifndef long_add
|
||||
+#define long_add(a, b, c) ({ \
|
||||
+ const long _limit = LONG_MAX; \
|
||||
+ long _ret = _limit - (a); \
|
||||
+ _ret = _ret > (b); \
|
||||
+ if (!_ret) \
|
||||
+ *(c) = ((a) + (b)); \
|
||||
+ (bool)_ret; \
|
||||
+ })
|
||||
+#endif
|
||||
+
|
||||
+#ifndef ulong_add
|
||||
+#define ulong_add(a, b, c) ({ \
|
||||
+ const unsigned long _limit = ULONG_MAX; \
|
||||
+ unsigned long _ret = _limit - (a); \
|
||||
+ _ret = _ret > (b); \
|
||||
+ if (!_ret) \
|
||||
+ *(c) = ((a) + (b)); \
|
||||
+ (bool)_ret; \
|
||||
+ })
|
||||
+#endif
|
||||
+
|
||||
+#ifndef int_mul
|
||||
+#define int_mul(a, b, c) ({ \
|
||||
+ int _ret; \
|
||||
+ _ret = __builtin_popcount(a) + __builtin_popcount(b); \
|
||||
+ _ret = _ret < ((sizeof(a) + sizeof(b)) << 4); \
|
||||
+ if (!_ret) \
|
||||
+ *(c) = ((a) * (b)); \
|
||||
+ (bool)_ret; \
|
||||
+ })
|
||||
+#endif
|
||||
+
|
||||
+#ifndef uint_mul
|
||||
+#define uint_mul(a, b, c) int_mul(a, b, c)
|
||||
+#endif
|
||||
+
|
||||
+#ifndef long_mul
|
||||
+#define long_mul(a, b, c) int_mul(a, b, c)
|
||||
+#endif
|
||||
+
|
||||
+#ifndef ulong_mul
|
||||
+#define ulong_mul(a, b, c) int_mul(a, b, c)
|
||||
+#endif
|
||||
+
|
||||
+#ifndef int_sub
|
||||
+#define int_sub(a, b, c) ({ \
|
||||
+ const long _min_limit = INT_MIN; \
|
||||
+ const long _max_limit = INT_MAX; \
|
||||
+ int _ret; \
|
||||
+ _ret = _min_limit + (b); \
|
||||
+ _ret = !(_ret < (a)); \
|
||||
+ if (!_ret) { \
|
||||
+ _ret = _max_limit - (a); \
|
||||
+ _ret = _ret > (b); \
|
||||
+ } \
|
||||
+ if (!_ret) \
|
||||
+ *(c) = ((a) - (b)); \
|
||||
+ (bool)_ret; \
|
||||
+ })
|
||||
+#endif
|
||||
+
|
||||
+#ifndef uint_sub
|
||||
+#define uint_sub(a, b, c) ({ \
|
||||
+ const unsigned int _limit = UINT_MAX; \
|
||||
+ unsigned int _ret = _limit - (a); \
|
||||
+ _ret = _ret > (b); \
|
||||
+ if (!_ret) \
|
||||
+ *(c) = ((a) - (b)); \
|
||||
+ (bool)_ret; \
|
||||
+ })
|
||||
+#endif
|
||||
+
|
||||
+#ifndef long_sub
|
||||
+#define long_sub(a, b, c) ({ \
|
||||
+ const long _min_limit = LONG_MIN; \
|
||||
+ const long _max_limit = LONG_MAX; \
|
||||
+ int _ret; \
|
||||
+ _ret = _min_limit + (b); \
|
||||
+ _ret = !(_ret < (a)); \
|
||||
+ if (!_ret) { \
|
||||
+ _ret = _max_limit - (a); \
|
||||
+ _ret = _ret > (b); \
|
||||
+ } \
|
||||
+ if (!_ret) \
|
||||
+ *(c) = ((a) - (b)); \
|
||||
+ (bool)_ret; \
|
||||
+ })
|
||||
+#endif
|
||||
+
|
||||
+#ifndef ulong_sub
|
||||
+#define ulong_sub(a, b, c) ({ \
|
||||
+ const unsigned long _limit = ULONG_MAX; \
|
||||
+ unsigned long _ret = _limit - (a); \
|
||||
+ _ret = _ret > (b); \
|
||||
+ if (!_ret) \
|
||||
+ *(c) = ((a) - (b)); \
|
||||
+ _ret; \
|
||||
+ })
|
||||
+#endif
|
||||
+
|
||||
+#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
+#if __GNUC__ >= 5 && __GNUC_MINOR__ >= 1
|
||||
+#define add(a, b, c) _Generic((c), \
|
||||
+ int *: int_add(a, b, c), \
|
||||
+ unsigned int *: uint_add(a, b, c), \
|
||||
+ long *: long_add(a, b, c), \
|
||||
+ unsigned long *: ulong_add(a, b, c))
|
||||
+#define sub(a, b, c) _Generic((c), \
|
||||
+ int *: int_sub(a, b, c), \
|
||||
+ unsigned int *: uint_sub(a, b, c), \
|
||||
+ long *: long_sub(a, b, c), \
|
||||
+ unsigned long *: ulong_sub(a, b, c))
|
||||
+#define mul(a, b, c) _Generic((c), \
|
||||
+ int *: int_sub(a, b, c), \
|
||||
+ unsigned int *: uint_mul(a, b, c), \
|
||||
+ long *: long_mul(a, b, c), \
|
||||
+ unsigned long *: ulong_mul(a, b, c))
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
+#ifndef add
|
||||
+#define add(a, b, c) ({ \
|
||||
+ (*(c)) = ((a) + (b)); \
|
||||
+ })
|
||||
+#endif
|
||||
+#ifndef mul
|
||||
+#define mul(a, b, c) ({ \
|
||||
+ (*(c)) = ((a) * (b)); \
|
||||
+ })
|
||||
+#endif
|
||||
+#ifndef sub
|
||||
+#define sub(a, b, c) ({ \
|
||||
+ (*(c)) = ((a) - (b)); \
|
||||
+ })
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
+#endif /* !SAFEMATH_H_ */
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/util.h b/src/util.h
|
||||
index 712abea2d42..3f68d812700 100644
|
||||
--- a/src/util.h
|
||||
+++ b/src/util.h
|
||||
@@ -61,102 +61,6 @@
|
||||
#define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x)))
|
||||
#endif
|
||||
|
||||
-/*
|
||||
- * I'm not actually sure when these appear, but they're present in the
|
||||
- * version in front of me.
|
||||
- */
|
||||
-#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
-#if __GNUC__ >= 5 && __GNUC_MINOR__ >= 1
|
||||
-#define int_add(a, b, c) __builtin_add_overflow(a, b, c)
|
||||
-#define long_add(a, b, c) __builtin_add_overflow(a, b, c)
|
||||
-#define long_mult(a, b, c) __builtin_mul_overflow(a, b, c)
|
||||
-#define ulong_add(a, b, c) __builtin_add_overflow(a, b, c)
|
||||
-#define ulong_mult(a, b, c) __builtin_mul_overflow(a, b, c)
|
||||
-#endif
|
||||
-#endif
|
||||
-#ifndef int_add
|
||||
-#define int_add(a, b, c) ({ \
|
||||
- const int _limit = INT_MAX; \
|
||||
- int _ret; \
|
||||
- _ret = _limit - ((unsigned long long)a) > \
|
||||
- ((unsigned long long)b); \
|
||||
- if (!_ret) \
|
||||
- *(c) = ((a) + (b)); \
|
||||
- _ret; \
|
||||
- })
|
||||
-#endif
|
||||
-#ifndef long_add
|
||||
-#define long_add(a, b, c) ({ \
|
||||
- const long _limit = LONG_MAX; \
|
||||
- int _ret; \
|
||||
- _ret = _limit - ((unsigned long long)a) > \
|
||||
- ((unsigned long long)b); \
|
||||
- if (!_ret) \
|
||||
- *(c) = ((a) + (b)); \
|
||||
- _ret; \
|
||||
- })
|
||||
-#endif
|
||||
-#ifndef long_mult
|
||||
-#define long_mult(a, b, c) ({ \
|
||||
- const long _limit = LONG_MAX; \
|
||||
- int _ret = 1; \
|
||||
- if ((a) == 0 || (b) == 0) \
|
||||
- _ret = 0; \
|
||||
- else \
|
||||
- _ret = _limit / (a) < (b); \
|
||||
- if (!_ret) \
|
||||
- *(c) = ((a) * (b)); \
|
||||
- _ret; \
|
||||
- })
|
||||
-#endif
|
||||
-#ifndef ulong_add
|
||||
-#define ulong_add(a, b, c) ({ \
|
||||
- const unsigned long _limit = ULONG_MAX; \
|
||||
- int _ret; \
|
||||
- _ret = _limit - ((unsigned long long)a) > \
|
||||
- ((unsigned long long)b); \
|
||||
- if (!_ret) \
|
||||
- *(c) = ((a) + (b)); \
|
||||
- _ret; \
|
||||
- })
|
||||
-#endif
|
||||
-#ifndef ulong_mult
|
||||
-#define ulong_mult(a, b, c) ({ \
|
||||
- const unsigned long _limit = ULONG_MAX; \
|
||||
- int _ret = 1; \
|
||||
- if ((a) == 0 || (b) == 0) \
|
||||
- _ret = 0; \
|
||||
- else \
|
||||
- _ret = _limit / (a) < (b); \
|
||||
- if (!_ret) \
|
||||
- *(c) = ((a) * (b)); \
|
||||
- _ret; \
|
||||
- })
|
||||
-#endif
|
||||
-
|
||||
-#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
-#if __GNUC__ >= 5 && __GNUC_MINOR__ >= 1
|
||||
-#define add(a, b, c) _Generic((c), \
|
||||
- int *: int_add(a,b,c), \
|
||||
- long *: long_add(a,b,c), \
|
||||
- unsigned long *: ulong_add(a,b,c))
|
||||
-#define mult(a, b, c) _Generic((c), \
|
||||
- long *: long_mult(a,b,c), \
|
||||
- unsigned long *: ulong_mult(a,b,c))
|
||||
-#endif
|
||||
-#endif
|
||||
-
|
||||
-#ifndef add
|
||||
-#define add(a, b, c) ({ \
|
||||
- (*(c)) = ((a) + (b)); \
|
||||
- })
|
||||
-#endif
|
||||
-#ifndef mult
|
||||
-#define mult(a, b, c) ({ \
|
||||
- (*(c)) = ((a) * (b)); \
|
||||
- })
|
||||
-#endif
|
||||
-
|
||||
static inline int UNUSED
|
||||
read_file(int fd, uint8_t **result, size_t *bufsize)
|
||||
{
|
||||
--
|
||||
2.24.1
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,187 +0,0 @@
|
||||
From 3b4336d1f894ee0ee4180d6b50f4b7febbea3476 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 18 Jun 2019 13:21:45 -0400
|
||||
Subject: [PATCH 38/86] Add some test cases for efivar export/import
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
Makefile | 3 ++
|
||||
tests/.gitignore | 2 +
|
||||
tests/Makefile | 86 ++++++++++++++++++++++++++++++++++++++++++
|
||||
tests/test.0.goal.var | Bin 0 -> 562 bytes
|
||||
tests/test.1.goal.var | Bin 0 -> 574 bytes
|
||||
tests/test.3.goal.var | Bin 0 -> 66 bytes
|
||||
tests/test.4.goal.var | Bin 0 -> 365 bytes
|
||||
7 files changed, 91 insertions(+)
|
||||
create mode 100644 tests/.gitignore
|
||||
create mode 100644 tests/Makefile
|
||||
create mode 100644 tests/test.0.goal.var
|
||||
create mode 100644 tests/test.1.goal.var
|
||||
create mode 100644 tests/test.3.goal.var
|
||||
create mode 100644 tests/test.4.goal.var
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 9c2620cb485..2d134ea9d6f 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -51,6 +51,9 @@ clean :
|
||||
done
|
||||
@rm -vf efivar.spec vgcore.* core.*
|
||||
|
||||
+test : all
|
||||
+ @$(MAKE) -C tests
|
||||
+
|
||||
test-archive: abicheck efivar.spec
|
||||
@rm -rf /tmp/efivar-$(GITTAG) /tmp/efivar-$(GITTAG)-tmp
|
||||
@mkdir -p /tmp/efivar-$(GITTAG)-tmp
|
||||
diff --git a/tests/.gitignore b/tests/.gitignore
|
||||
new file mode 100644
|
||||
index 00000000000..a0149cf75de
|
||||
--- /dev/null
|
||||
+++ b/tests/.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
+!*.var
|
||||
+*.result.*
|
||||
diff --git a/tests/Makefile b/tests/Makefile
|
||||
new file mode 100644
|
||||
index 00000000000..5e0c604e355
|
||||
--- /dev/null
|
||||
+++ b/tests/Makefile
|
||||
@@ -0,0 +1,86 @@
|
||||
+#
|
||||
+# Makefile
|
||||
+# Peter Jones, 2019-06-18 11:10
|
||||
+#
|
||||
+
|
||||
+all: clean test0 test1 test2 test3 test4
|
||||
+
|
||||
+GRUB_PREFIX ?= grub2
|
||||
+TOPDIR ?= ..
|
||||
+EFIVAR ?= ../src/efivar
|
||||
+
|
||||
+clean:
|
||||
+ @rm -f *.result.env *.result.var
|
||||
+
|
||||
+test0:
|
||||
+ @echo testing export to DMPSTORE format
|
||||
+ @$(GRUB_PREFIX)-editenv test.0.result.env create
|
||||
+ @$(GRUB_PREFIX)-editenv test.0.result.env set debug=all,-scripting,-lexer
|
||||
+ @truncate -s 512 test.0.result.env
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n {grub}-GRUB_ENV -f test.0.result.env -D -e test.0.result.var
|
||||
+ @cmp test.0.result.var test.0.goal.var
|
||||
+ @rm test.0.result.*
|
||||
+ @echo passed
|
||||
+
|
||||
+test1:
|
||||
+ @echo testing export to libefivar format
|
||||
+ @$(GRUB_PREFIX)-editenv test.1.result.env create
|
||||
+ @$(GRUB_PREFIX)-editenv test.1.result.env set debug=all,-scripting,-lexer
|
||||
+ @truncate -s 512 test.1.result.env
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n {grub}-GRUB_ENV -f test.1.result.env -e test.1.result.var
|
||||
+ @cmp test.1.result.var test.1.goal.var
|
||||
+ @rm test.1.result.*
|
||||
+ @echo passed
|
||||
+
|
||||
+test2:
|
||||
+ @$(GRUB_PREFIX)-editenv test.2.result.env create
|
||||
+ @$(GRUB_PREFIX)-editenv test.2.result.env set debug=all,-scripting,-lexer
|
||||
+ @truncate -s 512 test.2.result.env
|
||||
+ @echo test importing from DMPSTORE and exporting to DMPSTORE and symbolic guid-name validation
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n {grub}-GRUB_ENV -f test.2.result.env -D -e test.2.0.goal.var
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.2.0.goal.var -e test.2.0.result.var -D
|
||||
+ @cmp test.2.0.result.var test.2.0.result.var
|
||||
+ @rm test.2.0.*
|
||||
+ @echo passed
|
||||
+ @echo test importing from DMPSTORE and exporting to libefivar
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n {grub}-GRUB_ENV -f test.2.result.env -D -e test.2.1.goal.var
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.2.1.goal.var -e test.2.1.result.var
|
||||
+ @cmp test.2.1.result.var test.2.1.result.var
|
||||
+ @rm test.2.1.*
|
||||
+ @echo passed
|
||||
+ @echo test importing from libefivar and exporting to DMPSTORE and mixed-case guid-name validation
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n 91376aff-cBa6-42bE-949d-06fde81128e8-GRUB_ENV -f test.2.result.env -e test.2.2.goal.var
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.2.2.goal.var -e test.2.2.result.var -D
|
||||
+ @cmp test.2.2.result.var test.2.2.result.var
|
||||
+ @rm test.2.2.*
|
||||
+ @echo passed
|
||||
+ @echo test importing from libefivar and exporting to libefivar and guid-name validation
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -n 91376aff-cba6-42be-949d-06fde81128e8-GRUB_ENV -f test.2.result.env -e test.2.3.goal.var
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.2.3.goal.var -e test.2.3.result.var
|
||||
+ @cmp test.2.3.result.var test.2.3.result.var
|
||||
+ @rm test.2.3.* test.2.result.env
|
||||
+ @echo passed
|
||||
+ @echo testing efivar -L
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -L | \
|
||||
+ grep -q '^{91376aff-cba6-42be-949d-06fde81128e8} {grub} efi_guid_grub GRUB$$'
|
||||
+ @echo passed
|
||||
+
|
||||
+test3:
|
||||
+ @echo testing with BootOrder variable dmpstore generated
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.3.goal.var -e test.3.0.result.var
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.3.0.result.var -e test.3.1.result.var -D
|
||||
+ @cmp test.3.goal.var test.3.1.result.var
|
||||
+ @rm test.3.0.result.var test.3.1.result.var
|
||||
+ @echo passed
|
||||
+
|
||||
+test4:
|
||||
+ @echo testing with ConIn variable dmpstore generated
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.4.goal.var -e test.4.0.result.var
|
||||
+ @LD_LIBRARY_PATH=$(TOPDIR)/src $(EFIVAR) -i test.4.0.result.var -e test.4.1.result.var -D
|
||||
+ @cmp test.4.goal.var test.4.1.result.var
|
||||
+ @rm test.4.0.result.var test.4.1.result.var
|
||||
+ @echo passed
|
||||
+
|
||||
+.PHONY: all clean test0
|
||||
+# vim:ft=make
|
||||
+#
|
||||
diff --git a/tests/test.0.goal.var b/tests/test.0.goal.var
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a3bfb4db5ea49c8b26b0b9a0e118da4109969efb
|
||||
GIT binary patch
|
||||
literal 562
|
||||
zcmWe)00Jfk26u)ahEN74hIj^720w-{py2;3^NGt&?{k_mm+kKhL5&yeKrv+n_n=TG
|
||||
z1=qZ?%%c3f+|;}h1*e?+<ZP~#)TGjM+r*q49o^#OqRfJl%)E3R-JH~l)FLkBQ7~LW
|
||||
Jz?Da0CID%RU7r8|
|
||||
|
||||
literal 0
|
||||
HcmV?d00001
|
||||
|
||||
diff --git a/tests/test.1.goal.var b/tests/test.1.goal.var
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7f70c93317d996c429430ec434098c0417370970
|
||||
GIT binary patch
|
||||
literal 574
|
||||
zcmbO(djB&c0|Ns)5QD(~Ec1!WPVaM?GMDY|3qg$+LLfmV1_pPAAcjx|Cx&<iR|Y?Z
|
||||
zFrc8af_qS?lY(nrS!PjwUT$h$iGov3esVTfN@`MRx@}@kj*f0|a#3bMNoHQUj&4qB
|
||||
SMQRb3@+cTCAs{>T<#Pa%YGIxL
|
||||
|
||||
literal 0
|
||||
HcmV?d00001
|
||||
|
||||
diff --git a/tests/test.3.goal.var b/tests/test.3.goal.var
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..972dd553e2043e782b096c9a8ad509c07b73782d
|
||||
GIT binary patch
|
||||
literal 66
|
||||
zcmWe(U|`?_Vkd@tAS_|<XDDJwVMqm%3=E0)pLCy^d`WN>FT;Zw%-TKdKru!JW+2JL
|
||||
Pz{0@Fz{b#`@+=nsxhf5!
|
||||
|
||||
literal 0
|
||||
HcmV?d00001
|
||||
|
||||
diff --git a/tests/test.4.goal.var b/tests/test.4.goal.var
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..549ed5b717dd23843883d3d45f65f4dafeede870
|
||||
GIT binary patch
|
||||
literal 365
|
||||
zcmWe)U|_IjWMFV+$Y;o7@C0HPhE#?!plIU#C*7weUlLr!%kW?Zvvv;~P>hj9gu%OZ
|
||||
z#$~DL@y<Q#J=0$&6*)5V2?J$-U>bztU}R+G5@85-KlotZ&r5={co-(A+aL6;XJjEo
|
||||
zduqb6`;uEO3(nFdOFQ@Rb=42T%Y6FU_2+4DG&_@MdqeKT+KtgYu1oqK#orBlKZQi?
|
||||
e*A|Gbebas3YeDe^+2?h-9rgcN7(R2c?F0Zk6=943
|
||||
|
||||
literal 0
|
||||
HcmV?d00001
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,119 +0,0 @@
|
||||
From 272b216e197b2b3d05da68ef51861545a36dc6d8 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 18 Jun 2019 15:54:58 -0400
|
||||
Subject: [PATCH 39/86] Fix a case clang-analyzer found where we may try to
|
||||
parse a NULL
|
||||
|
||||
I don't think this is something that can *actually* happen - it didn't
|
||||
trigger before save_variable() was added, and the save_variable() path
|
||||
that calls this calls validate_name() immediately prior to this call.
|
||||
validate_name() calls exit() if it's NULL. But that's weird as well,
|
||||
because that's the same pattern all the other users of parse_name() use.
|
||||
|
||||
Anyway, this patch expands validate_name() and moves it into
|
||||
parse_name() so we don't need to call it from everywhere when we're just
|
||||
calling the two in a row anyway.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/efivar.c | 45 ++++++++++++++++++++++++++++++---------------
|
||||
1 file changed, 30 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/src/efivar.c b/src/efivar.c
|
||||
index 885a9af864b..8b1da8888f6 100644
|
||||
--- a/src/efivar.c
|
||||
+++ b/src/efivar.c
|
||||
@@ -95,6 +95,34 @@ show_errors(void)
|
||||
}
|
||||
}
|
||||
|
||||
+static inline void
|
||||
+validate_name(const char *name)
|
||||
+{
|
||||
+ if (name == NULL) {
|
||||
+err:
|
||||
+ warnx("Invalid variable name \"%s\"",
|
||||
+ (name == NULL) ? "(null)" : name);
|
||||
+ show_errors();
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ if (name[0] == '{') {
|
||||
+ const char *next = strchr(name+1, '}');
|
||||
+ if (!next)
|
||||
+ goto err;
|
||||
+ if (next[1] != '-')
|
||||
+ goto err;
|
||||
+ if (next[2] == '\000')
|
||||
+ goto err;
|
||||
+ } else {
|
||||
+ if (strlen(name) < 38)
|
||||
+ goto err;
|
||||
+ if (name[8] != '-' || name[13] != '-' ||
|
||||
+ name[18] != '-' || name[23] != '-' ||
|
||||
+ name[36] != '-')
|
||||
+ goto err;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void
|
||||
list_all_variables(void)
|
||||
{
|
||||
@@ -124,6 +152,8 @@ parse_name(const char *guid_name, char **name, efi_guid_t *guid)
|
||||
|
||||
const char *left, *right;
|
||||
|
||||
+ validate_name(guid_name);
|
||||
+
|
||||
left = strchr(guid_name, '{');
|
||||
right = strchr(guid_name, '}');
|
||||
if (left && right) {
|
||||
@@ -408,16 +438,6 @@ edit_variable(const char *guid_name, void *data, size_t data_size,
|
||||
}
|
||||
}
|
||||
|
||||
-static void
|
||||
-validate_name(const char *name)
|
||||
-{
|
||||
- if (name == NULL) {
|
||||
- fprintf(stderr, "Invalid variable name\n");
|
||||
- show_errors();
|
||||
- exit(1);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
static void
|
||||
prepare_data(const char *filename, uint8_t **data, size_t *data_size)
|
||||
{
|
||||
@@ -588,21 +608,17 @@ int main(int argc, char *argv[])
|
||||
list_all_variables();
|
||||
break;
|
||||
case ACTION_PRINT:
|
||||
- validate_name(guid_name);
|
||||
show_variable(guid_name, SHOW_VERBOSE);
|
||||
break;
|
||||
case ACTION_PRINT_DEC | ACTION_PRINT:
|
||||
- validate_name(guid_name);
|
||||
show_variable(guid_name, SHOW_DECIMAL);
|
||||
break;
|
||||
case ACTION_APPEND | ACTION_PRINT:
|
||||
- validate_name(guid_name);
|
||||
prepare_data(infile, &data, &data_size);
|
||||
edit_variable(guid_name, data, data_size, attributes,
|
||||
EDIT_APPEND);
|
||||
break;
|
||||
case ACTION_WRITE | ACTION_PRINT:
|
||||
- validate_name(guid_name);
|
||||
prepare_data(infile, &data, &data_size);
|
||||
edit_variable(guid_name, data, data_size, attributes,
|
||||
EDIT_WRITE);
|
||||
@@ -653,7 +669,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
efi_variable_free(var, false);
|
||||
} else {
|
||||
- validate_name(guid_name);
|
||||
save_variable(guid_name, outfile, dmpstore);
|
||||
}
|
||||
break;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,37 +0,0 @@
|
||||
From 81346196bb262156fd436c78323d161af61dd6c1 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Torokhov <dtor@chromium.org>
|
||||
Date: Tue, 6 Aug 2019 09:22:25 -0700
|
||||
Subject: [PATCH 40/86] Make sure makeguids helper is compiled for the host's
|
||||
arch
|
||||
|
||||
Currently makeguids is compiled with the same flags/settings as the rest
|
||||
of the package, which does not work in case of cross-compiles when arch
|
||||
of the build host and the target host are different. Let's force
|
||||
compiling for the native host arch to avoid this issue.
|
||||
|
||||
Note that this is not a full cross-compile solution as this does not
|
||||
account for potential differences in host/target compilers (versions,
|
||||
clang vs gcc, etc), but it removes one of the issue with package build
|
||||
aborting due to invalid instruction on the host.
|
||||
|
||||
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
|
||||
---
|
||||
src/Makefile | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index addfaa03c85..3729d2b8f35 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -52,7 +52,7 @@ include/efivar/efivar-guids.h : makeguids guids.txt
|
||||
./makeguids guids.txt guids.bin names.bin \
|
||||
guid-symbols.c include/efivar/efivar-guids.h
|
||||
|
||||
-makeguids : CPPFLAGS+=-DEFIVAR_BUILD_ENVIRONMENT
|
||||
+makeguids : CPPFLAGS+=-DEFIVAR_BUILD_ENVIRONMENT -march=native
|
||||
makeguids : LIBS=dl
|
||||
makeguids : $(MAKEGUIDS_SOURCES)
|
||||
makeguids : CCLD=$(CCLD_FOR_BUILD)
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,49 +0,0 @@
|
||||
From 641a1626543ca3bf0cdd5ea0bd6cc3a82462521a Mon Sep 17 00:00:00 2001
|
||||
From: Pierre Bourdon <delroth@gmail.com>
|
||||
Date: Tue, 13 Aug 2019 05:08:20 +0200
|
||||
Subject: [PATCH 41/86] Makefile: sort $(wildcard) output for reproducibility
|
||||
|
||||
https://reproducible-builds.org/docs/stable-inputs/
|
||||
|
||||
This should fix reproducibility issues noticed on Debian[1] and NixOS[2]
|
||||
|
||||
[1] https://tests.reproducible-builds.org/debian/rb-pkg/buster/i386/diffoscope-results/efivar.html
|
||||
[2] https://r13y.com/diff/b32a9d1c4159dab6aa15e873c0e5fc315ea2bdf545416d21d5b4a29f3c138727-3473019ee52f59732b13253b828bf2eb545384510f30db34413eb6c91dd3d047.html
|
||||
---
|
||||
src/Makefile | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index 3729d2b8f35..253d1f1d56c 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -15,7 +15,7 @@ TARGETS=$(LIBTARGETS) $(BINTARGETS) $(PCTARGETS)
|
||||
STATICTARGETS=$(STATICLIBTARGETS) $(STATICBINTARGETS)
|
||||
|
||||
LIBEFIBOOT_SOURCES = crc32.c creator.c disk.c gpt.c loadopt.c path-helpers.c \
|
||||
- linux.c $(wildcard linux-*.c)
|
||||
+ linux.c $(sort $(wildcard linux-*.c))
|
||||
LIBEFIBOOT_OBJECTS = $(patsubst %.c,%.o,$(LIBEFIBOOT_SOURCES))
|
||||
LIBEFIVAR_SOURCES = crc32.c dp.c dp-acpi.c dp-hw.c dp-media.c dp-message.c \
|
||||
efivarfs.c error.c export.c guid.c guids.S guid-symbols.c \
|
||||
@@ -25,7 +25,7 @@ EFIVAR_SOURCES = efivar.c
|
||||
GENERATED_SOURCES = include/efivar/efivar-guids.h guid-symbols.c
|
||||
MAKEGUIDS_SOURCES = makeguids.c guid.c
|
||||
ALL_SOURCES=$(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES) $(MAKEGUIDS_SOURCES) \
|
||||
- $(wildcard include/efivar/*.h) $(GENERATED_SOURCES) $(EFIVAR_SOURCES)
|
||||
+ $(sort $(wildcard include/efivar/*.h)) $(GENERATED_SOURCES) $(EFIVAR_SOURCES)
|
||||
|
||||
$(call deps-of,$(ALL_SOURCES)) : | deps
|
||||
-include $(call deps-of,$(ALL_SOURCES))
|
||||
@@ -103,7 +103,7 @@ install : all
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(PCDIR)
|
||||
$(foreach x, $(PCTARGETS), $(INSTALL) -m 644 $(x) $(DESTDIR)$(PCDIR) ;)
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/efivar
|
||||
- $(foreach x, $(wildcard $(TOPDIR)/src/include/efivar/*.h), $(INSTALL) -m 644 $(x) $(DESTDIR)$(INCLUDEDIR)/efivar/$(notdir $(x));)
|
||||
+ $(foreach x, $(sort $(wildcard $(TOPDIR)/src/include/efivar/*.h)), $(INSTALL) -m 644 $(x) $(DESTDIR)$(INCLUDEDIR)/efivar/$(notdir $(x));)
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)
|
||||
$(foreach x, $(BINTARGETS), $(INSTALL) -m 755 $(x) $(DESTDIR)$(BINDIR);)
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,22 +0,0 @@
|
||||
From d45b4193d98e7d8416dc7fd33637b9cbfcb4696a Mon Sep 17 00:00:00 2001
|
||||
From: Will Thompson <will@willthompson.co.uk>
|
||||
Date: Thu, 29 Aug 2019 10:39:39 +0100
|
||||
Subject: [PATCH 42/86] guids.txt: correct "sentinal" typo
|
||||
|
||||
---
|
||||
src/guids.txt | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/guids.txt b/src/guids.txt
|
||||
index 2486255b26c..f2f0282b3be 100644
|
||||
--- a/src/guids.txt
|
||||
+++ b/src/guids.txt
|
||||
@@ -1,4 +1,4 @@
|
||||
-00000000-0000-0000-0000-000000000000 zero zeroed sentinal guid
|
||||
+00000000-0000-0000-0000-000000000000 zero zeroed sentinel guid
|
||||
093e0fae-a6c4-4f50-9f1b-d41e2b89c19a sha512 SHA-512
|
||||
0abba7dc-e516-4167-bbf5-4d9d1c739416 fwupdate Linux Firmware Update Tool
|
||||
0b6e5233-a65c-44c9-9407-d9ab83bfc8bd sha224 SHA-224
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,73 +0,0 @@
|
||||
From 1c23cc5e02bfd9be78a9e7f49bf2d8756a7942ce Mon Sep 17 00:00:00 2001
|
||||
From: Robert Bisewski <contact@ibiscybernetics.com>
|
||||
Date: Wed, 25 Sep 2019 15:38:02 -0500
|
||||
Subject: [PATCH 43/86] update manpage for efivar such that it reflects the
|
||||
current options of the efivar util
|
||||
|
||||
---
|
||||
docs/efivar.1 | 30 ++++++++++++++++++++++--------
|
||||
1 file changed, 22 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/docs/efivar.1 b/docs/efivar.1
|
||||
index e4c84bb1fe8..6a3036f5dcd 100644
|
||||
--- a/docs/efivar.1
|
||||
+++ b/docs/efivar.1
|
||||
@@ -1,5 +1,4 @@
|
||||
-.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.45.1.
|
||||
-.TH EFIVAR "1" "June 2014" "efivar 0.10" "User Commands"
|
||||
+.TH EFIVAR "1" "September 2019" "efivar 37" "User Commands"
|
||||
.SH NAME
|
||||
efivar \- Tool to manipulate UEFI variables
|
||||
.SH SYNOPSIS
|
||||
@@ -7,8 +6,8 @@ efivar \- Tool to manipulate UEFI variables
|
||||
[\fI\,OPTION\/\fR...]
|
||||
.SH DESCRIPTION
|
||||
.TP
|
||||
-\fB\-L\fR, \fB\-\-list\-guids\fR
|
||||
-list guids efivar knows about
|
||||
+\fB\-t\fR, \fB\-\-attributes=\fR<attributes>
|
||||
+attributes to use on append
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-list\fR
|
||||
list current variables
|
||||
@@ -16,6 +15,12 @@ list current variables
|
||||
\fB\-p\fR, \fB\-\-print\fR
|
||||
print variable specified by \fB\-\-name\fR
|
||||
.TP
|
||||
+\fB\-D\fR, \fB\-\-dmpstore\fR
|
||||
+use DMPSTORE format when exporting
|
||||
+.TP
|
||||
+\fB\-d\fR, \fB\-\-print\-decimal\fR
|
||||
+print variable in decimal format values specified by \fB\-\-name\fR
|
||||
+.TP
|
||||
\fB\-n\fR, \fB\-\-name=\fR<guid\-name>
|
||||
variable to manipulate, in the form
|
||||
8be4df61\-93ca\-11d2\-aa0d\-00e098032b8c\-Boot0000
|
||||
@@ -23,11 +28,20 @@ variable to manipulate, in the form
|
||||
\fB\-a\fR, \fB\-\-append\fR
|
||||
append to variable specified by \fB\-\-name\fR
|
||||
.TP
|
||||
-\fB\-f\fR, \fB\-\-fromfile=\fR<file>
|
||||
-use data from <file>
|
||||
+\fB\-f\fR, \fB\-\-datafile=\fR<file>
|
||||
+load or save variable contents from <file>
|
||||
.TP
|
||||
-\fB\-t\fR, \fB\-\-attributes=\fR<attributes>
|
||||
-attributes to use on append
|
||||
+\fB\-e\fR, \fB\-\-export=\fR<file>
|
||||
+export variable to <file>
|
||||
+.TP
|
||||
+\fB\-i\fR, \fB\-\-import=\fR<file>
|
||||
+import variable from <file>
|
||||
+.TP
|
||||
+\fB\-L\fR, \fB\-\-list\-guids\fR
|
||||
+show internal guid list
|
||||
+.TP
|
||||
+\fB\-w\fR, \fB\-\-write\fR
|
||||
+write to variable specified by \fB\-\-name\fR
|
||||
.SS "Help options:"
|
||||
.TP
|
||||
\-?, \fB\-\-help\fR
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,53 +0,0 @@
|
||||
From ee045255da9c047aa170cde78a1749723138bb68 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Fri, 11 Oct 2019 10:44:53 -0400
|
||||
Subject: [PATCH 44/86] Fix some 32-bit size_t format specifier errors
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/export.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/export.c b/src/export.c
|
||||
index cfb021525ff..732b4bf30ad 100644
|
||||
--- a/src/export.c
|
||||
+++ b/src/export.c
|
||||
@@ -149,7 +149,7 @@ overflow:
|
||||
}
|
||||
|
||||
crc = efi_crc32(data, size - sizeof(uint32_t));
|
||||
- debug("efi_crc32(%p, %lu) -> 0x%"PRIx32", expected 0x%"PRIx32,
|
||||
+ debug("efi_crc32(%p, %zu) -> 0x%"PRIx32", expected 0x%"PRIx32,
|
||||
data, size - sizeof(uint32_t), crc,
|
||||
*(uint32_t*)(data + size - sizeof(uint32_t)));
|
||||
|
||||
@@ -282,7 +282,7 @@ efi_variable_import_efivar(uint8_t *data, size_t datasz, efi_variable_t **var_ou
|
||||
}
|
||||
|
||||
crc = efi_crc32(data, datasz - sizeof(uint32_t));
|
||||
- debug("efi_crc32(%p, %lu) -> 0x%"PRIx32", expected 0x%"PRIx32,
|
||||
+ debug("efi_crc32(%p, %zu) -> 0x%"PRIx32", expected 0x%"PRIx32,
|
||||
data, datasz - sizeof(uint32_t), crc,
|
||||
*(uint32_t*)(data + datasz - sizeof(uint32_t)));
|
||||
|
||||
@@ -473,7 +473,7 @@ overflow:
|
||||
ptr += var->data_size;
|
||||
|
||||
crc = efi_crc32(data, needed - sizeof(uint32_t));
|
||||
- debug("efi_crc32(%p, %lu) -> 0x%"PRIx32,
|
||||
+ debug("efi_crc32(%p, %zu) -> 0x%"PRIx32,
|
||||
data, needed - sizeof(uint32_t), crc);
|
||||
*(uint32_t *)ptr = crc;
|
||||
|
||||
@@ -611,7 +611,7 @@ overflow:
|
||||
ptr += var->data_size;
|
||||
|
||||
crc = efi_crc32(data, needed - sizeof(uint32_t));
|
||||
- debug("efi_crc32(%p, %lu) -> 0x%"PRIx32,
|
||||
+ debug("efi_crc32(%p, %zu) -> 0x%"PRIx32,
|
||||
data, needed - sizeof(uint32_t), crc);
|
||||
*(uint32_t *)ptr = crc;
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,34 +0,0 @@
|
||||
From f27c2a9e2602b54066e8d557e1cee3aabfd0ec38 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Fri, 11 Oct 2019 10:52:12 -0400
|
||||
Subject: [PATCH 45/86] Make the top level makefile not parallelize.
|
||||
|
||||
Right now if you run:
|
||||
|
||||
make
|
||||
make -j9 clean all
|
||||
|
||||
"clean" and "all" will run in parallel, and "all" will often finish
|
||||
before "clean" will. This is obviously wrong.
|
||||
|
||||
This patch adds .NOTPARALLEL: at the top level, so none of the top-level
|
||||
targets will parallelize, because we really never want that.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
Makefile | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 2d134ea9d6f..61b79a60369 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -83,4 +83,4 @@ archive: abicheck bumpver abidw tag efivar.spec
|
||||
@rm -rf /tmp/efivar-$(GITTAG)
|
||||
@echo "The archive is in efivar-$(GITTAG).tar.bz2"
|
||||
|
||||
-
|
||||
+.NOTPARALLEL:
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,25 +0,0 @@
|
||||
From b33e00224121e81a46c8cac9d685a3317d764236 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Fri, 11 Oct 2019 14:30:42 -0400
|
||||
Subject: [PATCH 46/86] guids: add auto_created_boot_option
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/guids.txt | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/src/guids.txt b/src/guids.txt
|
||||
index f2f0282b3be..95d93c0df74 100644
|
||||
--- a/src/guids.txt
|
||||
+++ b/src/guids.txt
|
||||
@@ -18,6 +18,7 @@
|
||||
721c8b66-426c-4e86-8e99-3457c46ab0b9 lenovo_setup Lenovo Firmware Setup
|
||||
77fa9abd-0359-4d32-bd60-28f4e78f784b microsoft Microsoft
|
||||
7FACC7B6-127F-4E9C-9C5D-080F98994345 lenovo_2 Lenovo
|
||||
+8108ac4e-9f11-4d59-850e-e21a522c59b2 auto_created_boot_option Automatically Created Boot Option
|
||||
826ca512-cf10-4ac9-b187-be01496631bd sha1 SHA-1
|
||||
82988420-7467-4490-9059-feb448dd1963 lenovo_me_config Lenovo ME Configuration Menu
|
||||
8be4df61-93ca-11d2-aa0d-00e098032b8c global EFI Global Variable
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,260 +0,0 @@
|
||||
From 3ba12ff9ba5ebcb55c1e3a8c720e265fa05888b2 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Thu, 10 Oct 2019 13:52:22 -0400
|
||||
Subject: [PATCH 47/86] Move our infrastructure makefiles out of the topdir.
|
||||
|
||||
No sense in leaving all this cluttering up what's usually my working
|
||||
directory...
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
Makefile | 22 ++++++++++----------
|
||||
docs/Makefile | 11 +++++-----
|
||||
src/Android.mk | 2 +-
|
||||
src/Makefile | 11 +++++-----
|
||||
Make.coverity => src/include/coverity.mk | 0
|
||||
Make.defaults => src/include/defaults.mk | 2 +-
|
||||
Make.deprecated => src/include/deprecated.mk | 0
|
||||
src/{Make.deps => include/deps.mk} | 7 +++----
|
||||
gcc.specs => src/include/gcc.specs | 0
|
||||
Make.rules => src/include/rules.mk | 2 +-
|
||||
Make.scan-build => src/include/scan-build.mk | 0
|
||||
Make.version => src/include/version.mk | 0
|
||||
src/test/Makefile | 7 +++----
|
||||
tests/Makefile | 3 +--
|
||||
14 files changed, 31 insertions(+), 36 deletions(-)
|
||||
rename Make.coverity => src/include/coverity.mk (100%)
|
||||
rename Make.defaults => src/include/defaults.mk (97%)
|
||||
rename Make.deprecated => src/include/deprecated.mk (100%)
|
||||
rename src/{Make.deps => include/deps.mk} (65%)
|
||||
rename gcc.specs => src/include/gcc.specs (100%)
|
||||
rename Make.rules => src/include/rules.mk (98%)
|
||||
rename Make.scan-build => src/include/scan-build.mk (100%)
|
||||
rename Make.version => src/include/version.mk (100%)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 61b79a60369..7a4ac8c62e4 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -1,15 +1,15 @@
|
||||
-TOPDIR = $(shell echo $$PWD)
|
||||
+export TOPDIR = $(realpath $(dir $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
-include $(TOPDIR)/Make.deprecated
|
||||
-include $(TOPDIR)/Make.version
|
||||
-include $(TOPDIR)/Make.rules
|
||||
-include $(TOPDIR)/Make.defaults
|
||||
-include $(TOPDIR)/Make.coverity
|
||||
-include $(TOPDIR)/Make.scan-build
|
||||
+include $(TOPDIR)/src/include/deprecated.mk
|
||||
+include $(TOPDIR)/src/include/version.mk
|
||||
+include $(TOPDIR)/src/include/rules.mk
|
||||
+include $(TOPDIR)/src/include/defaults.mk
|
||||
+include $(TOPDIR)/src/include/coverity.mk
|
||||
+include $(TOPDIR)/src/include/scan-build.mk
|
||||
|
||||
SUBDIRS := src docs
|
||||
|
||||
-all : | efivar.spec Make.version
|
||||
+all : | efivar.spec src/include/version.mk
|
||||
all :
|
||||
@set -e ; for x in $(SUBDIRS) ; do \
|
||||
$(MAKE) -C $$x $@ ; \
|
||||
@@ -43,7 +43,7 @@ a :
|
||||
|
||||
GITTAG = $(shell bash -c "echo $$(($(VERSION) + 1))")
|
||||
|
||||
-efivar.spec : | Makefile Make.version
|
||||
+efivar.spec : | Makefile src/include/version.mk
|
||||
|
||||
clean :
|
||||
@set -e ; for x in $(SUBDIRS) ; do \
|
||||
@@ -66,8 +66,8 @@ test-archive: abicheck efivar.spec
|
||||
@echo "The archive is in efivar-$(GITTAG).tar.bz2"
|
||||
|
||||
bumpver :
|
||||
- @echo VERSION=$(GITTAG) > Make.version
|
||||
- @git add Make.version
|
||||
+ @echo VERSION=$(GITTAG) > src/include/version.mk
|
||||
+ @git add src/include/version.mk
|
||||
git commit -m "Bump version to $(GITTAG)" -s
|
||||
|
||||
tag:
|
||||
diff --git a/docs/Makefile b/docs/Makefile
|
||||
index 0f610d9d9a9..2f6fc89b694 100644
|
||||
--- a/docs/Makefile
|
||||
+++ b/docs/Makefile
|
||||
@@ -1,10 +1,9 @@
|
||||
SRCDIR = $(realpath .)
|
||||
-TOPDIR = $(realpath ..)
|
||||
|
||||
-include $(TOPDIR)/Make.deprecated
|
||||
-include $(TOPDIR)/Make.version
|
||||
-include $(TOPDIR)/Make.rules
|
||||
-include $(TOPDIR)/Make.defaults
|
||||
+include $(TOPDIR)/src/include/deprecated.mk
|
||||
+include $(TOPDIR)/src/include/version.mk
|
||||
+include $(TOPDIR)/src/include/rules.mk
|
||||
+include $(TOPDIR)/src/include/defaults.mk
|
||||
|
||||
MAN1TARGETS = efivar.1
|
||||
MAN3TARGETS = efi_append_variable.3 \
|
||||
@@ -51,4 +50,4 @@ install :
|
||||
|
||||
.PHONY: all clean install
|
||||
|
||||
-include $(TOPDIR)/Make.rules
|
||||
+include $(TOPDIR)/src/include/rules.mk
|
||||
diff --git a/src/Android.mk b/src/Android.mk
|
||||
index bf6cfb2e91b..ea6ee3f9432 100644
|
||||
--- a/src/Android.mk
|
||||
+++ b/src/Android.mk
|
||||
@@ -46,7 +46,7 @@ LIBEFIVAR_SOURCES := \
|
||||
lib.c \
|
||||
vars.c
|
||||
|
||||
-include $(LOCAL_PATH)/../Make.version
|
||||
+include $(LOCAL_PATH)/../version.mk
|
||||
|
||||
LOCAL_SRC_FILES := $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES)
|
||||
LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu11 -DLIBEFIVAR_VERSION=$(VERSION)
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index 253d1f1d56c..e5f10d4c7bf 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -1,10 +1,9 @@
|
||||
SRCDIR = $(realpath .)
|
||||
-TOPDIR = $(realpath ..)
|
||||
|
||||
-include $(TOPDIR)/Make.deprecated
|
||||
-include $(TOPDIR)/Make.version
|
||||
-include $(TOPDIR)/Make.rules
|
||||
-include $(TOPDIR)/Make.defaults
|
||||
+include $(TOPDIR)/src/include/deprecated.mk
|
||||
+include $(TOPDIR)/src/include/version.mk
|
||||
+include $(TOPDIR)/src/include/rules.mk
|
||||
+include $(TOPDIR)/src/include/defaults.mk
|
||||
|
||||
LIBTARGETS=libefivar.so libefiboot.so
|
||||
STATICLIBTARGETS=libefivar.a libefiboot.a
|
||||
@@ -84,7 +83,7 @@ libefiboot.so : LIBS=efivar
|
||||
libefiboot.so : MAP=libefiboot.map
|
||||
|
||||
deps : $(ALL_SOURCES)
|
||||
- @$(MAKE) -f $(SRCDIR)/Make.deps deps SOURCES="$(ALL_SOURCES)"
|
||||
+ @$(MAKE) -f $(SRCDIR)/include/deps.mk deps SOURCES="$(ALL_SOURCES)"
|
||||
|
||||
clean :
|
||||
@rm -rfv *~ *.o *.a *.E *.so *.so.* *.pc *.bin .*.d *.map \
|
||||
diff --git a/Make.coverity b/src/include/coverity.mk
|
||||
similarity index 100%
|
||||
rename from Make.coverity
|
||||
rename to src/include/coverity.mk
|
||||
diff --git a/Make.defaults b/src/include/defaults.mk
|
||||
similarity index 97%
|
||||
rename from Make.defaults
|
||||
rename to src/include/defaults.mk
|
||||
index 36e922f5ba7..7290187ceba 100644
|
||||
--- a/Make.defaults
|
||||
+++ b/src/include/defaults.mk
|
||||
@@ -34,7 +34,7 @@ CPPFLAGS += -DLIBEFIVAR_VERSION=$(VERSION)
|
||||
clang_cflags = -D_GNU_SOURCE -std=gnu11 -Wno-address-of-packed-member \
|
||||
-funsigned-char -Wall -Wno-nonnull-compare \
|
||||
-Werror -Wno-error=cpp
|
||||
-gcc_cflags = -specs=$(TOPDIR)/gcc.specs
|
||||
+gcc_cflags = -specs=$(TOPDIR)/src/include/gcc.specs
|
||||
cflags = $(CFLAGS) -I${TOPDIR}/src/include/ \
|
||||
$(if $(findstring clang,$(CC)),$(clang_cflags),) \
|
||||
$(if $(findstring ccc-analyzer,$(CC)),$(clang_cflags),) \
|
||||
diff --git a/Make.deprecated b/src/include/deprecated.mk
|
||||
similarity index 100%
|
||||
rename from Make.deprecated
|
||||
rename to src/include/deprecated.mk
|
||||
diff --git a/src/Make.deps b/src/include/deps.mk
|
||||
similarity index 65%
|
||||
rename from src/Make.deps
|
||||
rename to src/include/deps.mk
|
||||
index c3df9e46559..a797d1bdbf5 100644
|
||||
--- a/src/Make.deps
|
||||
+++ b/src/include/deps.mk
|
||||
@@ -1,11 +1,10 @@
|
||||
SRCDIR = $(realpath .)
|
||||
-TOPDIR = $(realpath ..)
|
||||
|
||||
all : deps
|
||||
|
||||
-include $(TOPDIR)/Make.version
|
||||
-include $(TOPDIR)/Make.rules
|
||||
-include $(TOPDIR)/Make.defaults
|
||||
+include $(TOPDIR)/src/include/version.mk
|
||||
+include $(TOPDIR)/src/include/rules.mk
|
||||
+include $(TOPDIR)/src/include/defaults.mk
|
||||
|
||||
.%.d : %.c
|
||||
$(CC) $(cflags) $(CPPFLAGS) -MM -MG -MF $@ $^
|
||||
diff --git a/gcc.specs b/src/include/gcc.specs
|
||||
similarity index 100%
|
||||
rename from gcc.specs
|
||||
rename to src/include/gcc.specs
|
||||
diff --git a/Make.rules b/src/include/rules.mk
|
||||
similarity index 98%
|
||||
rename from Make.rules
|
||||
rename to src/include/rules.mk
|
||||
index 042585b533c..1783dda573b 100644
|
||||
--- a/Make.rules
|
||||
+++ b/src/include/rules.mk
|
||||
@@ -2,7 +2,7 @@ default : all
|
||||
|
||||
.PHONY: default all clean install test
|
||||
|
||||
-include $(TOPDIR)/Make.version
|
||||
+include $(TOPDIR)/src/include/version.mk
|
||||
|
||||
%.a :
|
||||
$(AR) -cvqs $@ $^
|
||||
diff --git a/Make.scan-build b/src/include/scan-build.mk
|
||||
similarity index 100%
|
||||
rename from Make.scan-build
|
||||
rename to src/include/scan-build.mk
|
||||
diff --git a/Make.version b/src/include/version.mk
|
||||
similarity index 100%
|
||||
rename from Make.version
|
||||
rename to src/include/version.mk
|
||||
diff --git a/src/test/Makefile b/src/test/Makefile
|
||||
index 4c2a18f8426..df16c7a5f3b 100644
|
||||
--- a/src/test/Makefile
|
||||
+++ b/src/test/Makefile
|
||||
@@ -1,8 +1,7 @@
|
||||
SRCDIR = $(realpath .)
|
||||
-TOPDIR = $(realpath $(SRCDIR)/../..)
|
||||
|
||||
-include $(TOPDIR)/Make.defaults
|
||||
-include $(TOPDIR)/Make.version
|
||||
+include $(TOPDIR)/src/include/defaults.mk
|
||||
+include $(TOPDIR)/src/include/version.mk
|
||||
|
||||
ccldflags += -L$(TOPDIR)/src/ -Wl,-rpath=$(TOPDIR)/src/
|
||||
LIBS=efivar
|
||||
@@ -22,4 +21,4 @@ tester :: tester.o
|
||||
|
||||
.PHONY: all clean install test
|
||||
|
||||
-include $(TOPDIR)/Make.rules
|
||||
+include $(TOPDIR)/src/include/rules.mk
|
||||
diff --git a/tests/Makefile b/tests/Makefile
|
||||
index 5e0c604e355..6f233d53fd1 100644
|
||||
--- a/tests/Makefile
|
||||
+++ b/tests/Makefile
|
||||
@@ -6,8 +6,7 @@
|
||||
all: clean test0 test1 test2 test3 test4
|
||||
|
||||
GRUB_PREFIX ?= grub2
|
||||
-TOPDIR ?= ..
|
||||
-EFIVAR ?= ../src/efivar
|
||||
+EFIVAR ?= $(TOPDIR)/src/efivar
|
||||
|
||||
clean:
|
||||
@rm -f *.result.env *.result.var
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,33 +0,0 @@
|
||||
From 53e10dd9a55f6c5db0fec2ea44f176e3f013e233 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Thu, 10 Oct 2019 13:52:46 -0400
|
||||
Subject: [PATCH 48/86] Make CC_FOR_BUILD and CCLD_FOR_BUILD override
|
||||
HOSTCC/HOSTCCLD
|
||||
|
||||
---
|
||||
src/include/deprecated.mk | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
diff --git a/src/include/deprecated.mk b/src/include/deprecated.mk
|
||||
index a31b080dbf6..00abc8c8226 100644
|
||||
--- a/src/include/deprecated.mk
|
||||
+++ b/src/include/deprecated.mk
|
||||
@@ -38,5 +38,15 @@ ifneq ($(origin bindir),undefined)
|
||||
override BINDIR = $(bindir)
|
||||
endif
|
||||
endif
|
||||
+ifneq ($(origin CC_FOR_BUILD),undefined)
|
||||
+ ifeq ($(origin HOSTCC),file)
|
||||
+ override HOSTCC = $(CC_FOR_BUILD)
|
||||
+ endif
|
||||
+endif
|
||||
+ifneq ($(origin CCLD_FOR_BUILD),undefined)
|
||||
+ ifeq ($(origin HOSTCCLD),file)
|
||||
+ override HOSTCCLD = $(CCLD_FOR_BUILD)
|
||||
+ endif
|
||||
+endif
|
||||
|
||||
# vim:ft=make
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,299 +0,0 @@
|
||||
From 998f617cec92d526e1fadb745673ceef63fa1483 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Thu, 10 Oct 2019 15:45:10 -0400
|
||||
Subject: [PATCH 49/86] Rework some makefile bits to make overriding some
|
||||
options simpler.
|
||||
|
||||
This reworks a lot of defaults.mk to make some variables more regularly
|
||||
partially overridden on the command line, making e.g. suppression of
|
||||
-Werror easier when warranted. It also makes having per-compiler
|
||||
versions of each thing simpler.
|
||||
|
||||
The following variables can be overridden, though in some cases only
|
||||
partially:
|
||||
|
||||
name kind of things in it
|
||||
COMPILER gcc
|
||||
CROSS_COMPILE arm-linux-gnu-
|
||||
CC $(CROSS_COMPILE)$(COMPILER)
|
||||
DEBUGINFO -g
|
||||
OPTIMIZE -O2 -flto
|
||||
WARNINGS -Wfoo -Wno-bar
|
||||
ERRORS -Werror -Wno-error=cpp
|
||||
CPPFLAGS -D and -I
|
||||
CFLAGS $(OPTIMIZE) $(DEBUGINFO) $(WARNINGS) $(ERRORS)
|
||||
LDFLAGS linker options (add-only)
|
||||
CCLDFLAGS -Wl, prefixed linker options (add-only and it's
|
||||
normally machine generated from LDFLAGS
|
||||
HOSTCC $(COMPILER)
|
||||
HOST_CPPFLAGS $(CPPFLAGS) (add-only)
|
||||
HOST_CFLAGS $(CFLAGS) (add-only)
|
||||
HOST_CCLDFLAGS $(CCLDFLAGS) (add-only)
|
||||
|
||||
This resolves issue #31
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/Makefile | 5 ++-
|
||||
src/include/defaults.mk | 83 +++++++++++++++++++++++++++--------------
|
||||
src/include/gcc.specs | 11 +-----
|
||||
src/include/rules.mk | 51 +++++++++++++------------
|
||||
src/test/Makefile | 2 +-
|
||||
5 files changed, 87 insertions(+), 65 deletions(-)
|
||||
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index e5f10d4c7bf..1d0e217c89b 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -51,10 +51,11 @@ include/efivar/efivar-guids.h : makeguids guids.txt
|
||||
./makeguids guids.txt guids.bin names.bin \
|
||||
guid-symbols.c include/efivar/efivar-guids.h
|
||||
|
||||
-makeguids : CPPFLAGS+=-DEFIVAR_BUILD_ENVIRONMENT -march=native
|
||||
+makeguids : CPPFLAGS=$(HOST_CPPFLAGS)
|
||||
makeguids : LIBS=dl
|
||||
+makeguids : CCLD=$(HOSTCCLD)
|
||||
+makeguids : CFLAGS=$(HOST_CFLAGS)
|
||||
makeguids : $(MAKEGUIDS_SOURCES)
|
||||
-makeguids : CCLD=$(CCLD_FOR_BUILD)
|
||||
|
||||
guids.o : guids.S | guids.bin names.bin
|
||||
|
||||
diff --git a/src/include/defaults.mk b/src/include/defaults.mk
|
||||
index 7290187ceba..df738feddea 100644
|
||||
--- a/src/include/defaults.mk
|
||||
+++ b/src/include/defaults.mk
|
||||
@@ -8,19 +8,63 @@ BINDIR ?= $(EXEC_PREFIX)/bin
|
||||
PCDIR ?= $(LIBDIR)/pkgconfig
|
||||
DESTDIR ?=
|
||||
|
||||
-INSTALL ?= install
|
||||
CROSS_COMPILE ?=
|
||||
COMPILER ?= gcc
|
||||
-PKG_CONFIG = $(shell if [ -e "$$(env $(CROSS_COMPILE)pkg-config 2>&1)" ]; then echo $(CROSS_COMPILE)pkg-config ; else echo pkg-config ; fi)
|
||||
-CC_FOR_BUILD ?= cc
|
||||
-CC := $(if $(filter default,$(origin CC)),$(CROSS_COMPILE)$(COMPILER),$(CC))
|
||||
-CCLD_FOR_BUILD ?= $(CC_FOR_BUILD)
|
||||
-CCLD := $(if $(filter undefined,$(origin CCLD)),$(CC),$(CCLD))
|
||||
+$(call set-if-undefined,CC,$(CROSS_COMPILE)$(COMPILER))
|
||||
+$(call set-if-undefined,CCLD,$(CC))
|
||||
+$(call set-if-undefined,HOSTCC,$(COMPILER))
|
||||
+$(call set-if-undefined,HOSTCCLD,$(HOSTCC))
|
||||
+
|
||||
OPTIMIZE ?= -O2 -flto
|
||||
-CFLAGS ?= $(OPTIMIZE) -g3
|
||||
-CFLAGS := $(CFLAGS)
|
||||
+DEBUGINFO ?= -g3
|
||||
+WARNINGS_GCC ?= -Wmaybe-uninitialized \
|
||||
+ -Wno-nonnull-compare
|
||||
+WARNINGS_CCC_ANALYZER ?= $(WARNINGS_GCC)
|
||||
+WARNINGS ?= -Wall -Wextra \
|
||||
+ -Wno-address-of-packed-member \
|
||||
+ $(call family,WARNINGS)
|
||||
+ERRORS ?= -Werror -Wno-error=cpp $(call family,ERRORS)
|
||||
+CPPFLAGS ?=
|
||||
+override _CPPFLAGS := $(CPPFLAGS)
|
||||
+override CPPFLAGS = $(_CPPFLAGS) -DLIBEFIVAR_VERSION=$(VERSION) \
|
||||
+ -D_GNU_SOURCE \
|
||||
+ -I$(TOPDIR)/src/include/
|
||||
+CFLAGS ?= $(OPTIMIZE) $(DEBUGINFO) $(WARNINGS) $(ERRORS)
|
||||
+CFLAGS_GCC ?= -specs=$(TOPDIR)/src/include/gcc.specs \
|
||||
+ -fno-merge-constants
|
||||
+override _CFLAGS := $(CFLAGS)
|
||||
+override CFLAGS = $(_CFLAGS) \
|
||||
+ -std=gnu11 \
|
||||
+ -funsigned-char \
|
||||
+ -fvisibility=hidden \
|
||||
+ $(call family,CFLAGS) \
|
||||
+ $(call pkg-config-cflags)
|
||||
+LDFLAGS_CLANG ?= --fatal-warnings -pie -z relro
|
||||
LDFLAGS ?=
|
||||
-LDFLAGS := $(LDFLAGS)
|
||||
+override _LDFLAGS := $(LDFLAGS)
|
||||
+override LDFLAGS = $(_LDFLAGS) \
|
||||
+ --add-needed \
|
||||
+ --build-id \
|
||||
+ --no-allow-shlib-undefined \
|
||||
+ --no-undefined-version \
|
||||
+ -z now \
|
||||
+ -z muldefs \
|
||||
+ $(call family,LDFLAGS)
|
||||
+CCLDFLAGS ?=
|
||||
+override _CCLDFLAGS := $(CCLDFLAGS)
|
||||
+override CCLDFLAGS = $(CFLAGS) -L. $(_CCLDFLAGS) \
|
||||
+ $(call add-prefix,-Wl,$(LDFLAGS)) \
|
||||
+ $(call pkg-config-ccldflags)
|
||||
+HOST_CPPFLAGS ?= $(CPPFLAGS)
|
||||
+override _HOST_CPPFLAGS := $(HOST_CPPFLAGS)
|
||||
+override HOST_CPPFLAGS = $(_HOST_CPPFLAGS) \
|
||||
+ -DEFIVAR_BUILD_ENVIRONMENT -march=native
|
||||
+HOST_CFLAGS ?= $(CFLAGS)
|
||||
+override _HOST_CFLAGS := $(HOST_CFLAGS)
|
||||
+override HOST_CFLAGS = $(_HOST_CFLAGS)
|
||||
+
|
||||
+PKG_CONFIG = $(shell if [ -e "$$(env $(CROSS_COMPILE)pkg-config 2>&1)" ]; then echo $(CROSS_COMPILE)pkg-config ; else echo pkg-config ; fi)
|
||||
+INSTALL ?= install
|
||||
AR := $(CROSS_COMPILE)$(COMPILER)-ar
|
||||
NM := $(CROSS_COMPILE)$(COMPILER)-nm
|
||||
RANLIB := $(CROSS_COMPILE)$(COMPILER)-ranlib
|
||||
@@ -29,26 +73,7 @@ ABIDIFF := abidiff
|
||||
|
||||
PKGS =
|
||||
|
||||
-CPPFLAGS += -DLIBEFIVAR_VERSION=$(VERSION)
|
||||
-
|
||||
-clang_cflags = -D_GNU_SOURCE -std=gnu11 -Wno-address-of-packed-member \
|
||||
- -funsigned-char -Wall -Wno-nonnull-compare \
|
||||
- -Werror -Wno-error=cpp
|
||||
-gcc_cflags = -specs=$(TOPDIR)/src/include/gcc.specs
|
||||
-cflags = $(CFLAGS) -I${TOPDIR}/src/include/ \
|
||||
- $(if $(findstring clang,$(CC)),$(clang_cflags),) \
|
||||
- $(if $(findstring ccc-analyzer,$(CC)),$(clang_cflags),) \
|
||||
- $(if $(findstring gcc,$(CC)),$(gcc_cflags),) \
|
||||
- $(call pkg-config-cflags)
|
||||
-clang_ccldflags =
|
||||
-gcc_ccldflags =
|
||||
-ccldflags = $(cflags) -L. $(CCLDFLAGS) $(LDFLAGS) \
|
||||
- -Wl,-z,muldefs \
|
||||
- $(if $(findstring clang,$(CCLD)),$(clang_ccldflags),) \
|
||||
- $(if $(findstring ccc-analyzer,$(CCLD)),$(clang_ccldflags),) \
|
||||
- $(if $(findstring gcc,$(CCLD)),$(gcc_ccldflags),) \
|
||||
- $(call pkg-config-ldflags)
|
||||
-SOFLAGS=-shared
|
||||
+SOFLAGS=-shared $(call family,SOFLAGS)
|
||||
LDLIBS=$(foreach lib,$(LIBS),-l$(lib)) $(call pkg-config-ldlibs)
|
||||
|
||||
COMMIT_ID=$(shell git log -1 --pretty=%H 2>/dev/null || echo master)
|
||||
diff --git a/src/include/gcc.specs b/src/include/gcc.specs
|
||||
index 9d2b145ee6e..ef28e2bb51a 100644
|
||||
--- a/src/include/gcc.specs
|
||||
+++ b/src/include/gcc.specs
|
||||
@@ -1,14 +1,5 @@
|
||||
-*cpp:
|
||||
-+ -D_GNU_SOURCE
|
||||
-
|
||||
-*efivar_cpp_options:
|
||||
- -Wall -Wno-nonnull-compare -Werror -Wno-error=cpp -std=gnu11 -Wextra -funsigned-char
|
||||
-
|
||||
-*cpp_options:
|
||||
-+ %(efivar_cpp_options)
|
||||
-
|
||||
*cc1_options:
|
||||
-+ %(efivar_cpp_options) -Wmaybe-uninitialized -fno-merge-constants -funsigned-char -fvisibility=hidden %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}} -grecord-gcc-switches
|
||||
++ %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}} -grecord-gcc-switches
|
||||
|
||||
*self_spec:
|
||||
+ %{!shared:%{!static:%{!r:-pie}}} %{static:-Wl,-no-fatal-warnings -Wl,-static -static -Wl,-z,relro,-z,now} -grecord-gcc-switches
|
||||
diff --git a/src/include/rules.mk b/src/include/rules.mk
|
||||
index 1783dda573b..ff0ff4ef61b 100644
|
||||
--- a/src/include/rules.mk
|
||||
+++ b/src/include/rules.mk
|
||||
@@ -4,20 +4,32 @@ default : all
|
||||
|
||||
include $(TOPDIR)/src/include/version.mk
|
||||
|
||||
+comma:= ,
|
||||
+empty:=
|
||||
+space:= $(empty) $(empty)
|
||||
+
|
||||
+set-if-undefined = $(call eval,$(1) := $(if $(filter default undefined,$(origin $(1))),$(2),$($(1))))
|
||||
+add-prefix = $(subst $(space),$(empty),$(1)$(foreach x,$(2),$(comma)$(x)))
|
||||
+
|
||||
+FAMILY_SUFFIXES = $(if $(findstring clang,$(CC)),CLANG,) \
|
||||
+ $(if $(findstring ccc-analyzer,$(CC)),CCC_ANALYZER,) \
|
||||
+ $(if $(findstring gcc,$(CC)),GCC,)
|
||||
+family = $(foreach FAMILY_SUFFIX,$(FAMILY_SUFFIXES),$($(1)_$(FAMILY_SUFFIX)))
|
||||
+
|
||||
%.a :
|
||||
$(AR) -cvqs $@ $^
|
||||
|
||||
% : %.c
|
||||
|
||||
% : %.c
|
||||
- $(CCLD) $(ccldflags) $(CPPFLAGS) -o $@ $^ $(LDLIBS)
|
||||
+ $(CCLD) $(CCLDFLAGS) $(CPPFLAGS) -o $@ $^ $(LDLIBS)
|
||||
|
||||
-%-static : ccldflags+=-static
|
||||
+%-static : CCLDFLAGS+=-static
|
||||
%-static : %.c
|
||||
- $(CCLD) $(ccldflags) $(CPPFLAGS) -o $@ $^ $(LDLIBS)
|
||||
+ $(CCLD) $(CCLDFLAGS) $(CPPFLAGS) -o $@ $^ $(LDLIBS)
|
||||
|
||||
%.so :
|
||||
- $(CCLD) $(ccldflags) $(CPPFLAGS) $(SOFLAGS) \
|
||||
+ $(CCLD) $(CCLDFLAGS) $(CPPFLAGS) $(SOFLAGS) \
|
||||
-Wl,-soname,$@.1 \
|
||||
-Wl,--version-script=$(MAP) \
|
||||
-o $@ $^ $(LDLIBS)
|
||||
@@ -35,22 +47,22 @@ include $(TOPDIR)/src/include/version.mk
|
||||
$<
|
||||
|
||||
%.o : %.c
|
||||
- $(CC) $(cflags) -fPIC $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
|
||||
+ $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
|
||||
|
||||
%.static.o : %.c
|
||||
- $(CC) $(cflags) -fPIE $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
|
||||
+ $(CC) $(CFLAGS) -fPIE $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
|
||||
|
||||
%.o : %.S
|
||||
- $(CC) $(cflags) -fPIC $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
|
||||
+ $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
|
||||
|
||||
%.static.o : %.S
|
||||
- $(CC) $(cflags) -fPIE $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
|
||||
+ $(CC) $(CFLAGS) -fPIE $(CPPFLAGS) -c -o $@ $(filter %.c %.o %.S,$^)
|
||||
|
||||
%.S: %.c
|
||||
- $(CC) $(cflags) $(CPPFLAGS) -S $< -o $@
|
||||
+ $(CC) $(CFLAGS) $(CPPFLAGS) -S $< -o $@
|
||||
|
||||
%.E: %.c
|
||||
- $(CC) $(cflags) $(CPPFLAGS) -E $< -o $@
|
||||
+ $(CC) $(CFLAGS) $(CPPFLAGS) -E $< -o $@
|
||||
|
||||
%.c : %.h
|
||||
|
||||
@@ -71,20 +83,13 @@ endef
|
||||
%.map : %.map.in
|
||||
@$(call substitute-version,$<,$@)
|
||||
|
||||
-pkg-config-cflags = \
|
||||
- $(shell if [ -n "$(PKGS)" ]; then $(PKG_CONFIG) --cflags $(PKGS); fi)
|
||||
-pkg-config-ldflags = \
|
||||
- $(shell if [ -n "$(PKGS)" ]; then $(PKG_CONFIG) --libs-only-L --libs-only-other $(PKGS) ; fi)
|
||||
-pkg-config-ldlibs = \
|
||||
- $(shell if [ -n "$(PKGS)" ]; then $(PKG_CONFIG) --libs-only-l $(PKGS) ; fi)
|
||||
+pkg-config-cflags = $(if $(PKGS),$(shell $(PKG_CONFIG) --cflags $(PKGS)))
|
||||
+pkg-config-ccldflags = $(if $(PKGS),$(shell $(PKG_CONFIG) --libs-only-L --libs-only-other $(PKGS)))
|
||||
+pkg-config-ldlibs = $(if $(PKGS),$(shell $(PKG_CONFIG) --libs-only-l $(PKGS)))
|
||||
|
||||
-define deps-of
|
||||
- $(foreach src,$(filter %.c,$(1)),$(patsubst %.c,.%.d,$(src))) \
|
||||
- $(foreach src,$(filter %.S,$(1)),$(patsubst %.S,.%.d,$(src)))
|
||||
-endef
|
||||
+deps-of = $(foreach src,$(filter %.c,$(1)),$(patsubst %.c,.%.d,$(src))) \
|
||||
+ $(foreach src,$(filter %.S,$(1)),$(patsubst %.S,.%.d,$(src)))
|
||||
|
||||
-define get-config
|
||||
-$(shell git config --local --get "efivar.$(1)")
|
||||
-endef
|
||||
+get-config = $(shell git config --local --get "efivar.$(1)")
|
||||
|
||||
# vim:ft=make
|
||||
diff --git a/src/test/Makefile b/src/test/Makefile
|
||||
index df16c7a5f3b..7a2aa496b48 100644
|
||||
--- a/src/test/Makefile
|
||||
+++ b/src/test/Makefile
|
||||
@@ -3,7 +3,7 @@ SRCDIR = $(realpath .)
|
||||
include $(TOPDIR)/src/include/defaults.mk
|
||||
include $(TOPDIR)/src/include/version.mk
|
||||
|
||||
-ccldflags += -L$(TOPDIR)/src/ -Wl,-rpath=$(TOPDIR)/src/
|
||||
+CCLDFLAGS += -L$(TOPDIR)/src/ -Wl,-rpath=$(TOPDIR)/src/
|
||||
LIBS=efivar
|
||||
|
||||
all : tester
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,55 +0,0 @@
|
||||
From 9b8213eee6889e859edc73569d3076e6a574b197 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 15 Oct 2019 16:49:54 -0400
|
||||
Subject: [PATCH 50/86] Make: add -Wno-missing-field-initializers
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Ritchie wrote in '84:
|
||||
|
||||
If there are fewer initializers in the list than there are members of
|
||||
the aggregate, then the aggregate is padded with 0's.
|
||||
|
||||
c99 §6.7.8 and c11 §6.7.9 each say:
|
||||
|
||||
10 If an object that has automatic storage duration is not initialized
|
||||
explicitly, its value is indeterminate. If an object that has static
|
||||
storage duration is not initialized explicitly, then:
|
||||
— if it has pointer type, it is initialized to a null pointer;
|
||||
— if it has arithmetic type, it is initialized to (positive or
|
||||
unsigned) zero;
|
||||
— if it is an aggregate, every member is initialized (recursively)
|
||||
according to these rules;
|
||||
— if it is a union, the first named member is initialized
|
||||
(recursively) according to these rules.
|
||||
...
|
||||
21 If there are fewer initializers in a brace-enclosed list than there
|
||||
are elements or members of an aggregate, or fewer characters in a
|
||||
string literal used to initialize an array of known size than there
|
||||
are elements in the array, the remainder of the aggregate shall be
|
||||
initialized implicitly the same as objects that have static storage
|
||||
duration.
|
||||
|
||||
This warning is thoroughly pointless.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/include/defaults.mk | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/src/include/defaults.mk b/src/include/defaults.mk
|
||||
index df738feddea..af6a41a9824 100644
|
||||
--- a/src/include/defaults.mk
|
||||
+++ b/src/include/defaults.mk
|
||||
@@ -22,6 +22,7 @@ WARNINGS_GCC ?= -Wmaybe-uninitialized \
|
||||
WARNINGS_CCC_ANALYZER ?= $(WARNINGS_GCC)
|
||||
WARNINGS ?= -Wall -Wextra \
|
||||
-Wno-address-of-packed-member \
|
||||
+ -Wno-missing-field-initializers \
|
||||
$(call family,WARNINGS)
|
||||
ERRORS ?= -Werror -Wno-error=cpp $(call family,ERRORS)
|
||||
CPPFLAGS ?=
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,86 +0,0 @@
|
||||
From fa28009b861dc9fd67ddd1a8f5372d10f3f9c663 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 15 Oct 2019 16:27:39 -0400
|
||||
Subject: [PATCH 51/86] debug(): don't write newlines to memfd
|
||||
|
||||
If we know our log will only be seen by strace, the newlines don't add
|
||||
anything to the strings but clutter.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/error.c | 18 +++++++++++++++---
|
||||
1 file changed, 15 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/error.c b/src/error.c
|
||||
index 083de15e984..b1a56ef629c 100644
|
||||
--- a/src/error.c
|
||||
+++ b/src/error.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2015 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
* Copyright (C) 2000-2001 Dell Computer Corporation <Matt_Domsch@dell.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
+#include <sys/random.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "efiboot.h"
|
||||
@@ -166,6 +167,7 @@ efi_error_pop(void)
|
||||
static int efi_verbose;
|
||||
static FILE *efi_errlog, *efi_dbglog;
|
||||
static int efi_dbglog_fd = -1;
|
||||
+static intptr_t efi_dbglog_cookie;
|
||||
static int log_level;
|
||||
static char efi_dbglog_buf[4096];
|
||||
|
||||
@@ -176,7 +178,7 @@ efi_set_loglevel(int level)
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
-dbglog_write(void *cookie UNUSED, const char *buf, size_t size)
|
||||
+dbglog_write(void *cookie, const char *buf, size_t size)
|
||||
{
|
||||
FILE *log = efi_errlog ? efi_errlog : stderr;
|
||||
ssize_t ret = size;
|
||||
@@ -185,6 +187,11 @@ dbglog_write(void *cookie UNUSED, const char *buf, size_t size)
|
||||
ret = fwrite(buf, 1, size, log);
|
||||
} else if (efi_dbglog_fd >= 0) {
|
||||
lseek(efi_dbglog_fd, 0, SEEK_SET);
|
||||
+ if ((intptr_t)cookie != 0 &&
|
||||
+ (intptr_t)cookie == efi_dbglog_cookie &&
|
||||
+ size > 0 &&
|
||||
+ buf[size-1] == '\n')
|
||||
+ size -= 1;
|
||||
ret = write(efi_dbglog_fd, buf, size);
|
||||
}
|
||||
return ret;
|
||||
@@ -248,6 +255,7 @@ efi_error_fini(void)
|
||||
static void CONSTRUCTOR
|
||||
efi_error_init(void)
|
||||
{
|
||||
+ ssize_t bytes;
|
||||
cookie_io_functions_t io_funcs = {
|
||||
.write = dbglog_write,
|
||||
.seek = dbglog_seek,
|
||||
@@ -258,7 +266,11 @@ efi_error_init(void)
|
||||
if (efi_dbglog_fd == -1)
|
||||
return;
|
||||
|
||||
- efi_dbglog = fopencookie(NULL, "a", io_funcs);
|
||||
+ bytes = getrandom(&efi_dbglog_cookie, sizeof(efi_dbglog_cookie), 0);
|
||||
+ if (bytes < (ssize_t)sizeof(efi_dbglog_cookie))
|
||||
+ efi_dbglog_cookie = 0;
|
||||
+
|
||||
+ efi_dbglog = fopencookie((void *)efi_dbglog_cookie, "a", io_funcs);
|
||||
if (efi_dbglog)
|
||||
setvbuf(efi_dbglog, efi_dbglog_buf, _IOLBF,
|
||||
sizeof(efi_dbglog_buf));
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,402 +0,0 @@
|
||||
From 097ff1033c6ee258b47720d079e27350f7189bbd Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 2 Oct 2019 16:59:14 -0400
|
||||
Subject: [PATCH 52/86] sysfs parsing: add some more debugging output
|
||||
|
||||
This adds highlights under the things we've found when searching, like:
|
||||
|
||||
linux-pci.c:66 parse_pci(): searching for 0000:00:00.0/
|
||||
linux-pci.c:69 parse_pci(): current:'0000:00:1d.4/0000:6e:00.0/nvme/nvme0/nvme0n1' rc:4 pos0:0 pos1:13
|
||||
linux-pci.c:70 parse_pci(): ^^^^^^^^^^^^^
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/linux-acpi-root.c | 5 ++++-
|
||||
src/linux-emmc.c | 3 ++-
|
||||
src/linux-md.c | 3 ++-
|
||||
src/linux-nvme.c | 3 ++-
|
||||
src/linux-pci-root.c | 4 +++-
|
||||
src/linux-pci.c | 3 ++-
|
||||
src/linux-pmem.c | 4 +++-
|
||||
src/linux-sata.c | 6 +++++-
|
||||
src/linux-scsi.c | 10 +++++++++-
|
||||
src/linux-soc-root.c | 4 +++-
|
||||
src/linux-virtblk.c | 3 ++-
|
||||
src/util.h | 35 +++++++++++++++++++++++++++++++++++
|
||||
12 files changed, 72 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/linux-acpi-root.c b/src/linux-acpi-root.c
|
||||
index f48d4be9ac6..8aa5c96cdb9 100644
|
||||
--- a/src/linux-acpi-root.c
|
||||
+++ b/src/linux-acpi-root.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -63,6 +63,7 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED
|
||||
*/
|
||||
rc = sscanf(devpart, "../../devices/platform/%n", &pos);
|
||||
debug("devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
if (rc != 0 || pos < 1)
|
||||
return 0;
|
||||
devpart += pos;
|
||||
@@ -97,6 +98,7 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED
|
||||
|
||||
pos -= 4;
|
||||
debug("devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
acpi_header = strndupa(devpart, pos);
|
||||
if (!acpi_header)
|
||||
return 0;
|
||||
@@ -114,6 +116,7 @@ parse_acpi_root(struct device *dev, const char *current, const char *root UNUSED
|
||||
}
|
||||
debug("devpart:\"%s\" parsed:%04hx:%02hhx pos:%d rc:%d",
|
||||
devpart, pad0, pad1, pos, rc);
|
||||
+ dbgmk(" ", pos);
|
||||
|
||||
devpart += pos;
|
||||
|
||||
diff --git a/src/linux-emmc.c b/src/linux-emmc.c
|
||||
index 8af316a1723..bcd061cb0b2 100644
|
||||
--- a/src/linux-emmc.c
|
||||
+++ b/src/linux-emmc.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -58,6 +58,7 @@ parse_emmc(struct device *dev, const char *current, const char *root UNUSED)
|
||||
&tosser0, &tosser1, &tosser2, &slot_id,
|
||||
&pos0, &tosser3, &partition, &pos1);
|
||||
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
|
||||
+ dbgmk(" ", pos0, pos1);
|
||||
/*
|
||||
* If it isn't of that form, it's not one of our emmc devices.
|
||||
*/
|
||||
diff --git a/src/linux-md.c b/src/linux-md.c
|
||||
index 3d5975d8195..b0809f8295a 100644
|
||||
--- a/src/linux-md.c
|
||||
+++ b/src/linux-md.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -51,6 +51,7 @@ parse_md(struct device *dev, const char *current, const char *root UNUSED)
|
||||
rc = sscanf(current, "md%d/%nmd%dp%d%n",
|
||||
&md, &pos0, &tosser0, &part, &pos1);
|
||||
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
|
||||
+ dbgmk(" ", pos0, pos1);
|
||||
/*
|
||||
* If it isn't of that form, it's not one of our partitioned md devices.
|
||||
*/
|
||||
diff --git a/src/linux-nvme.c b/src/linux-nvme.c
|
||||
index e6e42c7a3fc..530259c38e6 100644
|
||||
--- a/src/linux-nvme.c
|
||||
+++ b/src/linux-nvme.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -62,6 +62,7 @@ parse_nvme(struct device *dev, const char *current, const char *root UNUSED)
|
||||
&tosser0, &ctrl_id, &ns_id, &pos0,
|
||||
&tosser1, &tosser2, &partition, &pos1);
|
||||
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
|
||||
+ dbgmk(" ", pos0, pos1);
|
||||
/*
|
||||
* If it isn't of that form, it's not one of our nvme devices.
|
||||
*/
|
||||
diff --git a/src/linux-pci-root.c b/src/linux-pci-root.c
|
||||
index ede9321395c..def8fdaa526 100644
|
||||
--- a/src/linux-pci-root.c
|
||||
+++ b/src/linux-pci-root.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -57,6 +57,8 @@ parse_pci_root(struct device *dev, const char *current, const char *root UNUSED)
|
||||
* ^d ^p
|
||||
*/
|
||||
rc = sscanf(devpart, "../../devices/pci%hx:%hhx/%n", &root_domain, &root_bus, &pos);
|
||||
+ debug("current:\"%s\" rc:%d pos:%d", devpart, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
/*
|
||||
* If we can't find that, it's not a PCI device.
|
||||
*/
|
||||
diff --git a/src/linux-pci.c b/src/linux-pci.c
|
||||
index 4c715df3d6e..4e7e636c463 100644
|
||||
--- a/src/linux-pci.c
|
||||
+++ b/src/linux-pci.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -68,6 +68,7 @@ parse_pci(struct device *dev, const char *current, const char *root)
|
||||
rc = sscanf(devpart, "%hx:%hhx:%hhx.%hhx/%n",
|
||||
&domain, &bus, &device, &function, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d", devpart, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
if (rc != 4)
|
||||
break;
|
||||
devpart += pos;
|
||||
diff --git a/src/linux-pmem.c b/src/linux-pmem.c
|
||||
index 099ac8aef8c..a11e1644094 100644
|
||||
--- a/src/linux-pmem.c
|
||||
+++ b/src/linux-pmem.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -105,6 +105,8 @@ parse_pmem(struct device *dev, const char *current, const char *root UNUSED)
|
||||
"../../devices/LNXSYSTM:%hhx/LNXSYBUS:%hhx/ACPI%hx:%hhx/ndbus%d/region%d/btt%d.%d/%n",
|
||||
&system, &sysbus, &pnp_id, &acpi_id, &ndbus, ®ion,
|
||||
&btt_region_id, &btt_id, &pos);
|
||||
+ debug("current:\"%s\" rc:%d pos:%d", current, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
if (rc < 8)
|
||||
return 0;
|
||||
|
||||
diff --git a/src/linux-sata.c b/src/linux-sata.c
|
||||
index ee285d84a76..f3a921c2f79 100644
|
||||
--- a/src/linux-sata.c
|
||||
+++ b/src/linux-sata.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -162,6 +162,7 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
|
||||
debug("searching for ata1/");
|
||||
rc = sscanf(current, "ata%"PRIu32"/%n", &print_id, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
/*
|
||||
* If we don't find this one, it isn't an ata device, so return 0 not
|
||||
* error. Later errors mean it is an ata device, but we can't parse
|
||||
@@ -175,6 +176,7 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
|
||||
debug("searching for host0/");
|
||||
rc = sscanf(current, "host%"PRIu32"/%n", &scsi_bus, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
if (rc != 1)
|
||||
return -1;
|
||||
current += pos;
|
||||
@@ -184,6 +186,7 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
|
||||
rc = sscanf(current, "target%"PRIu32":%"PRIu32":%"PRIu64"/%n",
|
||||
&scsi_device, &scsi_target, &scsi_lun, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
if (rc != 3)
|
||||
return -1;
|
||||
current += pos;
|
||||
@@ -193,6 +196,7 @@ parse_sata(struct device *dev, const char *devlink, const char *root UNUSED)
|
||||
rc = sscanf(current, "%"PRIu32":%"PRIu32":%"PRIu32":%"PRIu64"/%n",
|
||||
&tosser0, &tosser1, &tosser2, &tosser3, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
if (rc != 4)
|
||||
return -1;
|
||||
current += pos;
|
||||
diff --git a/src/linux-scsi.c b/src/linux-scsi.c
|
||||
index 90a85836b1c..21fa0b7420c 100644
|
||||
--- a/src/linux-scsi.c
|
||||
+++ b/src/linux-scsi.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -101,6 +101,7 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
debug("searching for host4/");
|
||||
rc = sscanf(current, "host%d/%n", scsi_host, &pos0);
|
||||
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
|
||||
+ dbgmk(" ", pos0);
|
||||
if (rc != 1)
|
||||
return -1;
|
||||
sz += pos0;
|
||||
@@ -118,6 +119,7 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
rc = sscanf(current+sz, "port-%d:%d%n:%d%n", &tosser0,
|
||||
&tosser1, &pos0, &tosser2, &pos1);
|
||||
debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current+sz, rc, pos0, pos1);
|
||||
+ dbgmk(" ", pos0, pos1);
|
||||
if (rc == 2 || rc == 3) {
|
||||
sz += pos0;
|
||||
pos0 = 0;
|
||||
@@ -143,6 +145,7 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
debug("searching for expander-4:0/");
|
||||
rc = sscanf(current+sz, "expander-%d:%d/%n", &tosser0, &tosser1, &pos0);
|
||||
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
|
||||
+ dbgmk(" ", pos0);
|
||||
if (rc == 2) {
|
||||
if (!remote_target_id) {
|
||||
efi_error("Device is PHY is a remote target, but remote_target_id is NULL");
|
||||
@@ -158,6 +161,7 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
debug("searching for port-2:0:2/");
|
||||
rc = sscanf(current+sz, "port-%d:%d:%d/%n", &tosser0, &tosser1, &tosser2, &pos0);
|
||||
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
|
||||
+ dbgmk(" ", pos0);
|
||||
if (rc != 3) {
|
||||
efi_error("Couldn't parse port expander port string");
|
||||
return -1;
|
||||
@@ -182,6 +186,7 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
rc = sscanf(current + sz + pos0, ":%d%n", &tosser2, &pos1);
|
||||
if (rc != 0 && rc != 1)
|
||||
return -1;
|
||||
+ dbgmk(" ", pos0, pos0+pos1);
|
||||
if (remote_port_id && rc == 1)
|
||||
*remote_port_id = tosser2;
|
||||
if (local_port_id && rc == 0)
|
||||
@@ -203,6 +208,7 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
rc = sscanf(current + sz, "target%d:%d:%"PRIu64"/%n", &tosser0, &tosser1,
|
||||
&tosser3, &pos0);
|
||||
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
|
||||
+ dbgmk(" ", pos0);
|
||||
if (rc != 3)
|
||||
return -1;
|
||||
sz += pos0;
|
||||
@@ -215,6 +221,7 @@ parse_scsi_link(const char *current, uint32_t *scsi_host,
|
||||
rc = sscanf(current + sz, "%d:%d:%d:%"PRIu64"/%n",
|
||||
scsi_bus, scsi_device, scsi_target, scsi_lun, &pos0);
|
||||
debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
|
||||
+ dbgmk(" ", pos0);
|
||||
if (rc != 4)
|
||||
return -1;
|
||||
sz += pos0;
|
||||
@@ -242,6 +249,7 @@ parse_scsi(struct device *dev, const char *current, const char *root UNUSED)
|
||||
&dev->scsi_info.scsi_lun,
|
||||
&pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", dev->device, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
if (rc != 4)
|
||||
return 0;
|
||||
|
||||
diff --git a/src/linux-soc-root.c b/src/linux-soc-root.c
|
||||
index 27633d69c97..f4191dbd323 100644
|
||||
--- a/src/linux-soc-root.c
|
||||
+++ b/src/linux-soc-root.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -49,6 +49,8 @@ parse_soc_root(struct device *dev UNUSED, const char *current, const char *root
|
||||
rc = sscanf(devpart, "../../devices/platform/soc/%*[^/]/%n", &pos);
|
||||
if (rc != 0)
|
||||
return 0;
|
||||
+ debug("current:\"%s\" rc:%d pos:%d", current, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
devpart += pos;
|
||||
debug("new position is \"%s\"", devpart);
|
||||
|
||||
diff --git a/src/linux-virtblk.c b/src/linux-virtblk.c
|
||||
index 891c262fe05..e376e0480e6 100644
|
||||
--- a/src/linux-virtblk.c
|
||||
+++ b/src/linux-virtblk.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -56,6 +56,7 @@ parse_virtblk(struct device *dev, const char *current, const char *root UNUSED)
|
||||
debug("searching for virtio0/");
|
||||
rc = sscanf(current, "virtio%x/%n", &tosser, &pos);
|
||||
debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
|
||||
+ dbgmk(" ", pos);
|
||||
/*
|
||||
* If we couldn't find virtioX/ then it isn't a virtio device.
|
||||
*/
|
||||
diff --git a/src/util.h b/src/util.h
|
||||
index 3f68d812700..845989bbfe9 100644
|
||||
--- a/src/util.h
|
||||
+++ b/src/util.h
|
||||
@@ -284,6 +284,40 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
|
||||
u16[1] = __builtin_bswap16(u16[1]);
|
||||
}
|
||||
|
||||
+static inline void UNUSED
|
||||
+debug_markers_(const char * const file, int line,
|
||||
+ const char * const func, int level,
|
||||
+ const char * const prefix, ...)
|
||||
+{
|
||||
+ FILE *logfile;
|
||||
+ va_list ap;
|
||||
+ int pos;
|
||||
+ int n = 0;
|
||||
+ bool on = false;
|
||||
+
|
||||
+ va_start(ap, prefix);
|
||||
+ for (n = 0, pos = va_arg(ap, int); pos >= 0; pos = va_arg(ap, int), n++)
|
||||
+ ;
|
||||
+ va_end(ap);
|
||||
+ if (n < 2)
|
||||
+ return;
|
||||
+ n = 0;
|
||||
+
|
||||
+ efi_set_loglevel(level);
|
||||
+ logfile = efi_get_logfile();
|
||||
+ fprintf(logfile, "%s:%d %s(): %s", file, line, func, prefix ? prefix : "");
|
||||
+ va_start(ap, prefix);
|
||||
+ while ((pos = va_arg(ap, int)) >= 0) {
|
||||
+ for (; n <= pos; n++) {
|
||||
+ if (n == pos)
|
||||
+ on = !on;
|
||||
+ fprintf(logfile, "%c", on ? '^' : ' ');
|
||||
+ }
|
||||
+ }
|
||||
+ fprintf(logfile, "\n");
|
||||
+ va_end(ap);
|
||||
+}
|
||||
+
|
||||
#define log_(file, line, func, level, fmt, args...) \
|
||||
({ \
|
||||
efi_set_loglevel(level); \
|
||||
@@ -312,6 +346,7 @@ swizzle_guid_to_uuid(efi_guid_t *guid)
|
||||
})
|
||||
#define log_hex(level, buf, size) log_hex_(__FILE__, __LINE__, __func__, level, buf, size)
|
||||
#define debug_hex(buf, size) log_hex(LOG_DEBUG, buf, size)
|
||||
+#define dbgmk(prefix, args...) debug_markers_(__FILE__, __LINE__, __func__, LOG_DEBUG, prefix, ## args, -1)
|
||||
|
||||
#endif /* EFIVAR_UTIL_H */
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,25 +0,0 @@
|
||||
From 95e98e10cbabad4bfd99787dddb12afad1cb6331 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 16 Oct 2019 10:01:00 -0400
|
||||
Subject: [PATCH 53/86] gitignore: ignore *.strace
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
.gitignore | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
index 947d88eec42..f61b0bcb340 100644
|
||||
--- a/.gitignore
|
||||
+++ b/.gitignore
|
||||
@@ -14,6 +14,7 @@
|
||||
*.so
|
||||
*.so.*
|
||||
*.spec
|
||||
+*.strace
|
||||
*.tar.*
|
||||
*.var
|
||||
core.*
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,71 +0,0 @@
|
||||
From 22bc0866e941cbfe57de6522db51e9cf2c6b3ff1 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 2 Oct 2019 17:01:00 -0400
|
||||
Subject: [PATCH 54/86] Fix the error path in set_disk_and_part_name()
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/linux.c | 12 ++++++++++--
|
||||
1 file changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/linux.c b/src/linux.c
|
||||
index 45b1ee2d96f..1f37933f546 100644
|
||||
--- a/src/linux.c
|
||||
+++ b/src/linux.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2015 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
* Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@@ -169,6 +169,8 @@ set_disk_name(struct device *dev, const char * const fmt, ...)
|
||||
int HIDDEN
|
||||
set_disk_and_part_name(struct device *dev)
|
||||
{
|
||||
+ int rc = -1;
|
||||
+
|
||||
/*
|
||||
* results are like such:
|
||||
* maj:min -> ../../devices/pci$PCI_STUFF/$BLOCKDEV_STUFF/block/$DISK/$PART
|
||||
@@ -200,6 +202,7 @@ set_disk_and_part_name(struct device *dev)
|
||||
set_disk_name(dev, "%s", penultimate);
|
||||
set_part_name(dev, "%s", ultimate);
|
||||
debug("disk:%s part:%s", penultimate, ultimate);
|
||||
+ rc = 0;
|
||||
} else if (ultimate && approximate && !strcmp(approximate, "nvme")) {
|
||||
/*
|
||||
* 259:0 -> ../../devices/pci0000:00/0000:00:1d.0/0000:05:00.0/nvme/nvme0/nvme0n1
|
||||
@@ -207,6 +210,7 @@ set_disk_and_part_name(struct device *dev)
|
||||
set_disk_name(dev, "%s", ultimate);
|
||||
set_part_name(dev, "%sp%d", ultimate, dev->part);
|
||||
debug("disk:%s part:%sp%d", ultimate, ultimate, dev->part);
|
||||
+ rc = 0;
|
||||
} else if (ultimate && penultimate && !strcmp(penultimate, "block")) {
|
||||
/*
|
||||
* 253:0 -> ../../devices/virtual/block/dm-0 (... I guess)
|
||||
@@ -220,15 +224,19 @@ set_disk_and_part_name(struct device *dev)
|
||||
set_disk_name(dev, "%s", ultimate);
|
||||
set_part_name(dev, "%s%d", ultimate, dev->part);
|
||||
debug("disk:%s part:%s%d", ultimate, ultimate, dev->part);
|
||||
+ rc = 0;
|
||||
} else if (ultimate && approximate && !strcmp(approximate, "mtd")) {
|
||||
/*
|
||||
* 31:0 -> ../../devices/platform/1e000000.palmbus/1e000b00.spi/spi_master/spi32766/spi32766.0/mtd/mtd0/mtdblock0
|
||||
*/
|
||||
set_disk_name(dev, "%s", ultimate);
|
||||
debug("disk:%s", ultimate);
|
||||
+ rc = 0;
|
||||
}
|
||||
|
||||
- return 0;
|
||||
+ if (rc < 0)
|
||||
+ efi_error("Could not parse disk name:\"%s\"", dev->link);
|
||||
+ return rc;
|
||||
}
|
||||
|
||||
static struct dev_probe *dev_probes[] = {
|
||||
--
|
||||
2.24.1
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,306 +0,0 @@
|
||||
From d153ca75d0323eb125e525ebdf4ac5c982941d15 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 15 Oct 2019 16:26:30 -0400
|
||||
Subject: [PATCH 56/86] Improve consistency of debug prints
|
||||
|
||||
This changes debug prints in a couple of ways:
|
||||
- always calls the path we're parsing "current" in the output
|
||||
- always use ' not " for quoting in the debug output, so tools that
|
||||
escape strings won't change the lenghts
|
||||
- everything that parses "current" has a debug print after each parse
|
||||
attempt and before returning.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/dp-acpi.c | 8 ++++----
|
||||
src/linux-acpi-root.c | 4 ++--
|
||||
src/linux-acpi.c | 6 +++---
|
||||
src/linux-ata.c | 11 +++++++----
|
||||
src/linux-i2o.c | 10 +++++-----
|
||||
src/linux-md.c | 4 ++--
|
||||
src/linux-pci-root.c | 2 +-
|
||||
src/linux-pmem.c | 5 +++--
|
||||
src/linux.c | 27 +++++++++++++++++----------
|
||||
9 files changed, 44 insertions(+), 33 deletions(-)
|
||||
|
||||
diff --git a/src/dp-acpi.c b/src/dp-acpi.c
|
||||
index 02ec70eec7a..ae4102cdf56 100644
|
||||
--- a/src/dp-acpi.c
|
||||
+++ b/src/dp-acpi.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefivar - library for the manipulation of EFI variables
|
||||
- * Copyright 2012-2015 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -52,9 +52,9 @@ _format_acpi_hid_ex(unsigned char *buf, size_t size,
|
||||
{
|
||||
ssize_t off = 0;
|
||||
|
||||
- debug("hid:0x%08x hidstr:\"%s\"", dp->acpi_hid_ex.hid, hidstr);
|
||||
- debug("cid:0x%08x cidstr:\"%s\"", dp->acpi_hid_ex.cid, cidstr);
|
||||
- debug("uid:0x%08x uidstr:\"%s\"", dp->acpi_hid_ex.uid, uidstr);
|
||||
+ debug("hid:0x%08x hidstr:'%s'", dp->acpi_hid_ex.hid, hidstr);
|
||||
+ debug("cid:0x%08x cidstr:'%s'", dp->acpi_hid_ex.cid, cidstr);
|
||||
+ debug("uid:0x%08x uidstr:'%s'", dp->acpi_hid_ex.uid, uidstr);
|
||||
|
||||
if (!hidstr && !cidstr && (uidstr || dp->acpi_hid_ex.uid)) {
|
||||
format(buf, size, off, "AcpiExp",
|
||||
diff --git a/src/linux-acpi-root.c b/src/linux-acpi-root.c
|
||||
index 9154c950bb1..86693c81878 100644
|
||||
--- a/src/linux-acpi-root.c
|
||||
+++ b/src/linux-acpi-root.c
|
||||
@@ -144,7 +144,7 @@ parse_acpi_root(struct device *dev, const char *path, const char *root UNUSED)
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
- debug("Parsed HID:0x%08x UID:0x%"PRIx64" uidstr:\"%s\" path:\"%s\"",
|
||||
+ debug("Parsed HID:0x%08x UID:0x%"PRIx64" uidstr:'%s' path:'%s'",
|
||||
dev->acpi_root.acpi_hid, dev->acpi_root.acpi_uid,
|
||||
dev->acpi_root.acpi_uid_str,
|
||||
dev->acpi_root.acpi_cid_str);
|
||||
@@ -162,7 +162,7 @@ dp_create_acpi_root(struct device *dev,
|
||||
debug("entry buf:%p size:%zd off:%zd", buf, size, off);
|
||||
|
||||
if (dev->acpi_root.acpi_uid_str || dev->acpi_root.acpi_cid_str) {
|
||||
- debug("creating acpi_hid_ex dp hid:0x%08x uid:0x%"PRIx64" uidstr:\"%s\" cidstr:\"%s\"",
|
||||
+ debug("creating acpi_hid_ex dp hid:0x%08x uid:0x%"PRIx64" uidstr:'%s' cidstr:'%s'",
|
||||
dev->acpi_root.acpi_hid, dev->acpi_root.acpi_uid,
|
||||
dev->acpi_root.acpi_uid_str, dev->acpi_root.acpi_cid_str);
|
||||
new = efidp_make_acpi_hid_ex(buf + off, size ? size - off : 0,
|
||||
diff --git a/src/linux-acpi.c b/src/linux-acpi.c
|
||||
index 919f4654ae3..534573f32c1 100644
|
||||
--- a/src/linux-acpi.c
|
||||
+++ b/src/linux-acpi.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -54,7 +54,7 @@ parse_acpi_hid_uid(struct device *dev, const char *fmt, ...)
|
||||
if (l > 1) {
|
||||
fbuf[l-1] = 0;
|
||||
dev->acpi_root.acpi_cid_str = strdup(fbuf);
|
||||
- debug("Setting ACPI root path to \"%s\"", fbuf);
|
||||
+ debug("Setting ACPI root path to '%s'", fbuf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ hid_err:
|
||||
}
|
||||
}
|
||||
}
|
||||
- debug("acpi root UID:0x%"PRIx64" uidstr:\"%s\"",
|
||||
+ debug("acpi root UID:0x%"PRIx64" uidstr:'%s'",
|
||||
dev->acpi_root.acpi_uid, dev->acpi_root.acpi_uid_str);
|
||||
|
||||
errno = 0;
|
||||
diff --git a/src/linux-ata.c b/src/linux-ata.c
|
||||
index a05a2feb8b9..a51ed5abbe0 100644
|
||||
--- a/src/linux-ata.c
|
||||
+++ b/src/linux-ata.c
|
||||
@@ -60,6 +60,7 @@ is_pata(struct device *dev)
|
||||
static ssize_t
|
||||
parse_ata(struct device *dev, const char *path, const char *root UNUSED)
|
||||
{
|
||||
+ const char *current = path;
|
||||
uint32_t scsi_host, scsi_bus, scsi_device, scsi_target;
|
||||
uint64_t scsi_lun;
|
||||
int pos;
|
||||
@@ -118,6 +119,7 @@ parse_ata(struct device *dev, const char *path, const char *root UNUSED)
|
||||
NULL, NULL, NULL);
|
||||
if (pos < 0)
|
||||
return -1;
|
||||
+ current += pos;
|
||||
|
||||
dev->ata_info.scsi_host = scsi_host;
|
||||
dev->ata_info.scsi_bus = scsi_bus;
|
||||
@@ -125,10 +127,11 @@ parse_ata(struct device *dev, const char *path, const char *root UNUSED)
|
||||
dev->ata_info.scsi_target = scsi_target;
|
||||
dev->ata_info.scsi_lun = scsi_lun;
|
||||
|
||||
- char *block = strstr(path, "/block/");
|
||||
- if (!block)
|
||||
- return -1;
|
||||
- return block + 1 - path;
|
||||
+ char *block = strstr(current, "/block/");
|
||||
+ if (block)
|
||||
+ current += block + 1 - current;
|
||||
+ debug("current:'%s' sz:%zd", current, current - path);
|
||||
+ return current - path;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
diff --git a/src/linux-i2o.c b/src/linux-i2o.c
|
||||
index ebd92aeeb53..b53f4516309 100644
|
||||
--- a/src/linux-i2o.c
|
||||
+++ b/src/linux-i2o.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2018 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License as
|
||||
@@ -33,7 +33,7 @@
|
||||
* ... probably doesn't work.
|
||||
*/
|
||||
static ssize_t
|
||||
-parse_i2o(struct device *dev, const char *current UNUSED, const char *root UNUSED)
|
||||
+parse_i2o(struct device *dev, const char *current, const char *root UNUSED)
|
||||
{
|
||||
debug("entry");
|
||||
/* I2O disks can have up to 16 partitions, or 4 bits worth. */
|
||||
@@ -47,9 +47,9 @@ parse_i2o(struct device *dev, const char *current UNUSED, const char *root UNUSE
|
||||
}
|
||||
|
||||
char *block = strstr(current, "/block/");
|
||||
- if (!block)
|
||||
- return -1;
|
||||
- return block + 1 - current;
|
||||
+ ssize_t sz = block ? block + 1 - current : -1;
|
||||
+ debug("current:'%s' sz:%zd", current, sz);
|
||||
+ return sz;
|
||||
}
|
||||
|
||||
enum interface_type i2o_iftypes[] = { i2o, unknown };
|
||||
diff --git a/src/linux-md.c b/src/linux-md.c
|
||||
index b0809f8295a..2aacb87469a 100644
|
||||
--- a/src/linux-md.c
|
||||
+++ b/src/linux-md.c
|
||||
@@ -50,7 +50,7 @@ parse_md(struct device *dev, const char *current, const char *root UNUSED)
|
||||
debug("searching for mdM/mdMpN");
|
||||
rc = sscanf(current, "md%d/%nmd%dp%d%n",
|
||||
&md, &pos0, &tosser0, &part, &pos1);
|
||||
- debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
|
||||
+ debug("current:'%s' rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
|
||||
dbgmk(" ", pos0, pos1);
|
||||
/*
|
||||
* If it isn't of that form, it's not one of our partitioned md devices.
|
||||
@@ -63,10 +63,10 @@ parse_md(struct device *dev, const char *current, const char *root UNUSED)
|
||||
if (dev->part == -1)
|
||||
dev->part = part;
|
||||
|
||||
+ debug("current:'%s' sz:%d\n", current, pos1);
|
||||
return pos1;
|
||||
}
|
||||
|
||||
-
|
||||
static char *
|
||||
make_part_name(struct device *dev)
|
||||
{
|
||||
diff --git a/src/linux-pci-root.c b/src/linux-pci-root.c
|
||||
index 8cd3849b1db..84189ffbaca 100644
|
||||
--- a/src/linux-pci-root.c
|
||||
+++ b/src/linux-pci-root.c
|
||||
@@ -87,7 +87,7 @@ dp_create_pci_root(struct device *dev UNUSED,
|
||||
debug("entry buf:%p size:%zd off:%zd", buf, size, off);
|
||||
debug("returning 0");
|
||||
if (dev->acpi_root.acpi_uid_str) {
|
||||
- debug("creating acpi_hid_ex dp hid:0x%08x uid:\"%s\"",
|
||||
+ debug("creating acpi_hid_ex dp hid:0x%08x uid:'%s'",
|
||||
dev->acpi_root.acpi_hid,
|
||||
dev->acpi_root.acpi_uid_str);
|
||||
new = efidp_make_acpi_hid_ex(buf + off, size ? size - off : 0,
|
||||
diff --git a/src/linux-pmem.c b/src/linux-pmem.c
|
||||
index e5de3264d03..b9f83e12e7b 100644
|
||||
--- a/src/linux-pmem.c
|
||||
+++ b/src/linux-pmem.c
|
||||
@@ -103,11 +103,12 @@ parse_pmem(struct device *dev, const char *path, const char *root UNUSED)
|
||||
*
|
||||
* 259:0 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0012:00/ndbus0/region12/btt12.1/block/pmem12s
|
||||
*/
|
||||
+ pos0 = pos1 = -1;
|
||||
rc = sscanf(current,
|
||||
"../../devices/%nLNXSYSTM:%hhx/LNXSYBUS:%hhx/ACPI%hx:%hhx/ndbus%d/region%d/btt%d.%d/%n",
|
||||
&pos0, &system, &sysbus, &pnp_id, &acpi_id, &ndbus,
|
||||
®ion, &btt_region_id, &btt_id, &pos1);
|
||||
- debug("current:\"%s\" rc:%d pos0:%d pos1:%d", current, rc, pos0, pos1);
|
||||
+ debug("current:'%s' rc:%d pos0:%d pos1:%d", current, rc, pos0, pos1);
|
||||
dbgmk(" ", pos0, pos1);
|
||||
if (rc < 8)
|
||||
return 0;
|
||||
@@ -126,7 +127,7 @@ parse_pmem(struct device *dev, const char *path, const char *root UNUSED)
|
||||
return -1;
|
||||
|
||||
filebuf = NULL;
|
||||
- debug("nvdimm namespace is \"%s\"", namespace);
|
||||
+ debug("nvdimm namespace is '%s'", namespace);
|
||||
rc = read_sysfs_file(&filebuf, "bus/nd/devices/%s/uuid", namespace);
|
||||
free(namespace);
|
||||
if (rc < 0 || filebuf == NULL)
|
||||
diff --git a/src/linux.c b/src/linux.c
|
||||
index 1f37933f546..1051894e7bc 100644
|
||||
--- a/src/linux.c
|
||||
+++ b/src/linux.c
|
||||
@@ -184,10 +184,10 @@ set_disk_and_part_name(struct device *dev)
|
||||
errno = 0;
|
||||
debug("dev->disk_name:%p dev->part_name:%p", dev->disk_name, dev->part_name);
|
||||
debug("dev->part:%d", dev->part);
|
||||
- debug("ultimate:\"%s\"", ultimate ? : "");
|
||||
- debug("penultimate:\"%s\"", penultimate ? : "");
|
||||
- debug("approximate:\"%s\"", approximate ? : "");
|
||||
- debug("proximate:\"%s\"", proximate ? : "");
|
||||
+ debug("ultimate:'%s'", ultimate ? : "");
|
||||
+ debug("penultimate:'%s'", penultimate ? : "");
|
||||
+ debug("approximate:'%s'", approximate ? : "");
|
||||
+ debug("proximate:'%s'", proximate ? : "");
|
||||
|
||||
if (ultimate && penultimate &&
|
||||
((proximate && !strcmp(proximate, "nvme")) ||
|
||||
@@ -463,7 +463,11 @@ struct device HIDDEN
|
||||
efi_error("parsing %s failed", probe->name);
|
||||
goto err;
|
||||
} else if (pos > 0) {
|
||||
- debug("%s matched %s", probe->name, current);
|
||||
+ char match[pos+1];
|
||||
+
|
||||
+ strncpy(match, current, pos);
|
||||
+ match[pos] = '\0';
|
||||
+ debug("%s matched '%s'", probe->name, match);
|
||||
dev->flags |= probe->flags;
|
||||
|
||||
if (probe->flags & DEV_PROVIDES_HD ||
|
||||
@@ -473,7 +477,10 @@ struct device HIDDEN
|
||||
|
||||
dev->probes[n++] = dev_probes[i];
|
||||
current += pos;
|
||||
- debug("current:%s", current);
|
||||
+ if (current[0] == '\0')
|
||||
+ debug("finished");
|
||||
+ else
|
||||
+ debug("current:'%s'", current);
|
||||
last_successful_probe = i;
|
||||
|
||||
if (!*current || !strncmp(current, "block/", 6))
|
||||
@@ -482,8 +489,8 @@ struct device HIDDEN
|
||||
continue;
|
||||
}
|
||||
|
||||
- debug("dev_probes[i+1]: %p dev->interface_type: %d\n",
|
||||
- dev_probes[i+1], dev->interface_type);
|
||||
+ debug("dev_probes[%d]: %p dev->interface_type: %d\n",
|
||||
+ i+1, dev_probes[i+1], dev->interface_type);
|
||||
if (dev_probes[i+1] == NULL && dev->interface_type == unknown) {
|
||||
pos = 0;
|
||||
rc = sscanf(current, "%*[^/]/%n", &pos);
|
||||
@@ -499,8 +506,8 @@ slash_err:
|
||||
if (!current[pos])
|
||||
goto slash_err;
|
||||
|
||||
- debug("Cannot parse device link segment \"%s\"", current);
|
||||
- debug("Skipping to \"%s\"", current + pos);
|
||||
+ debug("Cannot parse device link segment '%s'", current);
|
||||
+ debug("Skipping to '%s'", current + pos);
|
||||
debug("This means we can only create abbreviated paths");
|
||||
dev->flags |= DEV_ABBREV_ONLY;
|
||||
i = last_successful_probe;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,212 +0,0 @@
|
||||
From c9c1424d0e09bf33b747d37c43177c63367b1290 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Fri, 11 Oct 2019 14:20:54 -0400
|
||||
Subject: [PATCH 57/86] Try even harder to find disk device symlinks in sysfs.
|
||||
|
||||
Today's realization is that the thing encoded into the structure of
|
||||
sysfs is, in the best case, the dependency graph of the makefile targets
|
||||
to build a device driver.
|
||||
|
||||
In the case of nvme-fabric, or really wherever the kernel has
|
||||
class_create() and device_create() in the same function, there's an
|
||||
extra level of indirection.
|
||||
|
||||
Anyway, in this patch we stop pretending sysfs isn't completely absurd,
|
||||
and just try adding "/device" in the middle of the driver symlink path,
|
||||
until we actually either get ENOENT on the device symlink or find a
|
||||
device symlink that actually has a driver symlink under it.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/linux-nvme.c | 13 ++++-----
|
||||
src/linux.c | 46 +++++++++++++++++--------------
|
||||
src/linux.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
3 files changed, 102 insertions(+), 28 deletions(-)
|
||||
|
||||
diff --git a/src/linux-nvme.c b/src/linux-nvme.c
|
||||
index b83c631119a..5d69a33c715 100644
|
||||
--- a/src/linux-nvme.c
|
||||
+++ b/src/linux-nvme.c
|
||||
@@ -89,13 +89,12 @@ parse_nvme(struct device *dev, const char *path, const char *root UNUSED)
|
||||
/*
|
||||
* now fish the eui out of sysfs is there is one...
|
||||
*/
|
||||
- rc = read_sysfs_file(&filebuf,
|
||||
- "class/block/nvme%dn%d/eui",
|
||||
- ctrl_id, ns_id);
|
||||
- if ((rc < 0 && errno == ENOENT) || filebuf == NULL) {
|
||||
- rc = read_sysfs_file(&filebuf,
|
||||
- "class/block/nvme%dn%d/device/eui",
|
||||
- ctrl_id, ns_id);
|
||||
+ char *euipath = NULL;
|
||||
+ rc = read_sysfs_file(&filebuf, "class/block/nvme%dn%d/eui", ctrl_id, ns_id);
|
||||
+ if (rc < 0 && (errno == ENOENT || errno == ENOTDIR)) {
|
||||
+ rc = find_device_file(&euipath, "eui", "class/block/nvme%dn%d", ctrl_id, ns_id);
|
||||
+ if (rc >= 0 && euipath != NULL)
|
||||
+ rc = read_sysfs_file(&filebuf, "%s", euipath);
|
||||
}
|
||||
if (rc >= 0 && filebuf != NULL) {
|
||||
uint8_t eui[8];
|
||||
diff --git a/src/linux.c b/src/linux.c
|
||||
index 1051894e7bc..0324e20c8cf 100644
|
||||
--- a/src/linux.c
|
||||
+++ b/src/linux.c
|
||||
@@ -401,26 +401,32 @@ struct device HIDDEN
|
||||
goto err;
|
||||
}
|
||||
|
||||
- if (dev->device[0] != 0) {
|
||||
- rc = sysfs_readlink(&tmpbuf, "block/%s/device/driver", dev->disk_name);
|
||||
+ /*
|
||||
+ * So, on a normal disk, you get something like:
|
||||
+ * /sys/block/sda/device -> ../../0:0:0:0
|
||||
+ * /sys/block/sda/device/driver -> ../../../../../../../bus/scsi/drivers/sd
|
||||
+ *
|
||||
+ * On a directly attached nvme device you get:
|
||||
+ * /sys/block/nvme0n1/device -> ../../nvme0
|
||||
+ * /sys/block/nvme0n1/device/device -> ../../../0000:6e:00.0
|
||||
+ * /sys/block/nvme0n1/device/device/driver -> ../../../../bus/pci/drivers/nvme
|
||||
+ *
|
||||
+ * On a fabric-attached nvme device, you get something like:
|
||||
+ * /sys/block/nvme0n1/device -> ../../nvme0
|
||||
+ * /sys/block/nvme0n1/device/device -> ../../ctl
|
||||
+ * /sys/block/nvme0n1/device/device/device -> ../../../../../0000:6e:00.0
|
||||
+ * /sys/block/nvme0n1/device/device/device/driver -> ../../../../../../bus/pci/drivers/nvme-fabrics
|
||||
+ *
|
||||
+ * ... I think? I don't have one in front of me.
|
||||
+ */
|
||||
+
|
||||
+ char *filepath = NULL;
|
||||
+ rc = find_device_file(&filepath, "driver", "block/%s", dev->disk_name);
|
||||
+ if (rc >= 0) {
|
||||
+ rc = sysfs_readlink(&tmpbuf, "%s", filepath);
|
||||
if (rc < 0 || !tmpbuf) {
|
||||
- if (errno == ENOENT) {
|
||||
- /*
|
||||
- * nvme, for example, will have nvme0n1/device point
|
||||
- * at nvme0, and we need to look for device/driver
|
||||
- * there.
|
||||
- */
|
||||
- rc = sysfs_readlink(&tmpbuf,
|
||||
- "block/%s/device/device/driver",
|
||||
- dev->disk_name);
|
||||
- if (rc >= 0 && tmpbuf)
|
||||
- efi_error_pop();
|
||||
- }
|
||||
- if (rc < 0 || !tmpbuf) {
|
||||
- efi_error("readlink of /sys/block/%s/device/driver failed",
|
||||
- dev->disk_name);
|
||||
- goto err;
|
||||
- }
|
||||
+ efi_error("readlink of /sys/%s failed", filepath);
|
||||
+ goto err;
|
||||
}
|
||||
|
||||
linkbuf = pathseg(tmpbuf, -1);
|
||||
@@ -431,7 +437,7 @@ struct device HIDDEN
|
||||
|
||||
dev->driver = strdup(linkbuf);
|
||||
} else {
|
||||
- dev->driver = strdup("");
|
||||
+ dev->driver = strdup("");
|
||||
}
|
||||
|
||||
if (!dev->driver) {
|
||||
diff --git a/src/linux.h b/src/linux.h
|
||||
index 5ae64ffaacf..97f9518bb5c 100644
|
||||
--- a/src/linux.h
|
||||
+++ b/src/linux.h
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libefiboot - library for the manipulation of EFI boot variables
|
||||
- * Copyright 2012-2015 Red Hat, Inc.
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
* Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@@ -218,6 +218,22 @@ extern ssize_t HIDDEN make_mac_path(uint8_t *buf, ssize_t size,
|
||||
_rc; \
|
||||
})
|
||||
|
||||
+#define sysfs_access(mode, fmt, args...) \
|
||||
+ ({ \
|
||||
+ int rc_; \
|
||||
+ char *pn_; \
|
||||
+ \
|
||||
+ rc_ = asprintfa(&pn_, "/sys/" fmt, ## args); \
|
||||
+ if (rc_ >= 0) { \
|
||||
+ rc_ = access(pn_, mode); \
|
||||
+ if (rc_ < 0) \
|
||||
+ efi_error("could not access %s", pn_); \
|
||||
+ } else { \
|
||||
+ efi_error("could not allocate memory"); \
|
||||
+ } \
|
||||
+ rc_; \
|
||||
+ })
|
||||
+
|
||||
#define sysfs_stat(statbuf, fmt, args...) \
|
||||
({ \
|
||||
int rc_; \
|
||||
@@ -251,6 +267,59 @@ extern ssize_t HIDDEN make_mac_path(uint8_t *buf, ssize_t size,
|
||||
dir_; \
|
||||
})
|
||||
|
||||
+/*
|
||||
+ * Iterate a /sys/block directory looking for device/foo, device/device/foo,
|
||||
+ * etc. I'm not proud of this method.
|
||||
+ */
|
||||
+#define find_device_file(result, name, fmt, args...) \
|
||||
+ ({ \
|
||||
+ int rc_ = 0; \
|
||||
+ debug("searching for %s from in %s", name, dev->disk_name); \
|
||||
+ for (unsigned int try_ = 0; true; try_++) { \
|
||||
+ char slashdev_[sizeof("device") \
|
||||
+ + try_ * strlen("/device")]; \
|
||||
+ \
|
||||
+ char *nul_ = stpcpy(slashdev_, "device"); \
|
||||
+ for (unsigned int i_ = 0; i_ < try_; i_++) \
|
||||
+ nul_ = stpcpy(nul_, "/device"); \
|
||||
+ \
|
||||
+ debug("trying /sys/" fmt "/%s/%s", \
|
||||
+ ## args, slashdev_, name); \
|
||||
+ \
|
||||
+ rc_ = sysfs_access(F_OK, fmt "/%s", ## args, slashdev_);\
|
||||
+ if (rc_ < 0) { \
|
||||
+ if (errno == ENOENT) { \
|
||||
+ efi_error_pop(); \
|
||||
+ break; \
|
||||
+ } \
|
||||
+ efi_error("cannot access /sys/"fmt"/%s: %m", \
|
||||
+ ## args, slashdev_); \
|
||||
+ goto find_device_link_err_; \
|
||||
+ } \
|
||||
+ \
|
||||
+ rc_ = sysfs_access(F_OK, fmt "/%s/%s", \
|
||||
+ ## args, slashdev_, name); \
|
||||
+ if (rc_ < 0) { \
|
||||
+ if (errno == ENOENT) { \
|
||||
+ efi_error_pop(); \
|
||||
+ break; \
|
||||
+ } \
|
||||
+ efi_error("cannot access /sys/"fmt"/%s/%s: %m", \
|
||||
+ ## args, slashdev_, name); \
|
||||
+ goto find_device_link_err_; \
|
||||
+ } \
|
||||
+ \
|
||||
+ rc_ = asprintfa(result, fmt "/%s/%s", \
|
||||
+ ## args, slashdev_, name); \
|
||||
+ if (rc_ < 0) { \
|
||||
+ efi_error("cannot allocate memory: %m"); \
|
||||
+ goto find_device_link_err_; \
|
||||
+ } \
|
||||
+ } \
|
||||
+find_device_link_err_: \
|
||||
+ rc_; \
|
||||
+ })
|
||||
+
|
||||
#define DEV_PROVIDES_ROOT 1
|
||||
#define DEV_PROVIDES_HD 2
|
||||
#define DEV_ABBREV_ONLY 4
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,313 +0,0 @@
|
||||
From c41da0bdce04ab0f99b992d51ff6fd0ab55d040a Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 2 Oct 2019 17:04:12 -0400
|
||||
Subject: [PATCH 58/86] Handle
|
||||
/sys/devices/virtual/{nvme-fabrics,nvme-subsystem} devices
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/linux-nvme.c | 52 ++++++++++++++++++++----
|
||||
src/linux-virtual-root.c | 88 ++++++++++++++++++++++++++++++++++++++++
|
||||
src/linux.c | 43 +++++++++++++++++---
|
||||
src/linux.h | 4 +-
|
||||
4 files changed, 173 insertions(+), 14 deletions(-)
|
||||
create mode 100644 src/linux-virtual-root.c
|
||||
|
||||
diff --git a/src/linux-nvme.c b/src/linux-nvme.c
|
||||
index 5d69a33c715..d0941e85e08 100644
|
||||
--- a/src/linux-nvme.c
|
||||
+++ b/src/linux-nvme.c
|
||||
@@ -15,7 +15,6 @@
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
- *
|
||||
*/
|
||||
|
||||
#include "fix_coverity.h"
|
||||
@@ -35,6 +34,12 @@
|
||||
* /sys/dev/block/$major:$minor looks like:
|
||||
* 259:0 -> ../../devices/pci0000:00/0000:00:1d.0/0000:05:00.0/nvme/nvme0/nvme0n1
|
||||
* 259:1 -> ../../devices/pci0000:00/0000:00:1d.0/0000:05:00.0/nvme/nvme0/nvme0n1/nvme0n1p1
|
||||
+ * or:
|
||||
+ * 259:0 ->../../devices/virtual/nvme-fabrics/ctl/nvme0/nvme0n1
|
||||
+ * 259:1 ->../../devices/virtual/nvme-fabrics/ctl/nvme0/nvme0n1/nvme0n1p1
|
||||
+ * or:
|
||||
+ * 259:5 -> ../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1
|
||||
+ * 259:6 -> ../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1/nvme0n1p1
|
||||
*
|
||||
* /sys/dev/block/259:0/device looks like:
|
||||
* device -> ../../nvme0
|
||||
@@ -56,14 +61,42 @@ parse_nvme(struct device *dev, const char *path, const char *root UNUSED)
|
||||
int32_t tosser0, tosser1, tosser2, ctrl_id, ns_id, partition;
|
||||
uint8_t *filebuf = NULL;
|
||||
int pos0 = -1, pos1 = -1, pos2 = -1;
|
||||
+ ssize_t sz = 0;
|
||||
+ struct subdir {
|
||||
+ const char * const name;
|
||||
+ const char * const fmt;
|
||||
+ int *pos0, *pos1;
|
||||
+ } subdirs[] = {
|
||||
+ {"nvme-subsysN/", "%nnvme-subsys%d/%n", &pos0, &pos2},
|
||||
+ {"ctl/", "%nctl/%n%n", &pos0, &pos1},
|
||||
+ {"nvme/", "%nnvme/%n%n", &pos0, &pos1},
|
||||
+ {NULL, }
|
||||
+ };
|
||||
|
||||
debug("entry");
|
||||
|
||||
- debug("searching for nvme/nvme0/nvme0n1 or nvme/nvme0/nvme0n1/nvme0n1p1");
|
||||
- rc = sscanf(current, "%nnvme/nvme%d/nvme%dn%d%n/nvme%dn%dp%d%n",
|
||||
- &pos0, &tosser0, &ctrl_id, &ns_id,
|
||||
- &pos1, &tosser1, &tosser2, &partition, &pos2);
|
||||
- debug("current:\"%s\" rc:%d pos0:%d pos1:%d pos2:%d\n", current, rc, pos0, pos1, pos2);
|
||||
+ /*
|
||||
+ * in this case, *any* of these is okay.
|
||||
+ */
|
||||
+ for (int i = 0; subdirs[i].name; i++) {
|
||||
+ debug("searching for %s", subdirs[i].name);
|
||||
+ pos0 = tosser0 = pos1 = -1;
|
||||
+ rc = sscanf(current, subdirs[i].fmt, &pos0, &pos1, &pos2);
|
||||
+ debug("current:'%s' rc:%d pos0:%d pos1:%d\n", current, rc,
|
||||
+ *subdirs[i].pos0, *subdirs[i].pos1);
|
||||
+ dbgmk(" ", *subdirs[i].pos0, *subdirs[i].pos1);
|
||||
+ if (*subdirs[i].pos0 >= 0 && *subdirs[i].pos1 >= *subdirs[i].pos0) {
|
||||
+ sz += *subdirs[i].pos1;
|
||||
+ current += *subdirs[i].pos1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ debug("searching for nvme0/nvme0n1 or nvme0/nvme0n1/nvme0n1p1");
|
||||
+ rc = sscanf(current, "%nnvme%d/nvme%dn%d%n/nvme%dn%dp%d%n",
|
||||
+ &pos0, &tosser0, &ctrl_id, &ns_id, &pos1,
|
||||
+ &tosser1, &tosser2, &partition, &pos2);
|
||||
+ debug("current:'%s' rc:%d pos0:%d pos1:%d pos2:%d\n", current, rc, pos0, pos1, pos2);
|
||||
dbgmk(" ", pos0, MAX(pos1,pos2));
|
||||
/*
|
||||
* If it isn't of that form, it's not one of our nvme devices.
|
||||
@@ -82,13 +115,15 @@ parse_nvme(struct device *dev, const char *path, const char *root UNUSED)
|
||||
if (dev->part == -1)
|
||||
dev->part = partition;
|
||||
|
||||
- pos1 = pos2;
|
||||
+ pos1 = pos2;
|
||||
}
|
||||
+
|
||||
current += pos1;
|
||||
|
||||
/*
|
||||
* now fish the eui out of sysfs is there is one...
|
||||
*/
|
||||
+ debug("looking for the eui");
|
||||
char *euipath = NULL;
|
||||
rc = read_sysfs_file(&filebuf, "class/block/nvme%dn%d/eui", ctrl_id, ns_id);
|
||||
if (rc < 0 && (errno == ENOENT || errno == ENOTDIR)) {
|
||||
@@ -111,6 +146,9 @@ parse_nvme(struct device *dev, const char *path, const char *root UNUSED)
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
+ debug("eui is %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
|
||||
+ eui[0], eui[1], eui[2], eui[3],
|
||||
+ eui[4], eui[5], eui[6], eui[7]);
|
||||
dev->nvme_info.has_eui = 1;
|
||||
memcpy(dev->nvme_info.eui, eui, sizeof(eui));
|
||||
}
|
||||
diff --git a/src/linux-virtual-root.c b/src/linux-virtual-root.c
|
||||
new file mode 100644
|
||||
index 00000000000..75fbbfc1de6
|
||||
--- /dev/null
|
||||
+++ b/src/linux-virtual-root.c
|
||||
@@ -0,0 +1,88 @@
|
||||
+/*
|
||||
+ * libefiboot - library for the manipulation of EFI boot variables
|
||||
+ * Copyright 2012-2019 Red Hat, Inc.
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public License as
|
||||
+ * published by the Free Software Foundation; either version 2.1 of the
|
||||
+ * License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, see
|
||||
+ * <http://www.gnu.org/licenses/>.
|
||||
+ */
|
||||
+
|
||||
+#include "fix_coverity.h"
|
||||
+
|
||||
+#include <errno.h>
|
||||
+#include <fcntl.h>
|
||||
+#include <inttypes.h>
|
||||
+#include <stdint.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+#include "efiboot.h"
|
||||
+
|
||||
+/*
|
||||
+ * Support virtually rooted devices (fibre+nvme, etc.)
|
||||
+ *
|
||||
+ * /sys/dev/block/$major:$minor looks like:
|
||||
+ * 259:0 ->../../devices/virtual/nvme-fabrics/ctl/nvme0/nvme0n1
|
||||
+ * 259:1 ->../../devices/virtual/nvme-fabrics/ctl/nvme0/nvme0n1/nvme0n1p1
|
||||
+ * or:
|
||||
+ * 259:5 -> ../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1
|
||||
+ * 259:6 -> ../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1/nvme0n1p1
|
||||
+ */
|
||||
+
|
||||
+static ssize_t
|
||||
+parse_virtual_root(struct device *dev UNUSED, const char *current, const char *root UNUSED)
|
||||
+{
|
||||
+ int rc;
|
||||
+ ssize_t sz;
|
||||
+ int pos0 = 0, pos1 = 0;
|
||||
+ struct subdir {
|
||||
+ const char * const name;
|
||||
+ const char * const fmt;
|
||||
+ } subdirs[] = {
|
||||
+ {"../../devices/virtual", "%n../../devices/virtual/%n"},
|
||||
+ {"nvme-subsystem/", "%nnvme-subsystem/%n"},
|
||||
+ {"nvme-fabrics/ctl/", "%nnvme-fabrics/ctl/%n"},
|
||||
+ {NULL, NULL}
|
||||
+ };
|
||||
+
|
||||
+ debug("entry");
|
||||
+
|
||||
+ for (int i = 0; subdirs[i].name; i++) {
|
||||
+ debug("searching for %s", subdirs[i].name);
|
||||
+ pos0 = pos1 = -1;
|
||||
+ rc = sscanf(current, subdirs[i].fmt, &pos0, &pos1);
|
||||
+ debug("current:'%s' rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
|
||||
+ dbgmk(" ", pos0, pos1);
|
||||
+ if (rc == 1) {
|
||||
+ sz += pos1;
|
||||
+ current += pos1;
|
||||
+ if (i > 0)
|
||||
+ goto found;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ sz = 0;
|
||||
+found:
|
||||
+ debug("current:'%s' sz:%zd\n", current, sz);
|
||||
+ return sz;
|
||||
+}
|
||||
+
|
||||
+static enum interface_type virtual_root_iftypes[] = { virtual_root, unknown };
|
||||
+
|
||||
+struct dev_probe HIDDEN virtual_root_parser = {
|
||||
+ .name = "virtual_root",
|
||||
+ .iftypes = virtual_root_iftypes,
|
||||
+ .flags = DEV_ABBREV_ONLY|DEV_PROVIDES_ROOT,
|
||||
+ .parse = parse_virtual_root,
|
||||
+};
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/linux.c b/src/linux.c
|
||||
index 0324e20c8cf..67fbb1be059 100644
|
||||
--- a/src/linux.c
|
||||
+++ b/src/linux.c
|
||||
@@ -170,16 +170,17 @@ int HIDDEN
|
||||
set_disk_and_part_name(struct device *dev)
|
||||
{
|
||||
int rc = -1;
|
||||
-
|
||||
- /*
|
||||
- * results are like such:
|
||||
- * maj:min -> ../../devices/pci$PCI_STUFF/$BLOCKDEV_STUFF/block/$DISK/$PART
|
||||
- */
|
||||
-
|
||||
char *ultimate = pathseg(dev->link, -1);
|
||||
char *penultimate = pathseg(dev->link, -2);
|
||||
char *approximate = pathseg(dev->link, -3);
|
||||
char *proximate = pathseg(dev->link, -4);
|
||||
+ char *psl5 = pathseg(dev->link, -5);
|
||||
+
|
||||
+
|
||||
+ /*
|
||||
+ * devlinks look something like:
|
||||
+ * maj:min -> ../../devices/pci$PCI_STUFF/$BLOCKDEV_STUFF/block/$DISK/$PART
|
||||
+ */
|
||||
|
||||
errno = 0;
|
||||
debug("dev->disk_name:%p dev->part_name:%p", dev->disk_name, dev->part_name);
|
||||
@@ -188,6 +189,7 @@ set_disk_and_part_name(struct device *dev)
|
||||
debug("penultimate:'%s'", penultimate ? : "");
|
||||
debug("approximate:'%s'", approximate ? : "");
|
||||
debug("proximate:'%s'", proximate ? : "");
|
||||
+ debug("psl5:'%s'", psl5 ? : "");
|
||||
|
||||
if (ultimate && penultimate &&
|
||||
((proximate && !strcmp(proximate, "nvme")) ||
|
||||
@@ -232,6 +234,34 @@ set_disk_and_part_name(struct device *dev)
|
||||
set_disk_name(dev, "%s", ultimate);
|
||||
debug("disk:%s", ultimate);
|
||||
rc = 0;
|
||||
+ } else if ((proximate && ultimate && !strcmp(proximate, "nvme-fabrics")) ||
|
||||
+ (approximate && ultimate && !strcmp(approximate, "nvme-subsystem"))) {
|
||||
+ /*
|
||||
+ * 259:0 ->../../devices/virtual/nvme-fabrics/ctl/nvme0/nvme0n1
|
||||
+ * ^ proximate ^ ultimate
|
||||
+ * or
|
||||
+ * 259:5 -> ../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1
|
||||
+ * ^ approximate ^ penultimate
|
||||
+ * ultimate ^
|
||||
+ */
|
||||
+ set_disk_name(dev, "%s", ultimate);
|
||||
+ debug("disk:%s", ultimate);
|
||||
+ rc = 0;
|
||||
+ } else if ((psl5 && penultimate && ultimate && !strcmp(psl5, "nvme-fabrics")) ||
|
||||
+ (proximate && penultimate && ultimate && !strcmp(proximate, "nvme-subsystem"))) {
|
||||
+ /*
|
||||
+ * 259:1 -> ../../devices/virtual/nvme-fabrics/ctl/nvme0/nvme0n1/nvme0n1p1
|
||||
+ * ^psl5 ^ penultimate
|
||||
+ * ultimate ^
|
||||
+ * or
|
||||
+ * 259:6 -> ../../devices/virtual/nvme-subsystem/nvme-subsys0/nvme0n1/nvme0n1p1
|
||||
+ * ^ proximate ^ penultimate
|
||||
+ * ultimate ^
|
||||
+ */
|
||||
+ set_disk_name(dev, "%s", penultimate);
|
||||
+ set_part_name(dev, "%s", ultimate);
|
||||
+ debug("disk:%s part:%s", penultimate, ultimate);
|
||||
+ rc = 0;
|
||||
}
|
||||
|
||||
if (rc < 0)
|
||||
@@ -248,6 +278,7 @@ static struct dev_probe *dev_probes[] = {
|
||||
&acpi_root_parser,
|
||||
&pci_root_parser,
|
||||
&soc_root_parser,
|
||||
+ &virtual_root_parser,
|
||||
&pci_parser,
|
||||
&virtblk_parser,
|
||||
&sas_parser,
|
||||
diff --git a/src/linux.h b/src/linux.h
|
||||
index 97f9518bb5c..a5ef0dfa154 100644
|
||||
--- a/src/linux.h
|
||||
+++ b/src/linux.h
|
||||
@@ -99,7 +99,8 @@ struct emmc_info {
|
||||
|
||||
enum interface_type {
|
||||
unknown,
|
||||
- isa, acpi_root, pci_root, soc_root, pci, network,
|
||||
+ isa, acpi_root, pci_root, soc_root, virtual_root,
|
||||
+ pci, network,
|
||||
ata, atapi, scsi, sata, sas,
|
||||
usb, i1394, fibre, i2o,
|
||||
md, virtblk,
|
||||
@@ -346,6 +347,7 @@ extern struct dev_probe pmem_parser;
|
||||
extern struct dev_probe pci_root_parser;
|
||||
extern struct dev_probe acpi_root_parser;
|
||||
extern struct dev_probe soc_root_parser;
|
||||
+extern struct dev_probe virtual_root_parser;
|
||||
extern struct dev_probe pci_parser;
|
||||
extern struct dev_probe sas_parser;
|
||||
extern struct dev_probe sata_parser;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,72 +0,0 @@
|
||||
From ca85d518ab6063ff07af41672dcb366610f51a20 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 15 Oct 2019 16:58:19 -0400
|
||||
Subject: [PATCH 59/86] Put some EFI device paths into the debug log
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/linux.c | 41 +++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 41 insertions(+)
|
||||
|
||||
diff --git a/src/linux.c b/src/linux.c
|
||||
index 67fbb1be059..6b88bfb7e9b 100644
|
||||
--- a/src/linux.c
|
||||
+++ b/src/linux.c
|
||||
@@ -336,6 +336,44 @@ device_free(struct device *dev)
|
||||
free(dev);
|
||||
}
|
||||
|
||||
+static void
|
||||
+print_dev_dp_node(struct device *dev, struct dev_probe *probe)
|
||||
+{
|
||||
+ ssize_t dpsz;
|
||||
+ uint8_t *dp;
|
||||
+ ssize_t bufsz;
|
||||
+ uint8_t *buf;
|
||||
+
|
||||
+ dpsz = probe->create(dev, NULL, 0, 0);
|
||||
+ if (dpsz <= 0)
|
||||
+ return;
|
||||
+
|
||||
+ dp = alloca(dpsz + 4);
|
||||
+ if (!dp)
|
||||
+ return;
|
||||
+
|
||||
+ dpsz = probe->create(dev, dp, dpsz, 0);
|
||||
+ if (dpsz <= 0)
|
||||
+ return;
|
||||
+
|
||||
+ efidp_make_end_entire(dp + dpsz, 4);
|
||||
+ bufsz = efidp_format_device_path(NULL, 0,
|
||||
+ (const_efidp)dp, dpsz + 4);
|
||||
+ if (bufsz <= 0)
|
||||
+ return;
|
||||
+
|
||||
+ buf = alloca(bufsz);
|
||||
+ if (!buf)
|
||||
+ return;
|
||||
+
|
||||
+ bufsz = efidp_format_device_path(buf, bufsz,
|
||||
+ (const_efidp)dp, dpsz + 4);
|
||||
+ if (bufsz <= 0)
|
||||
+ return;
|
||||
+
|
||||
+ debug("Device path node is %s", buf);
|
||||
+}
|
||||
+
|
||||
struct device HIDDEN
|
||||
*device_get(int fd, int partition)
|
||||
{
|
||||
@@ -512,6 +550,9 @@ struct device HIDDEN
|
||||
probe->flags & DEV_ABBREV_ONLY)
|
||||
needs_root = false;
|
||||
|
||||
+ if (probe->create)
|
||||
+ print_dev_dp_node(dev, probe);
|
||||
+
|
||||
dev->probes[n++] = dev_probes[i];
|
||||
current += pos;
|
||||
if (current[0] == '\0')
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,99 +0,0 @@
|
||||
From 9fa8c3a91ac834564ef6e3d1455a63b1eaee4c14 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 13 Jan 2020 09:51:56 -0500
|
||||
Subject: [PATCH 60/86] Update abixml
|
||||
|
||||
---
|
||||
src/libefiboot.abixml | 10 +++++-----
|
||||
src/libefivar.abixml | 10 +++++-----
|
||||
2 files changed, 10 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/libefiboot.abixml b/src/libefiboot.abixml
|
||||
index ffdae048021..4b673d5c3e9 100644
|
||||
--- a/src/libefiboot.abixml
|
||||
+++ b/src/libefiboot.abixml
|
||||
@@ -1577,13 +1577,13 @@
|
||||
<function-decl name='__builtin_memcpy' mangled-name='memcpy' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-168'/>
|
||||
</function-decl>
|
||||
- <function-decl name='free' mangled-name='free' filepath='/usr/include/stdlib.h' line='563' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
+ <function-decl name='free' mangled-name='free' filepath='/usr/include/stdlib.h' line='565' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-168'/>
|
||||
</function-decl>
|
||||
- <function-decl name='calloc' mangled-name='calloc' filepath='/usr/include/stdlib.h' line='541' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
+ <function-decl name='calloc' mangled-name='calloc' filepath='/usr/include/stdlib.h' line='542' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-168'/>
|
||||
</function-decl>
|
||||
- <function-decl name='realloc' mangled-name='realloc' filepath='/usr/include/stdlib.h' line='549' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
+ <function-decl name='realloc' mangled-name='realloc' filepath='/usr/include/stdlib.h' line='550' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-168'/>
|
||||
</function-decl>
|
||||
<function-decl name='read' mangled-name='read' filepath='/usr/include/unistd.h' line='360' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
@@ -1685,7 +1685,7 @@
|
||||
<function-decl name='efi_str_to_guid' mangled-name='efi_str_to_guid' filepath='src/include/efivar/efivar.h' line='112' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-168'/>
|
||||
</function-decl>
|
||||
- <function-decl name='getenv' mangled-name='getenv' filepath='/usr/include/stdlib.h' line='631' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
+ <function-decl name='getenv' mangled-name='getenv' filepath='/usr/include/stdlib.h' line='634' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-168'/>
|
||||
</function-decl>
|
||||
<function-decl name='efidp_make_sas' mangled-name='efidp_make_sas' filepath='src/include/efivar/efivar-dp.h' line='579' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
@@ -1709,7 +1709,7 @@
|
||||
<function-decl name='strerror' mangled-name='strerror' filepath='/usr/include/string.h' line='396' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-168'/>
|
||||
</function-decl>
|
||||
- <function-decl name='posix_memalign' mangled-name='posix_memalign' filepath='/usr/include/stdlib.h' line='577' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
+ <function-decl name='posix_memalign' mangled-name='posix_memalign' filepath='/usr/include/stdlib.h' line='580' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-168'/>
|
||||
</function-decl>
|
||||
<function-decl name='lseek' mangled-name='lseek' filepath='/usr/include/unistd.h' line='334' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
diff --git a/src/libefivar.abixml b/src/libefivar.abixml
|
||||
index 4aadf5079a7..094f43d7b27 100644
|
||||
--- a/src/libefivar.abixml
|
||||
+++ b/src/libefivar.abixml
|
||||
@@ -639,7 +639,7 @@
|
||||
<var-decl name='default_ops' type-id='type-id-71' visibility='default' filepath='src/lib.c' line='38' column='1'/>
|
||||
<var-decl name='vars_ops' type-id='type-id-71' visibility='default' filepath='src/lib.h' line='50' column='1'/>
|
||||
<var-decl name='efivarfs_ops' type-id='type-id-71' visibility='default' filepath='src/lib.h' line='51' column='1'/>
|
||||
- <function-decl name='getenv' mangled-name='getenv' filepath='/usr/include/stdlib.h' line='631' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
+ <function-decl name='getenv' mangled-name='getenv' filepath='/usr/include/stdlib.h' line='634' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-35'/>
|
||||
</function-decl>
|
||||
<function-decl name='asprintf' mangled-name='asprintf' filepath='/usr/include/stdio.h' line='372' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
@@ -648,7 +648,7 @@
|
||||
<function-decl name='chmod' mangled-name='chmod' filepath='/usr/include/sys/stat.h' line='280' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-35'/>
|
||||
</function-decl>
|
||||
- <function-decl name='free' mangled-name='free' filepath='/usr/include/stdlib.h' line='563' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
+ <function-decl name='free' mangled-name='free' filepath='/usr/include/stdlib.h' line='565' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-35'/>
|
||||
</function-decl>
|
||||
<function-decl name='umask' mangled-name='umask' filepath='/usr/include/sys/stat.h' line='308' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
@@ -678,7 +678,7 @@
|
||||
<function-decl name='malloc' mangled-name='malloc' filepath='/usr/include/stdlib.h' line='539' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-35'/>
|
||||
</function-decl>
|
||||
- <function-decl name='calloc' mangled-name='calloc' filepath='/usr/include/stdlib.h' line='541' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
+ <function-decl name='calloc' mangled-name='calloc' filepath='/usr/include/stdlib.h' line='542' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-35'/>
|
||||
</function-decl>
|
||||
<function-decl name='printf' mangled-name='printf' filepath='/usr/include/stdio.h' line='332' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
@@ -693,13 +693,13 @@
|
||||
<function-decl name='__builtin_puts' mangled-name='puts' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-35'/>
|
||||
</function-decl>
|
||||
- <function-decl name='exit' mangled-name='exit' filepath='/usr/include/stdlib.h' line='614' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
+ <function-decl name='exit' mangled-name='exit' filepath='/usr/include/stdlib.h' line='617' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-35'/>
|
||||
</function-decl>
|
||||
<function-decl name='vasprintf' mangled-name='vasprintf' filepath='/usr/include/stdio.h' line='366' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-35'/>
|
||||
</function-decl>
|
||||
- <function-decl name='realloc' mangled-name='realloc' filepath='/usr/include/stdlib.h' line='549' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
+ <function-decl name='realloc' mangled-name='realloc' filepath='/usr/include/stdlib.h' line='550' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<return type-id='type-id-35'/>
|
||||
</function-decl>
|
||||
<function-decl name='strdup' mangled-name='strdup' filepath='/usr/include/string.h' line='166' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
--
|
||||
2.24.1
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,43 +0,0 @@
|
||||
From b99adbbd711ff4c4cc0caa9d171d07914ee7ddef Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 13 Jan 2020 15:58:47 -0500
|
||||
Subject: [PATCH 62/86] Don't use -march=native on ia64.
|
||||
|
||||
I don't understand why this architecture hasn't been fully pushed into
|
||||
the sea*, but somehow there are bug reports anyway. In this case,
|
||||
because the gcc port is inadequately maintained.
|
||||
|
||||
(* don't pollute the planet this way, destroy the device responsibly.)
|
||||
|
||||
Resolves github issue #144
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/include/defaults.mk | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/include/defaults.mk b/src/include/defaults.mk
|
||||
index af6a41a9824..8a784d00be3 100644
|
||||
--- a/src/include/defaults.mk
|
||||
+++ b/src/include/defaults.mk
|
||||
@@ -56,10 +56,16 @@ override _CCLDFLAGS := $(CCLDFLAGS)
|
||||
override CCLDFLAGS = $(CFLAGS) -L. $(_CCLDFLAGS) \
|
||||
$(call add-prefix,-Wl,$(LDFLAGS)) \
|
||||
$(call pkg-config-ccldflags)
|
||||
+HOST_ARCH=$(shell uname -m)
|
||||
+ifneq ($(HOST_ARCH),ia64)
|
||||
+ HOST_MARCH=-march=native
|
||||
+else
|
||||
+ HOST_MARCH=
|
||||
+endif
|
||||
HOST_CPPFLAGS ?= $(CPPFLAGS)
|
||||
override _HOST_CPPFLAGS := $(HOST_CPPFLAGS)
|
||||
override HOST_CPPFLAGS = $(_HOST_CPPFLAGS) \
|
||||
- -DEFIVAR_BUILD_ENVIRONMENT -march=native
|
||||
+ -DEFIVAR_BUILD_ENVIRONMENT $(HOST_MARCH)
|
||||
HOST_CFLAGS ?= $(CFLAGS)
|
||||
override _HOST_CFLAGS := $(HOST_CFLAGS)
|
||||
override HOST_CFLAGS = $(_HOST_CFLAGS)
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,56 +0,0 @@
|
||||
From 191e3b01463548fc3a99494cd0c0ec15c41e9382 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 13 Jan 2020 16:27:42 -0500
|
||||
Subject: [PATCH 63/86] Work around autoconf existing in the world.
|
||||
|
||||
Long long ago, autoconf added a variable called to pass linker flags to
|
||||
the compiler. For some misguided reason, they prefixed it with LD (the
|
||||
linker) instead of "CC" (the compiler). Now people unquestioningly
|
||||
complain if you use that name a more reasonable way, so we're stuck with
|
||||
names that are counter-descriptive. You just can't win, the well is too
|
||||
full of poison.
|
||||
|
||||
Resolves github issue #142.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/include/defaults.mk | 16 ++++++++--------
|
||||
1 file changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/include/defaults.mk b/src/include/defaults.mk
|
||||
index 8a784d00be3..781587b4215 100644
|
||||
--- a/src/include/defaults.mk
|
||||
+++ b/src/include/defaults.mk
|
||||
@@ -40,21 +40,21 @@ override CFLAGS = $(_CFLAGS) \
|
||||
-fvisibility=hidden \
|
||||
$(call family,CFLAGS) \
|
||||
$(call pkg-config-cflags)
|
||||
-LDFLAGS_CLANG ?= --fatal-warnings -pie -z relro
|
||||
+LDFLAGS_CLANG ?= -Wl,--fatal-warnings,-pie,-z,relro
|
||||
LDFLAGS ?=
|
||||
override _LDFLAGS := $(LDFLAGS)
|
||||
override LDFLAGS = $(_LDFLAGS) \
|
||||
- --add-needed \
|
||||
- --build-id \
|
||||
- --no-allow-shlib-undefined \
|
||||
- --no-undefined-version \
|
||||
- -z now \
|
||||
- -z muldefs \
|
||||
+ -Wl,--add-needed \
|
||||
+ -Wl,--build-id \
|
||||
+ -Wl,--no-allow-shlib-undefined \
|
||||
+ -Wl,--no-undefined-version \
|
||||
+ -Wl,-z,now \
|
||||
+ -Wl,-z,muldefs \
|
||||
$(call family,LDFLAGS)
|
||||
CCLDFLAGS ?=
|
||||
override _CCLDFLAGS := $(CCLDFLAGS)
|
||||
override CCLDFLAGS = $(CFLAGS) -L. $(_CCLDFLAGS) \
|
||||
- $(call add-prefix,-Wl,$(LDFLAGS)) \
|
||||
+ $(LDFLAGS) \
|
||||
$(call pkg-config-ccldflags)
|
||||
HOST_ARCH=$(shell uname -m)
|
||||
ifneq ($(HOST_ARCH),ia64)
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,37 +0,0 @@
|
||||
From fa29161221937243dd7c3a11908aa020aa5e990c Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 13 Jan 2020 16:40:32 -0500
|
||||
Subject: [PATCH 64/86] Fix "efivar -w" and "efivar -a"
|
||||
|
||||
When adding --export, I broke -w and -a by accidentally using the wrong
|
||||
variable to get the data from. Woops.
|
||||
|
||||
Resolves github issue #143
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/efivar.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/efivar.c b/src/efivar.c
|
||||
index 8b1da8888f6..edfd4af7e01 100644
|
||||
--- a/src/efivar.c
|
||||
+++ b/src/efivar.c
|
||||
@@ -614,12 +614,12 @@ int main(int argc, char *argv[])
|
||||
show_variable(guid_name, SHOW_DECIMAL);
|
||||
break;
|
||||
case ACTION_APPEND | ACTION_PRINT:
|
||||
- prepare_data(infile, &data, &data_size);
|
||||
+ prepare_data(datafile, &data, &data_size);
|
||||
edit_variable(guid_name, data, data_size, attributes,
|
||||
EDIT_APPEND);
|
||||
break;
|
||||
case ACTION_WRITE | ACTION_PRINT:
|
||||
- prepare_data(infile, &data, &data_size);
|
||||
+ prepare_data(datafile, &data, &data_size);
|
||||
edit_variable(guid_name, data, data_size, attributes,
|
||||
EDIT_WRITE);
|
||||
break;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,28 +0,0 @@
|
||||
From c98d11a74f29c91e850aeafd7e09a42b4d883704 Mon Sep 17 00:00:00 2001
|
||||
From: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
Date: Wed, 22 Jan 2020 10:47:20 +0800
|
||||
Subject: [PATCH 65/86] Android: fix incorrect include path
|
||||
|
||||
Fixes: 3ba12ff9 ("Move our infrastructure makefiles out of the topdir")
|
||||
|
||||
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
---
|
||||
src/Android.mk | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/Android.mk b/src/Android.mk
|
||||
index ea6ee3f9432..57ac2b55846 100644
|
||||
--- a/src/Android.mk
|
||||
+++ b/src/Android.mk
|
||||
@@ -46,7 +46,7 @@ LIBEFIVAR_SOURCES := \
|
||||
lib.c \
|
||||
vars.c
|
||||
|
||||
-include $(LOCAL_PATH)/../version.mk
|
||||
+include $(LOCAL_PATH)/include/version.mk
|
||||
|
||||
LOCAL_SRC_FILES := $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES)
|
||||
LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu11 -DLIBEFIVAR_VERSION=$(VERSION)
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,35 +0,0 @@
|
||||
From e79af5540f11bf04905fd13660b0bb80ec995094 Mon Sep 17 00:00:00 2001
|
||||
From: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
Date: Wed, 22 Jan 2020 11:36:58 +0800
|
||||
Subject: [PATCH 66/86] Android: fix missing field initializers
|
||||
|
||||
To fix the error:
|
||||
|
||||
external/efivar/src/linux-nvme.c:73:10: error: missing field 'fmt' initializer [-Werror,-Wmissing-field-initializers]
|
||||
{NULL, }
|
||||
^
|
||||
1 error generated.
|
||||
|
||||
Fixes: c41da0bd ("Handle /sys/devices/virtual/{nvme-fabrics,nvme-subsystem} devices")
|
||||
|
||||
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
---
|
||||
src/Android.mk | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/Android.mk b/src/Android.mk
|
||||
index 57ac2b55846..f6af87c51ac 100644
|
||||
--- a/src/Android.mk
|
||||
+++ b/src/Android.mk
|
||||
@@ -49,7 +49,7 @@ LIBEFIVAR_SOURCES := \
|
||||
include $(LOCAL_PATH)/include/version.mk
|
||||
|
||||
LOCAL_SRC_FILES := $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES)
|
||||
-LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu11 -DLIBEFIVAR_VERSION=$(VERSION)
|
||||
+LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu11 -DLIBEFIVAR_VERSION=$(VERSION) -Wno-missing-field-initializers
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES) $(LOCAL_C_INCLUDES)/efivar $(local-generated-sources-dir)
|
||||
LIBEFIVAR_GUIDS_H := $(local-generated-sources-dir)/efivar/efivar-guids.h
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,39 +0,0 @@
|
||||
From 9dc04c2fd88b6e0e0fe411885041925d52f71af3 Mon Sep 17 00:00:00 2001
|
||||
From: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
Date: Wed, 22 Jan 2020 12:16:12 +0800
|
||||
Subject: [PATCH 67/86] Fix variable 'sz' uninitialized error
|
||||
|
||||
To fix the error:
|
||||
|
||||
external/efivar/src/linux-virtual-root.c:66:4: error: variable 'sz' is uninitialized when used here [-Werror,-Wuninitialized]
|
||||
sz += pos1;
|
||||
^~
|
||||
external/efivar/src/linux-virtual-root.c:45:12: note: initialize the variable 'sz' to silence this warning
|
||||
ssize_t sz;
|
||||
^
|
||||
= 0
|
||||
1 error generated.
|
||||
|
||||
Fixes: c41da0bd ("Handle /sys/devices/virtual/{nvme-fabrics,nvme-subsystem} devices")
|
||||
|
||||
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
---
|
||||
src/linux-virtual-root.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/linux-virtual-root.c b/src/linux-virtual-root.c
|
||||
index 75fbbfc1de6..2d39c28ebb6 100644
|
||||
--- a/src/linux-virtual-root.c
|
||||
+++ b/src/linux-virtual-root.c
|
||||
@@ -42,7 +42,7 @@ static ssize_t
|
||||
parse_virtual_root(struct device *dev UNUSED, const char *current, const char *root UNUSED)
|
||||
{
|
||||
int rc;
|
||||
- ssize_t sz;
|
||||
+ ssize_t sz = 0;
|
||||
int pos0 = 0, pos1 = 0;
|
||||
struct subdir {
|
||||
const char * const name;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,45 +0,0 @@
|
||||
From 3cf3b3d5cf3f6ff7ddb315676e338a0632aa6dc8 Mon Sep 17 00:00:00 2001
|
||||
From: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
Date: Wed, 22 Jan 2020 12:19:35 +0800
|
||||
Subject: [PATCH 68/86] Fix an argument mismatch error
|
||||
|
||||
MSDOS_MBR_MAGIC is an int, no need to specify the 'h' (unsigned short)
|
||||
modifier. This avoids the error (built with clang):
|
||||
|
||||
external/efivar/src/disk.c:59:18: error: format specifies type 'unsigned short' but the argument has type 'int' [-Werror,-Wformat]
|
||||
mbr->magic, MSDOS_MBR_MAGIC);
|
||||
^~~~~~~~~~~~~~~
|
||||
external/efivar/src/include/efivar/efivar.h:244:66: note: expanded from macro 'efi_error'
|
||||
efi_error_real__(errno, __FILE__, __func__, __LINE__, (fmt), ## args)
|
||||
^~~~
|
||||
external/efivar/src/include/efivar/efivar.h:241:56: note: expanded from macro 'efi_error_real__'
|
||||
efi_error_set(file, function, line, errval, (fmt), ## args)
|
||||
^~~~
|
||||
external/efivar/src/gpt.h:32:25: note: expanded from macro 'MSDOS_MBR_MAGIC'
|
||||
#define MSDOS_MBR_MAGIC 0xaa55
|
||||
^~~~~~
|
||||
1 error generated.
|
||||
|
||||
Fixes: 038afd7a ("Always refer to MBR and GPT fixed values as 'magic' not 'signature'")
|
||||
|
||||
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
---
|
||||
src/disk.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/disk.c b/src/disk.c
|
||||
index 3b5bf8330b1..2eaf57436a2 100644
|
||||
--- a/src/disk.c
|
||||
+++ b/src/disk.c
|
||||
@@ -55,7 +55,7 @@ is_mbr_valid(legacy_mbr *mbr)
|
||||
ret = (mbr->magic == MSDOS_MBR_MAGIC);
|
||||
if (!ret) {
|
||||
errno = ENOTTY;
|
||||
- efi_error("mbr magic is 0x%04hx not MSDOS_MBR_MAGIC (0x%04hx)",
|
||||
+ efi_error("mbr magic is 0x%04hx not MSDOS_MBR_MAGIC (0x%04x)",
|
||||
mbr->magic, MSDOS_MBR_MAGIC);
|
||||
}
|
||||
return ret;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,66 +0,0 @@
|
||||
From 301bf0d2968136df30bcd6ae9f294e504ec347a8 Mon Sep 17 00:00:00 2001
|
||||
From: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
Date: Wed, 22 Jan 2020 12:26:27 +0800
|
||||
Subject: [PATCH 69/86] Android: fix building errors
|
||||
|
||||
Android bionic doesn't have cookie_io_functions_t, memfd_create and
|
||||
fopencookie yet. So just disable the debug feature.
|
||||
|
||||
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
|
||||
---
|
||||
src/error.c | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/error.c b/src/error.c
|
||||
index b1a56ef629c..f865bb61e51 100644
|
||||
--- a/src/error.c
|
||||
+++ b/src/error.c
|
||||
@@ -166,10 +166,12 @@ efi_error_pop(void)
|
||||
|
||||
static int efi_verbose;
|
||||
static FILE *efi_errlog, *efi_dbglog;
|
||||
+#ifndef ANDROID
|
||||
static int efi_dbglog_fd = -1;
|
||||
static intptr_t efi_dbglog_cookie;
|
||||
-static int log_level;
|
||||
static char efi_dbglog_buf[4096];
|
||||
+#endif
|
||||
+static int log_level;
|
||||
|
||||
void PUBLIC
|
||||
efi_set_loglevel(int level)
|
||||
@@ -177,6 +179,7 @@ efi_set_loglevel(int level)
|
||||
log_level = level;
|
||||
}
|
||||
|
||||
+#ifndef ANDROID
|
||||
static ssize_t
|
||||
dbglog_write(void *cookie, const char *buf, size_t size)
|
||||
{
|
||||
@@ -226,6 +229,7 @@ dbglog_close(void *cookie UNUSED)
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
+#endif
|
||||
|
||||
void PUBLIC
|
||||
efi_error_clear(void)
|
||||
@@ -255,6 +259,7 @@ efi_error_fini(void)
|
||||
static void CONSTRUCTOR
|
||||
efi_error_init(void)
|
||||
{
|
||||
+#ifndef ANDROID
|
||||
ssize_t bytes;
|
||||
cookie_io_functions_t io_funcs = {
|
||||
.write = dbglog_write,
|
||||
@@ -274,6 +279,7 @@ efi_error_init(void)
|
||||
if (efi_dbglog)
|
||||
setvbuf(efi_dbglog, efi_dbglog_buf, _IOLBF,
|
||||
sizeof(efi_dbglog_buf));
|
||||
+#endif
|
||||
}
|
||||
|
||||
FILE PUBLIC *
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,49 +0,0 @@
|
||||
From db5e7f4244150b108970093fdc97072934e2bf2a Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 29 Jan 2020 13:15:51 -0500
|
||||
Subject: [PATCH 70/86] Fix the MSDOS_MBR_MAGIC type, not the format string.
|
||||
|
||||
The value of MSDOS_MBR_MAGIC is 16 bits; make it evaluate that way,
|
||||
instead of promoting it to int for efi_error() formatting.
|
||||
|
||||
Fixes: 3cf3b3d5cf3f6ff7ddb315676e338a0632aa6dc8
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/disk.c | 2 +-
|
||||
src/gpt.h | 6 +++---
|
||||
2 files changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/disk.c b/src/disk.c
|
||||
index 2eaf57436a2..3b5bf8330b1 100644
|
||||
--- a/src/disk.c
|
||||
+++ b/src/disk.c
|
||||
@@ -55,7 +55,7 @@ is_mbr_valid(legacy_mbr *mbr)
|
||||
ret = (mbr->magic == MSDOS_MBR_MAGIC);
|
||||
if (!ret) {
|
||||
errno = ENOTTY;
|
||||
- efi_error("mbr magic is 0x%04hx not MSDOS_MBR_MAGIC (0x%04x)",
|
||||
+ efi_error("mbr magic is 0x%04hx not MSDOS_MBR_MAGIC (0x%04hx)",
|
||||
mbr->magic, MSDOS_MBR_MAGIC);
|
||||
}
|
||||
return ret;
|
||||
diff --git a/src/gpt.h b/src/gpt.h
|
||||
index 66fbc21106c..45a048b21e1 100644
|
||||
--- a/src/gpt.h
|
||||
+++ b/src/gpt.h
|
||||
@@ -27,9 +27,9 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
-#define EFI_PMBR_OSTYPE_EFI 0xEF
|
||||
-#define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
|
||||
-#define MSDOS_MBR_MAGIC 0xaa55
|
||||
+#define EFI_PMBR_OSTYPE_EFI ((uint8_t)0xEF)
|
||||
+#define EFI_PMBR_OSTYPE_EFI_GPT ((uint8_t)0xEE)
|
||||
+#define MSDOS_MBR_MAGIC ((uint16_t)0xaa55)
|
||||
#define GPT_BLOCK_SIZE 512
|
||||
|
||||
#define GPT_HEADER_MAGIC ((uint64_t)(0x5452415020494645ULL))
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,174 +0,0 @@
|
||||
From 2bec15e310de37398cf5bb8135f15d15ab2bb54b Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 29 Jan 2020 15:35:17 -0500
|
||||
Subject: [PATCH 71/86] Make scan-build and CC=clang work again.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/Makefile | 3 +++
|
||||
src/include/defaults.mk | 58 ++++++++++++++++++++++++++++++++---------
|
||||
src/include/deps.mk | 4 +--
|
||||
src/include/rules.mk | 2 --
|
||||
4 files changed, 50 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index 1d0e217c89b..144289d4709 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -53,8 +53,11 @@ include/efivar/efivar-guids.h : makeguids guids.txt
|
||||
|
||||
makeguids : CPPFLAGS=$(HOST_CPPFLAGS)
|
||||
makeguids : LIBS=dl
|
||||
+makeguids : CC=$(HOSTCC)
|
||||
makeguids : CCLD=$(HOSTCCLD)
|
||||
makeguids : CFLAGS=$(HOST_CFLAGS)
|
||||
+makeguids : LDFLAGS=$(HOST_LDFLAGS)
|
||||
+makeguids : CCLDFLAGS=$(HOST_CCLDFLAGS)
|
||||
makeguids : $(MAKEGUIDS_SOURCES)
|
||||
|
||||
guids.o : guids.S | guids.bin names.bin
|
||||
diff --git a/src/include/defaults.mk b/src/include/defaults.mk
|
||||
index 781587b4215..bc515e36305 100644
|
||||
--- a/src/include/defaults.mk
|
||||
+++ b/src/include/defaults.mk
|
||||
@@ -9,13 +9,18 @@ PCDIR ?= $(LIBDIR)/pkgconfig
|
||||
DESTDIR ?=
|
||||
|
||||
CROSS_COMPILE ?=
|
||||
-COMPILER ?= gcc
|
||||
+COMPILER ?= gcc
|
||||
+ifeq ($(origin CC),command line)
|
||||
+override COMPILER := $(CC)
|
||||
+override CC := $(CROSS_COMPILE)$(COMPILER)
|
||||
+endif
|
||||
$(call set-if-undefined,CC,$(CROSS_COMPILE)$(COMPILER))
|
||||
$(call set-if-undefined,CCLD,$(CC))
|
||||
$(call set-if-undefined,HOSTCC,$(COMPILER))
|
||||
$(call set-if-undefined,HOSTCCLD,$(HOSTCC))
|
||||
|
||||
-OPTIMIZE ?= -O2 -flto
|
||||
+OPTIMIZE_GCC = -flto
|
||||
+OPTIMIZE ?= -O2 $(call family,OPTIMIZE)
|
||||
DEBUGINFO ?= -g3
|
||||
WARNINGS_GCC ?= -Wmaybe-uninitialized \
|
||||
-Wno-nonnull-compare
|
||||
@@ -30,7 +35,7 @@ override _CPPFLAGS := $(CPPFLAGS)
|
||||
override CPPFLAGS = $(_CPPFLAGS) -DLIBEFIVAR_VERSION=$(VERSION) \
|
||||
-D_GNU_SOURCE \
|
||||
-I$(TOPDIR)/src/include/
|
||||
-CFLAGS ?= $(OPTIMIZE) $(DEBUGINFO) $(WARNINGS) $(ERRORS)
|
||||
+CFLAGS ?= $(FULL_OPTIMIZE) $(DEBUGINFO) $(WARNINGS) $(ERRORS)
|
||||
CFLAGS_GCC ?= -specs=$(TOPDIR)/src/include/gcc.specs \
|
||||
-fno-merge-constants
|
||||
override _CFLAGS := $(CFLAGS)
|
||||
@@ -40,22 +45,32 @@ override CFLAGS = $(_CFLAGS) \
|
||||
-fvisibility=hidden \
|
||||
$(call family,CFLAGS) \
|
||||
$(call pkg-config-cflags)
|
||||
-LDFLAGS_CLANG ?= -Wl,--fatal-warnings,-pie,-z,relro
|
||||
+LDFLAGS_CLANG ?= -rtlib=compiler-rt
|
||||
+CCLDFLAGS ?=
|
||||
LDFLAGS ?=
|
||||
+override _CCLDFLAGS := $(CCLDFLAGS)
|
||||
override _LDFLAGS := $(LDFLAGS)
|
||||
-override LDFLAGS = $(_LDFLAGS) \
|
||||
+override LDFLAGS = $(CFLAGS) -L. $(_LDFLAGS) $(_CCLDFLAGS) \
|
||||
-Wl,--add-needed \
|
||||
-Wl,--build-id \
|
||||
-Wl,--no-allow-shlib-undefined \
|
||||
-Wl,--no-undefined-version \
|
||||
-Wl,-z,now \
|
||||
-Wl,-z,muldefs \
|
||||
- $(call family,LDFLAGS)
|
||||
-CCLDFLAGS ?=
|
||||
-override _CCLDFLAGS := $(CCLDFLAGS)
|
||||
-override CCLDFLAGS = $(CFLAGS) -L. $(_CCLDFLAGS) \
|
||||
- $(LDFLAGS) \
|
||||
- $(call pkg-config-ccldflags)
|
||||
+ -Wl,-z,relro \
|
||||
+ -Wl,--fatal-warnings \
|
||||
+ $(call family,LDFLAGS) $(call family,CCLDFLAGS) \
|
||||
+ $(call pkg-config-ccldflags)
|
||||
+override CCLDFLAGS = $(LDFLAGS)
|
||||
+SOFLAGS_GCC =
|
||||
+SOFLAGS_CLANG =
|
||||
+SOFLAGS ?=
|
||||
+override _SOFLAGS := $(SOFLAGS)
|
||||
+override SOFLAGS = $(_SOFLAGS) \
|
||||
+ -shared -Wl,-soname,$@.1 \
|
||||
+ -Wl,--version-script=$(MAP) \
|
||||
+ $(call family,SOFLAGS)
|
||||
+
|
||||
HOST_ARCH=$(shell uname -m)
|
||||
ifneq ($(HOST_ARCH),ia64)
|
||||
HOST_MARCH=-march=native
|
||||
@@ -66,9 +81,27 @@ HOST_CPPFLAGS ?= $(CPPFLAGS)
|
||||
override _HOST_CPPFLAGS := $(HOST_CPPFLAGS)
|
||||
override HOST_CPPFLAGS = $(_HOST_CPPFLAGS) \
|
||||
-DEFIVAR_BUILD_ENVIRONMENT $(HOST_MARCH)
|
||||
-HOST_CFLAGS ?= $(CFLAGS)
|
||||
+HOST_CFLAGS_CLANG ?=
|
||||
+HOST_CFLAGS ?= $(CFLAGS) $(call family,HOST_CFLAGS)
|
||||
override _HOST_CFLAGS := $(HOST_CFLAGS)
|
||||
override HOST_CFLAGS = $(_HOST_CFLAGS)
|
||||
+HOST_LDFLAGS_CLANG ?= -Wl,--fatal-warnings,-z,relro -rtlib=compiler-rt
|
||||
+HOST_LDFLAGS_GCC ?= -Wl,--no-undefined-version
|
||||
+HOST_LDFLAGS ?=
|
||||
+HOST_CCLDFLAGS ?=
|
||||
+override _HOST_LDFLAGS := $(HOST_LDFLAGS)
|
||||
+override _HOST_CCLDFLAGS := $(HOST_CCLDFLAGS)
|
||||
+override HOST_LDFLAGS = $(HOST_CFLAGS) -L. \
|
||||
+ $(_HOST_LDFLAGS) $(_HOST_CCLDFLAGS) \
|
||||
+ -Wl,--add-needed \
|
||||
+ -Wl,--build-id \
|
||||
+ -Wl,--no-allow-shlib-undefined \
|
||||
+ -Wl,-z,now \
|
||||
+ -Wl,-z,muldefs \
|
||||
+ $(call family,HOST_LDFLAGS) \
|
||||
+ $(call family,HOST_CCLDFLAGS) \
|
||||
+ $(call pkg-config-ccldflags)
|
||||
+override HOST_CCLDFLAGS = $(HOST_LDFLAGS)
|
||||
|
||||
PKG_CONFIG = $(shell if [ -e "$$(env $(CROSS_COMPILE)pkg-config 2>&1)" ]; then echo $(CROSS_COMPILE)pkg-config ; else echo pkg-config ; fi)
|
||||
INSTALL ?= install
|
||||
@@ -80,7 +113,6 @@ ABIDIFF := abidiff
|
||||
|
||||
PKGS =
|
||||
|
||||
-SOFLAGS=-shared $(call family,SOFLAGS)
|
||||
LDLIBS=$(foreach lib,$(LIBS),-l$(lib)) $(call pkg-config-ldlibs)
|
||||
|
||||
COMMIT_ID=$(shell git log -1 --pretty=%H 2>/dev/null || echo master)
|
||||
diff --git a/src/include/deps.mk b/src/include/deps.mk
|
||||
index a797d1bdbf5..3c8243144dc 100644
|
||||
--- a/src/include/deps.mk
|
||||
+++ b/src/include/deps.mk
|
||||
@@ -7,10 +7,10 @@ include $(TOPDIR)/src/include/rules.mk
|
||||
include $(TOPDIR)/src/include/defaults.mk
|
||||
|
||||
.%.d : %.c
|
||||
- $(CC) $(cflags) $(CPPFLAGS) -MM -MG -MF $@ $^
|
||||
+ $(CC) $(CFLAGS) $(CPPFLAGS) -MM -MG -MF $@ $^
|
||||
|
||||
.%.d : %.S
|
||||
- $(CC) $(cflags) $(CPPFLAGS) -MM -MG -MF $@ $^
|
||||
+ $(CC) $(CFLAGS) $(CPPFLAGS) -MM -MG -MF $@ $^
|
||||
|
||||
SOURCES ?=
|
||||
|
||||
diff --git a/src/include/rules.mk b/src/include/rules.mk
|
||||
index ff0ff4ef61b..99a6329e3fe 100644
|
||||
--- a/src/include/rules.mk
|
||||
+++ b/src/include/rules.mk
|
||||
@@ -30,8 +30,6 @@ family = $(foreach FAMILY_SUFFIX,$(FAMILY_SUFFIXES),$($(1)_$(FAMILY_SUFFIX)))
|
||||
|
||||
%.so :
|
||||
$(CCLD) $(CCLDFLAGS) $(CPPFLAGS) $(SOFLAGS) \
|
||||
- -Wl,-soname,$@.1 \
|
||||
- -Wl,--version-script=$(MAP) \
|
||||
-o $@ $^ $(LDLIBS)
|
||||
ln -vfs $@ $@.1
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,42 +0,0 @@
|
||||
From 025e71fb477bfc227d1ba59b85ee8153703cc4a3 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Thu, 30 Jan 2020 10:35:35 -0500
|
||||
Subject: [PATCH 72/86] Remove a dead store.
|
||||
|
||||
ccc-analyzer noticed:
|
||||
|
||||
Bug Group Bug Type File Function/Method Line Path Length
|
||||
Dead store Dead increment linux-nvme.c parse_nvme 89 1
|
||||
|
||||
Which is a "sz += ..." I accidentally left in when I switched all the
|
||||
file path parsers to just using the string pointer "current" and
|
||||
subtracting it from "path" at the end.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/linux-nvme.c | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
diff --git a/src/linux-nvme.c b/src/linux-nvme.c
|
||||
index d0941e85e08..33edcd4fc7d 100644
|
||||
--- a/src/linux-nvme.c
|
||||
+++ b/src/linux-nvme.c
|
||||
@@ -61,7 +61,6 @@ parse_nvme(struct device *dev, const char *path, const char *root UNUSED)
|
||||
int32_t tosser0, tosser1, tosser2, ctrl_id, ns_id, partition;
|
||||
uint8_t *filebuf = NULL;
|
||||
int pos0 = -1, pos1 = -1, pos2 = -1;
|
||||
- ssize_t sz = 0;
|
||||
struct subdir {
|
||||
const char * const name;
|
||||
const char * const fmt;
|
||||
@@ -86,7 +85,6 @@ parse_nvme(struct device *dev, const char *path, const char *root UNUSED)
|
||||
*subdirs[i].pos0, *subdirs[i].pos1);
|
||||
dbgmk(" ", *subdirs[i].pos0, *subdirs[i].pos1);
|
||||
if (*subdirs[i].pos0 >= 0 && *subdirs[i].pos1 >= *subdirs[i].pos0) {
|
||||
- sz += *subdirs[i].pos1;
|
||||
current += *subdirs[i].pos1;
|
||||
break;
|
||||
}
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,38 +0,0 @@
|
||||
From f4952ecf70ab6de206d63f24d050f4303eccce45 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Thu, 30 Jan 2020 10:47:11 -0500
|
||||
Subject: [PATCH 73/86] makeguids: confuse ccc-analyzer less.
|
||||
|
||||
Putting the non-NULL and non-NUL tests inside the loop confuses
|
||||
ccc-analyzer into thinking it might be NULL later when we pass it to
|
||||
strchr().
|
||||
|
||||
It can't, but I like a clean scan.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/makeguids.c | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/makeguids.c b/src/makeguids.c
|
||||
index f12dac3bb15..c0a9db1509c 100644
|
||||
--- a/src/makeguids.c
|
||||
+++ b/src/makeguids.c
|
||||
@@ -141,9 +141,11 @@ main(int argc, char *argv[])
|
||||
|
||||
char *guidstr = inbuf;
|
||||
unsigned int line;
|
||||
- for (line = 1; (uintptr_t)guidstr - (uintptr_t)inbuf < inlen; line++) {
|
||||
- if (guidstr && guidstr[0] == '\0')
|
||||
- break;
|
||||
+ for (line = 1;
|
||||
+ guidstr && guidstr[0] != '\0' &&
|
||||
+ (uintptr_t)guidstr - (uintptr_t)inbuf < inlen;
|
||||
+ line++) {
|
||||
+
|
||||
outbuf = realloc(outbuf, line * sizeof (struct guidname));
|
||||
if (!outbuf)
|
||||
err(1, "makeguids");
|
||||
--
|
||||
2.24.1
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,25 +0,0 @@
|
||||
From 46c0623dad819a75ed479ac2576ce836a2dda2a6 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 3 Feb 2020 11:30:33 -0500
|
||||
Subject: [PATCH 75/86] Makefile: minor typo fix.
|
||||
|
||||
---
|
||||
src/Makefile | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index 144289d4709..0783cb3b55f 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -115,7 +115,7 @@ test : all
|
||||
|
||||
.PHONY: test deps abiclean abixml
|
||||
.SECONDARY : libefivar.so.1.$(VERSION) libefivar.so.1
|
||||
-.SECONDARY : libefiboot.so.1.$(VERSION) libefivar.so.1
|
||||
+.SECONDARY : libefiboot.so.1.$(VERSION) libefiboot.so.1
|
||||
.SECONDARY : include/efivar/efivar-guids.h guid-symbols.c
|
||||
.INTERMEDIATE : guids.bin names.bin
|
||||
.PRECIOUS : guid-symbols.o makeguids
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,135 +0,0 @@
|
||||
From c6122e960a412dd181dbea3ef0559640139a3c26 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Thu, 30 Jan 2020 13:54:34 -0500
|
||||
Subject: [PATCH 76/86] util.h: minor whitespace cleanup
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/util.h | 102 ++++++++++++++++++++++++++---------------------------
|
||||
1 file changed, 51 insertions(+), 51 deletions(-)
|
||||
|
||||
diff --git a/src/util.h b/src/util.h
|
||||
index 4791223d962..b7b03931d7e 100644
|
||||
--- a/src/util.h
|
||||
+++ b/src/util.h
|
||||
@@ -144,66 +144,66 @@ lcm(uint64_t x, uint64_t y)
|
||||
}
|
||||
|
||||
#ifndef strdupa
|
||||
-#define strdupa(s) \
|
||||
- (__extension__ ({ \
|
||||
- const char *__in = (s); \
|
||||
- size_t __len = strlen (__in); \
|
||||
- char *__out = (char *) alloca (__len + 1); \
|
||||
- strcpy(__out, __in); \
|
||||
- __out; \
|
||||
+#define strdupa(s) \
|
||||
+ (__extension__ ({ \
|
||||
+ const char *__in = (s); \
|
||||
+ size_t __len = strlen (__in); \
|
||||
+ char *__out = (char *) alloca (__len + 1); \
|
||||
+ strcpy(__out, __in); \
|
||||
+ __out; \
|
||||
}))
|
||||
#endif
|
||||
|
||||
#ifndef strndupa
|
||||
-#define strndupa(s, l) \
|
||||
- (__extension__ ({ \
|
||||
- const char *__in = (s); \
|
||||
- size_t __len = strnlen (__in, (l)); \
|
||||
- char *__out = (char *) alloca (__len + 1); \
|
||||
- strncpy(__out, __in, __len); \
|
||||
- __out[__len] = '\0'; \
|
||||
- __out; \
|
||||
+#define strndupa(s, l) \
|
||||
+ (__extension__ ({ \
|
||||
+ const char *__in = (s); \
|
||||
+ size_t __len = strnlen (__in, (l)); \
|
||||
+ char *__out = (char *) alloca (__len + 1); \
|
||||
+ strncpy(__out, __in, __len); \
|
||||
+ __out[__len] = '\0'; \
|
||||
+ __out; \
|
||||
}))
|
||||
#endif
|
||||
|
||||
-#define asprintfa(str, fmt, args...) \
|
||||
- ({ \
|
||||
- char *_tmp = NULL; \
|
||||
- int _rc; \
|
||||
- *(str) = NULL; \
|
||||
- _rc = asprintf((str), (fmt), ## args); \
|
||||
- if (_rc > 0) { \
|
||||
- _tmp = strdupa(*(str)); \
|
||||
- if (!_tmp) { \
|
||||
- _rc = -1; \
|
||||
- } else { \
|
||||
- free(*(str)); \
|
||||
- *(str) = _tmp; \
|
||||
- } \
|
||||
- } else { \
|
||||
- _rc = -1; \
|
||||
- } \
|
||||
- _rc; \
|
||||
+#define asprintfa(str, fmt, args...) \
|
||||
+ ({ \
|
||||
+ char *_tmp = NULL; \
|
||||
+ int _rc; \
|
||||
+ *(str) = NULL; \
|
||||
+ _rc = asprintf((str), (fmt), ## args); \
|
||||
+ if (_rc > 0) { \
|
||||
+ _tmp = strdupa(*(str)); \
|
||||
+ if (!_tmp) { \
|
||||
+ _rc = -1; \
|
||||
+ } else { \
|
||||
+ free(*(str)); \
|
||||
+ *(str) = _tmp; \
|
||||
+ } \
|
||||
+ } else { \
|
||||
+ _rc = -1; \
|
||||
+ } \
|
||||
+ _rc; \
|
||||
})
|
||||
|
||||
-#define vasprintfa(str, fmt, ap) \
|
||||
- ({ \
|
||||
- char *_tmp = NULL; \
|
||||
- int _rc; \
|
||||
- *(str) = NULL; \
|
||||
- _rc = vasprintf((str), (fmt), (ap)); \
|
||||
- if (_rc > 0) { \
|
||||
- _tmp = strdupa(*(str)); \
|
||||
- if (!_tmp) { \
|
||||
- _rc = -1; \
|
||||
- } else { \
|
||||
- free(*(str)); \
|
||||
- *(str) = _tmp; \
|
||||
- } \
|
||||
- } else { \
|
||||
- _rc = -1; \
|
||||
- } \
|
||||
- _rc; \
|
||||
+#define vasprintfa(str, fmt, ap) \
|
||||
+ ({ \
|
||||
+ char *_tmp = NULL; \
|
||||
+ int _rc; \
|
||||
+ *(str) = NULL; \
|
||||
+ _rc = vasprintf((str), (fmt), (ap)); \
|
||||
+ if (_rc > 0) { \
|
||||
+ _tmp = strdupa(*(str)); \
|
||||
+ if (!_tmp) { \
|
||||
+ _rc = -1; \
|
||||
+ } else { \
|
||||
+ free(*(str)); \
|
||||
+ *(str) = _tmp; \
|
||||
+ } \
|
||||
+ } else { \
|
||||
+ _rc = -1; \
|
||||
+ } \
|
||||
+ _rc; \
|
||||
})
|
||||
|
||||
static inline ssize_t
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,54 +0,0 @@
|
||||
From 07fbba7acf9c757a3ae8192a64cb3a1f631c5f74 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Thu, 30 Jan 2020 13:57:18 -0500
|
||||
Subject: [PATCH 77/86] util.h: make strdupa() and strndupa() pass NULL
|
||||
straight through.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/util.h | 22 +++++++++++++++-------
|
||||
1 file changed, 15 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/util.h b/src/util.h
|
||||
index b7b03931d7e..f4c6c27cc73 100644
|
||||
--- a/src/util.h
|
||||
+++ b/src/util.h
|
||||
@@ -147,9 +147,13 @@ lcm(uint64_t x, uint64_t y)
|
||||
#define strdupa(s) \
|
||||
(__extension__ ({ \
|
||||
const char *__in = (s); \
|
||||
- size_t __len = strlen (__in); \
|
||||
- char *__out = (char *) alloca (__len + 1); \
|
||||
- strcpy(__out, __in); \
|
||||
+ size_t __len; \
|
||||
+ char *__out = NULL; \
|
||||
+ if (__in) { \
|
||||
+ __len = strlen (__in); \
|
||||
+ __out = (char *) alloca (__len + 1); \
|
||||
+ strcpy(__out, __in); \
|
||||
+ } \
|
||||
__out; \
|
||||
}))
|
||||
#endif
|
||||
@@ -158,10 +162,14 @@ lcm(uint64_t x, uint64_t y)
|
||||
#define strndupa(s, l) \
|
||||
(__extension__ ({ \
|
||||
const char *__in = (s); \
|
||||
- size_t __len = strnlen (__in, (l)); \
|
||||
- char *__out = (char *) alloca (__len + 1); \
|
||||
- strncpy(__out, __in, __len); \
|
||||
- __out[__len] = '\0'; \
|
||||
+ size_t __len; \
|
||||
+ char *__out = NULL; \
|
||||
+ if (__in) { \
|
||||
+ __len = strnlen (__in, (l)); \
|
||||
+ __out = (char *) alloca (__len + 1); \
|
||||
+ strncpy(__out, __in, __len); \
|
||||
+ __out[__len] = '\0'; \
|
||||
+ } \
|
||||
__out; \
|
||||
}))
|
||||
#endif
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,26 +0,0 @@
|
||||
From 0e42eb90521c8cd4f67196c6620c0672c1106f2c Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 18 Feb 2020 18:03:13 -0500
|
||||
Subject: [PATCH 78/86] Update travis to use a newer distro.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
.travis.yml | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/.travis.yml b/.travis.yml
|
||||
index 0b1fa856fd6..f651234da83 100644
|
||||
--- a/.travis.yml
|
||||
+++ b/.travis.yml
|
||||
@@ -7,7 +7,7 @@ branches:
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
- dist: trusty
|
||||
+ dist: bionic
|
||||
services: docker
|
||||
|
||||
before_install:
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,199 +0,0 @@
|
||||
From 2117a21fed77fc4cb66da7fc4441af4c871f2ccf Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 3 Feb 2020 13:24:30 -0500
|
||||
Subject: [PATCH 79/86] efivar: Split types and guids out into a different
|
||||
header.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/export.c | 8 ----
|
||||
src/include/efivar/efivar-types.h | 64 +++++++++++++++++++++++++++++++
|
||||
src/include/efivar/efivar.h | 44 +--------------------
|
||||
src/lib.h | 8 ++++
|
||||
src/libefivar.map.in | 1 +
|
||||
5 files changed, 74 insertions(+), 51 deletions(-)
|
||||
create mode 100644 src/include/efivar/efivar-types.h
|
||||
|
||||
diff --git a/src/export.c b/src/export.c
|
||||
index 30f706484ab..c65002cd100 100644
|
||||
--- a/src/export.c
|
||||
+++ b/src/export.c
|
||||
@@ -18,14 +18,6 @@
|
||||
#define ATTRS_UNSET 0xa5a5a5a5a5a5a5a5
|
||||
#define ATTRS_MASK 0xffffffff
|
||||
|
||||
-struct efi_variable {
|
||||
- uint64_t attrs;
|
||||
- efi_guid_t *guid;
|
||||
- unsigned char *name;
|
||||
- uint8_t *data;
|
||||
- size_t data_size;
|
||||
-};
|
||||
-
|
||||
/* The exported structure is:
|
||||
* struct {
|
||||
* uint32_t magic;
|
||||
diff --git a/src/include/efivar/efivar-types.h b/src/include/efivar/efivar-types.h
|
||||
new file mode 100644
|
||||
index 00000000000..6fca8a495f4
|
||||
--- /dev/null
|
||||
+++ b/src/include/efivar/efivar-types.h
|
||||
@@ -0,0 +1,64 @@
|
||||
+// SPDX-License-Identifier: LGPL-2.1
|
||||
+/*
|
||||
+ * Copyright 2012-2020 Red Hat, Inc.
|
||||
+ * Copyright 2012-2020 Peter M. Jones <pjones@redhat.com>
|
||||
+ *
|
||||
+ * Author(s): Peter Jones <pjones@redhat.com>
|
||||
+ */
|
||||
+#ifndef EFI_TYPES_H
|
||||
+#define EFI_TYPES_H 1
|
||||
+
|
||||
+#include <stdint.h>
|
||||
+
|
||||
+typedef struct {
|
||||
+ uint32_t a;
|
||||
+ uint16_t b;
|
||||
+ uint16_t c;
|
||||
+ uint16_t d;
|
||||
+ uint8_t e[6];
|
||||
+} efi_guid_t __attribute__((__aligned__(1)));
|
||||
+
|
||||
+#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
+#define EFI_GUID(a,b,c,d,e0,e1,e2,e3,e4,e5) \
|
||||
+((efi_guid_t) {(a), (b), (c), __builtin_bswap16(d), { (e0), (e1), (e2), (e3), (e4), (e5) }})
|
||||
+#else
|
||||
+#define EFI_GUID(a,b,c,d,e0,e1,e2,e3,e4,e5) \
|
||||
+((efi_guid_t) {(a), (b), (c), (d), { (e0), (e1), (e2), (e3), (e4), (e5) }})
|
||||
+#endif
|
||||
+
|
||||
+#define EFI_GLOBAL_GUID EFI_GUID(0x8be4df61,0x93ca,0x11d2,0xaa0d,0x00,0xe0,0x98,0x03,0x2b,0x8c)
|
||||
+
|
||||
+typedef struct {
|
||||
+ uint8_t addr[4];
|
||||
+} efi_ipv4_addr_t;
|
||||
+
|
||||
+typedef struct {
|
||||
+ uint8_t addr[16];
|
||||
+} efi_ipv6_addr_t;
|
||||
+
|
||||
+typedef union {
|
||||
+ uint32_t addr[4];
|
||||
+ efi_ipv4_addr_t v4;
|
||||
+ efi_ipv6_addr_t v6;
|
||||
+} efi_ip_addr_t;
|
||||
+
|
||||
+typedef struct {
|
||||
+ uint8_t addr[32];
|
||||
+} efi_mac_addr_t;
|
||||
+
|
||||
+typedef unsigned long efi_status_t;
|
||||
+typedef uint16_t efi_char16_t;
|
||||
+typedef unsigned long uintn_t;
|
||||
+typedef long intn_t;
|
||||
+
|
||||
+#define EFI_VARIABLE_NON_VOLATILE ((uint64_t)0x0000000000000001)
|
||||
+#define EFI_VARIABLE_BOOTSERVICE_ACCESS ((uint64_t)0x0000000000000002)
|
||||
+#define EFI_VARIABLE_RUNTIME_ACCESS ((uint64_t)0x0000000000000004)
|
||||
+#define EFI_VARIABLE_HARDWARE_ERROR_RECORD ((uint64_t)0x0000000000000008)
|
||||
+#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS ((uint64_t)0x0000000000000010)
|
||||
+#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS ((uint64_t)0x0000000000000020)
|
||||
+#define EFI_VARIABLE_APPEND_WRITE ((uint64_t)0x0000000000000040)
|
||||
+#define EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS ((uint64_t)0x0000000000000080)
|
||||
+
|
||||
+#endif /* EFI_TYPES_H */
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
|
||||
index cc5dcc5657a..6b38ce8faf4 100644
|
||||
--- a/src/include/efivar/efivar.h
|
||||
+++ b/src/include/efivar/efivar.h
|
||||
@@ -17,54 +17,12 @@
|
||||
#include <unistd.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
-typedef struct {
|
||||
- uint32_t a;
|
||||
- uint16_t b;
|
||||
- uint16_t c;
|
||||
- uint16_t d;
|
||||
- uint8_t e[6];
|
||||
-} efi_guid_t __attribute__((__aligned__(1)));
|
||||
-
|
||||
-typedef struct {
|
||||
- uint8_t addr[4];
|
||||
-} efi_ipv4_addr_t;
|
||||
-
|
||||
-typedef struct {
|
||||
- uint8_t addr[16];
|
||||
-} efi_ipv6_addr_t;
|
||||
-
|
||||
-typedef union {
|
||||
- uint32_t addr[4];
|
||||
- efi_ipv4_addr_t v4;
|
||||
- efi_ipv6_addr_t v6;
|
||||
-} efi_ip_addr_t;
|
||||
-
|
||||
-typedef struct {
|
||||
- uint8_t addr[32];
|
||||
-} efi_mac_addr_t;
|
||||
+#include <efivar/efivar-types.h>
|
||||
|
||||
#ifndef EFIVAR_BUILD_ENVIRONMENT
|
||||
#include <efivar/efivar-guids.h>
|
||||
#endif
|
||||
|
||||
-#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
-#define EFI_GUID(a,b,c,d,e0,e1,e2,e3,e4,e5) \
|
||||
-((efi_guid_t) {(a), (b), (c), __builtin_bswap16(d), { (e0), (e1), (e2), (e3), (e4), (e5) }})
|
||||
-#else
|
||||
-#define EFI_GUID(a,b,c,d,e0,e1,e2,e3,e4,e5) \
|
||||
-((efi_guid_t) {(a), (b), (c), (d), { (e0), (e1), (e2), (e3), (e4), (e5) }})
|
||||
-#endif
|
||||
-
|
||||
-#define EFI_GLOBAL_GUID EFI_GUID(0x8be4df61,0x93ca,0x11d2,0xaa0d,0x00,0xe0,0x98,0x03,0x2b,0x8c)
|
||||
-
|
||||
-#define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
|
||||
-#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
|
||||
-#define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004
|
||||
-#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008
|
||||
-#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010
|
||||
-#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020
|
||||
-#define EFI_VARIABLE_APPEND_WRITE 0x0000000000000040
|
||||
-
|
||||
#define EFI_VARIABLE_HAS_AUTH_HEADER 0x0000000100000000
|
||||
#define EFI_VARIABLE_HAS_SIGNATURE 0x0000000200000000
|
||||
|
||||
diff --git a/src/lib.h b/src/lib.h
|
||||
index 26e0f169bd1..21ebc9a818a 100644
|
||||
--- a/src/lib.h
|
||||
+++ b/src/lib.h
|
||||
@@ -12,6 +12,14 @@
|
||||
|
||||
#define GUID_FORMAT "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x"
|
||||
|
||||
+struct efi_variable {
|
||||
+ uint64_t attrs;
|
||||
+ efi_guid_t *guid;
|
||||
+ unsigned char *name;
|
||||
+ uint8_t *data;
|
||||
+ size_t data_size;
|
||||
+};
|
||||
+
|
||||
struct efi_var_operations {
|
||||
char name[NAME_MAX];
|
||||
int (*probe)(void);
|
||||
diff --git a/src/libefivar.map.in b/src/libefivar.map.in
|
||||
index 54bfb765998..f2505134c63 100644
|
||||
--- a/src/libefivar.map.in
|
||||
+++ b/src/libefivar.map.in
|
||||
@@ -136,6 +136,7 @@ LIBEFIVAR_1.38 {
|
||||
efi_set_loglevel;
|
||||
efi_get_libefivar_version;
|
||||
efi_guid_grub;
|
||||
+ efi_guid_external_management;
|
||||
efi_variable_alloc;
|
||||
efi_variable_export_dmpstore;
|
||||
} LIBEFIVAR_1.37;
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,430 +0,0 @@
|
||||
From 2554f389cd167ee28033b8885da3f92b798f7ed3 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 3 Feb 2020 13:26:08 -0500
|
||||
Subject: [PATCH 80/86] Add efi_time_t and time conversion and formatting
|
||||
utilities.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/Makefile | 2 +-
|
||||
src/include/efivar/efivar-time.h | 27 +++
|
||||
src/include/efivar/efivar-types.h | 33 ++++
|
||||
src/include/efivar/efivar.h | 2 +
|
||||
src/libefivar.map.in | 12 ++
|
||||
src/time.c | 272 ++++++++++++++++++++++++++++++
|
||||
6 files changed, 347 insertions(+), 1 deletion(-)
|
||||
create mode 100644 src/include/efivar/efivar-time.h
|
||||
create mode 100644 src/time.c
|
||||
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index 0783cb3b55f..b0ef8ec29a5 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -18,7 +18,7 @@ LIBEFIBOOT_SOURCES = crc32.c creator.c disk.c gpt.c loadopt.c path-helpers.c \
|
||||
LIBEFIBOOT_OBJECTS = $(patsubst %.c,%.o,$(LIBEFIBOOT_SOURCES))
|
||||
LIBEFIVAR_SOURCES = crc32.c dp.c dp-acpi.c dp-hw.c dp-media.c dp-message.c \
|
||||
efivarfs.c error.c export.c guid.c guids.S guid-symbols.c \
|
||||
- lib.c vars.c
|
||||
+ lib.c vars.c time.c
|
||||
LIBEFIVAR_OBJECTS = $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(LIBEFIVAR_SOURCES)))
|
||||
EFIVAR_SOURCES = efivar.c
|
||||
GENERATED_SOURCES = include/efivar/efivar-guids.h guid-symbols.c
|
||||
diff --git a/src/include/efivar/efivar-time.h b/src/include/efivar/efivar-time.h
|
||||
new file mode 100644
|
||||
index 00000000000..04c243601f5
|
||||
--- /dev/null
|
||||
+++ b/src/include/efivar/efivar-time.h
|
||||
@@ -0,0 +1,27 @@
|
||||
+// SPDX-License-Identifier: LGPL-2.1
|
||||
+/*
|
||||
+ * efivar-time.h
|
||||
+ * Copyright 2020 Peter Jones <pjones@redhat.com>
|
||||
+ */
|
||||
+
|
||||
+#ifndef EFIVAR_TIME_H_
|
||||
+#define EFIVAR_TIME_H_
|
||||
+
|
||||
+#include <stdbool.h>
|
||||
+
|
||||
+extern int tm_to_efi_time(const struct tm * const s, efi_time_t *d, bool tzadj);
|
||||
+extern int efi_time_to_tm(const efi_time_t * const s, struct tm *d);
|
||||
+
|
||||
+extern char *efi_asctime(const efi_time_t * const time);
|
||||
+extern char *efi_asctime_r(const efi_time_t * const time, char *buf);
|
||||
+extern efi_time_t *efi_gmtime(const time_t *time);
|
||||
+extern efi_time_t *efi_gmtime_r(const time_t *time, efi_time_t *result);
|
||||
+extern efi_time_t *efi_localtime(const time_t *time);
|
||||
+extern efi_time_t *efi_localtime_r(const time_t *time, efi_time_t *result);
|
||||
+extern time_t efi_mktime(const efi_time_t * const time);
|
||||
+
|
||||
+extern char *efi_strptime(const char *s, const char *format, efi_time_t *time);
|
||||
+extern size_t efi_strftime(char *s, size_t max, const char *format, const efi_time_t *time);
|
||||
+
|
||||
+#endif /* !EFIVAR_TIME_H_ */
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/include/efivar/efivar-types.h b/src/include/efivar/efivar-types.h
|
||||
index 6fca8a495f4..ce22b6c12b3 100644
|
||||
--- a/src/include/efivar/efivar-types.h
|
||||
+++ b/src/include/efivar/efivar-types.h
|
||||
@@ -51,6 +51,39 @@ typedef uint16_t efi_char16_t;
|
||||
typedef unsigned long uintn_t;
|
||||
typedef long intn_t;
|
||||
|
||||
+#define EFIVAR_HAVE_EFI_TIME_T 1
|
||||
+
|
||||
+/*
|
||||
+ * This can never be correct in, as defined, in the face of leap seconds.
|
||||
+ * Because seconds here are defined with a range of [0,59], we can't
|
||||
+ * express leap seconds correctly there. Because TimeZone is specified in
|
||||
+ * minutes West of UTC, rather than seconds (like struct tm), it can't be
|
||||
+ * used to correct when we cross a leap second boundary condition. As a
|
||||
+ * result, EFI_TIME can only express UT1, rather than UTC, and there's no
|
||||
+ * way when converting to know wether the error has been taken into
|
||||
+ * account, nor if it should be.
|
||||
+ *
|
||||
+ * As I write this, there is a 37 second error.
|
||||
+ */
|
||||
+typedef struct {
|
||||
+ uint16_t year; // 1900 - 9999
|
||||
+ uint8_t month; // 1 - 12
|
||||
+ uint8_t day; // 1 - 31
|
||||
+ uint8_t hour; // 0 - 23
|
||||
+ uint8_t minute; // 0 - 59
|
||||
+ uint8_t second; // 0 - 59 // ha ha only serious
|
||||
+ uint8_t pad1; // 0
|
||||
+ uint32_t nanosecond; // 0 - 999,999,999
|
||||
+ int16_t timezone; // minutes from UTC or EFI_UNSPECIFIED_TIMEZONE
|
||||
+ uint8_t daylight; // bitfield
|
||||
+ uint8_t pad2; // 0
|
||||
+} efi_time_t __attribute__((__aligned__(1)));
|
||||
+
|
||||
+#define EFI_TIME_ADJUST_DAYLIGHT ((uint8_t)0x01)
|
||||
+#define EFI_TIME_IN_DAYLIGHT ((uint8_t)0x02)
|
||||
+
|
||||
+#define EFI_UNSPECIFIED_TIMEZONE ((uint16_t)0x07ff)
|
||||
+
|
||||
#define EFI_VARIABLE_NON_VOLATILE ((uint64_t)0x0000000000000001)
|
||||
#define EFI_VARIABLE_BOOTSERVICE_ACCESS ((uint64_t)0x0000000000000002)
|
||||
#define EFI_VARIABLE_RUNTIME_ACCESS ((uint64_t)0x0000000000000004)
|
||||
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
|
||||
index 6b38ce8faf4..7518a3238c7 100644
|
||||
--- a/src/include/efivar/efivar.h
|
||||
+++ b/src/include/efivar/efivar.h
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
+#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
@@ -200,6 +201,7 @@ extern uint32_t efi_get_libefivar_version(void)
|
||||
__attribute__((__visibility__("default")));
|
||||
|
||||
#include <efivar/efivar-dp.h>
|
||||
+#include <efivar/efivar-time.h>
|
||||
|
||||
#endif /* EFIVAR_H */
|
||||
|
||||
diff --git a/src/libefivar.map.in b/src/libefivar.map.in
|
||||
index f2505134c63..47d45456372 100644
|
||||
--- a/src/libefivar.map.in
|
||||
+++ b/src/libefivar.map.in
|
||||
@@ -139,4 +139,16 @@ LIBEFIVAR_1.38 {
|
||||
efi_guid_external_management;
|
||||
efi_variable_alloc;
|
||||
efi_variable_export_dmpstore;
|
||||
+
|
||||
+ tm_to_efi_time;
|
||||
+ efi_time_to_tm;
|
||||
+ efi_asctime;
|
||||
+ efi_asctime_r;
|
||||
+ efi_gmtime;
|
||||
+ efi_gmtime_r;
|
||||
+ efi_localtime;
|
||||
+ efi_localtime_r;
|
||||
+ efi_mktime;
|
||||
+ efi_strptime;
|
||||
+ efi_strftime;
|
||||
} LIBEFIVAR_1.37;
|
||||
diff --git a/src/time.c b/src/time.c
|
||||
new file mode 100644
|
||||
index 00000000000..f267fd193e6
|
||||
--- /dev/null
|
||||
+++ b/src/time.c
|
||||
@@ -0,0 +1,272 @@
|
||||
+// SPDX-License-Identifier: LGPL-2.1
|
||||
+/*
|
||||
+ * time.c - efi_time_t helper functions
|
||||
+ * Copyright 2020 Peter Jones <pjones@redhat.com>
|
||||
+ */
|
||||
+
|
||||
+#include "efivar.h"
|
||||
+
|
||||
+int
|
||||
+efi_time_to_tm(const efi_time_t * const s, struct tm *d)
|
||||
+{
|
||||
+
|
||||
+ if (!s || !d) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ d->tm_year = s->year - 1900;
|
||||
+ d->tm_mon = s->month - 1;
|
||||
+ d->tm_mday = s->day;
|
||||
+ d->tm_hour = s->hour;
|
||||
+ d->tm_min = s->minute;
|
||||
+ /*
|
||||
+ * Just ignore EFI's range problem here and pretend we're in UTC
|
||||
+ * not UT1.
|
||||
+ */
|
||||
+ d->tm_sec = s->second;
|
||||
+ d->tm_isdst = (s->daylight & EFI_TIME_IN_DAYLIGHT) ? 1 : 0;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+tm_to_efi_time(const struct tm * const s, efi_time_t *d, bool tzadj)
|
||||
+{
|
||||
+ if (!s || !d) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ d->pad2 = 0;
|
||||
+ d->daylight = s->tm_isdst ? EFI_TIME_IN_DAYLIGHT : 0;
|
||||
+ d->timezone = 0;
|
||||
+ d->nanosecond = 0;
|
||||
+ d->pad1 = 0;
|
||||
+ /*
|
||||
+ * Just ignore EFI's range problem here and pretend we're in UTC
|
||||
+ * not UT1.
|
||||
+ */
|
||||
+ d->second = s->tm_sec;
|
||||
+ d->minute = s->tm_min;
|
||||
+ d->hour = s->tm_hour;
|
||||
+ d->day = s->tm_mday;
|
||||
+ d->month = s->tm_mon + 1;
|
||||
+ d->year = s->tm_year + 1900;
|
||||
+
|
||||
+ if (tzadj) {
|
||||
+ tzset();
|
||||
+ d->timezone = timezone / 60;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static char *otz_;
|
||||
+static char *ntz_;
|
||||
+
|
||||
+static const char *
|
||||
+newtz(int16_t timezone_)
|
||||
+{
|
||||
+ if (!otz_)
|
||||
+ otz_ = strdup(secure_getenv("TZ"));
|
||||
+
|
||||
+ if (ntz_) {
|
||||
+ free(ntz_);
|
||||
+ ntz_ = NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (timezone_ == EFI_UNSPECIFIED_TIMEZONE) {
|
||||
+ unsetenv("TZ");
|
||||
+ } else {
|
||||
+ char tzsign = timezone_ >= 0 ? '+' : '-';
|
||||
+ int tzabs = tzsign == '+' ? timezone_ : -timezone_;
|
||||
+ int16_t tzhours = tzabs / 60;
|
||||
+ int16_t tzminutes = tzabs % 60;
|
||||
+
|
||||
+ /*
|
||||
+ * I have no idea what the right thing to do with DST is
|
||||
+ * here, so I'm going to ignore it.
|
||||
+ */
|
||||
+ asprintf(&ntz_, "UTC%c%"PRId16":%"PRId16":00",
|
||||
+ tzsign, tzhours, tzminutes);
|
||||
+ setenv("TZ", ntz_, 1);
|
||||
+ }
|
||||
+ tzset();
|
||||
+
|
||||
+ return ntz_;
|
||||
+}
|
||||
+
|
||||
+static const char *
|
||||
+oldtz(void) {
|
||||
+ if (ntz_) {
|
||||
+ free(ntz_);
|
||||
+ ntz_ = NULL;
|
||||
+
|
||||
+ if (otz_)
|
||||
+ setenv("TZ", otz_, 1);
|
||||
+ else
|
||||
+ unsetenv("TZ");
|
||||
+ }
|
||||
+
|
||||
+ tzset();
|
||||
+
|
||||
+ return otz_;
|
||||
+}
|
||||
+
|
||||
+efi_time_t *
|
||||
+efi_gmtime_r(const time_t *time, efi_time_t *result)
|
||||
+{
|
||||
+ struct tm tm = { 0 };
|
||||
+
|
||||
+ if (!time || !result) {
|
||||
+ errno = EINVAL;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ gmtime_r(time, &tm);
|
||||
+ tm_to_efi_time(&tm, result, false);
|
||||
+
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+efi_time_t *
|
||||
+efi_gmtime(const time_t *time)
|
||||
+{
|
||||
+ static efi_time_t ret;
|
||||
+
|
||||
+ if (!time) {
|
||||
+ errno = EINVAL;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ efi_gmtime_r(time, &ret);
|
||||
+
|
||||
+ return &ret;
|
||||
+}
|
||||
+
|
||||
+efi_time_t *
|
||||
+efi_localtime_r(const time_t *time, efi_time_t *result)
|
||||
+{
|
||||
+ struct tm tm = { 0 };
|
||||
+
|
||||
+ if (!time || !result) {
|
||||
+ errno = EINVAL;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ localtime_r(time, &tm);
|
||||
+ tm_to_efi_time(&tm, result, true);
|
||||
+
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+efi_time_t *
|
||||
+efi_localtime(const time_t *time)
|
||||
+{
|
||||
+ static efi_time_t ret;
|
||||
+
|
||||
+ if (!time) {
|
||||
+ errno = EINVAL;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ efi_localtime_r(time, &ret);
|
||||
+
|
||||
+ return &ret;
|
||||
+}
|
||||
+
|
||||
+time_t
|
||||
+efi_mktime(const efi_time_t * const time)
|
||||
+{
|
||||
+ struct tm tm = { 0 };
|
||||
+ time_t ret;
|
||||
+
|
||||
+ if (!time) {
|
||||
+ errno = EINVAL;
|
||||
+ return (time_t)-1;
|
||||
+ }
|
||||
+
|
||||
+ newtz(time->timezone);
|
||||
+
|
||||
+ efi_time_to_tm(time, &tm);
|
||||
+ ret = mktime(&tm);
|
||||
+
|
||||
+ oldtz();
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+char *
|
||||
+efi_strptime(const char *s, const char *format, efi_time_t *time)
|
||||
+{
|
||||
+ struct tm tm;
|
||||
+ char *end;
|
||||
+
|
||||
+ if (!s || !format || !time) {
|
||||
+ errno = EINVAL;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ memset(&tm, 0, sizeof(tm));
|
||||
+ end = strptime(s, format, &tm);
|
||||
+ if (end != NULL && tm_to_efi_time(&tm, time, true) < 0)
|
||||
+ return NULL;
|
||||
+
|
||||
+ return end;
|
||||
+}
|
||||
+
|
||||
+char *
|
||||
+efi_asctime_r(const efi_time_t * const time, char *buf)
|
||||
+{
|
||||
+ struct tm tm;
|
||||
+ char *ret;
|
||||
+
|
||||
+ newtz(time->timezone);
|
||||
+
|
||||
+ efi_time_to_tm(time, &tm);
|
||||
+ ret = asctime_r(&tm, buf);
|
||||
+
|
||||
+ oldtz();
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+char *
|
||||
+efi_asctime(const efi_time_t * const time)
|
||||
+{
|
||||
+ struct tm tm;
|
||||
+ char *ret;
|
||||
+
|
||||
+ newtz(time->timezone);
|
||||
+
|
||||
+ efi_time_to_tm(time, &tm);
|
||||
+ ret = asctime(&tm);
|
||||
+
|
||||
+ oldtz();
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+size_t
|
||||
+efi_strftime(char *s, size_t max, const char *format, const efi_time_t *time)
|
||||
+{
|
||||
+ size_t ret = 0;
|
||||
+ struct tm tm = { 0 };
|
||||
+
|
||||
+ if (!s || !format || !time) {
|
||||
+ errno = EINVAL;
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ newtz(time->timezone);
|
||||
+
|
||||
+ efi_time_to_tm(time, &tm);
|
||||
+ ret = strftime(s, max, format, &tm);
|
||||
+
|
||||
+ oldtz();
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,195 +0,0 @@
|
||||
From 89ed4a7d1fc1e1164c9f4ad2f0f8a3d1c0f7d90e Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 3 Feb 2020 13:47:08 -0500
|
||||
Subject: [PATCH 81/86] Add the beginnings of our security library.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/Android.mk | 5 ++++-
|
||||
src/Makefile | 20 +++++++++++++++-----
|
||||
src/efisec.h | 15 +++++++++++++++
|
||||
src/efisec.pc.in | 11 +++++++++++
|
||||
src/include/efivar/efisec.h | 17 +++++++++++++++++
|
||||
src/libefisec.map.in | 7 +++++++
|
||||
src/sec.c | 16 ++++++++++++++++
|
||||
7 files changed, 85 insertions(+), 6 deletions(-)
|
||||
create mode 100644 src/efisec.h
|
||||
create mode 100644 src/efisec.pc.in
|
||||
create mode 100644 src/include/efivar/efisec.h
|
||||
create mode 100644 src/libefisec.map.in
|
||||
create mode 100644 src/sec.c
|
||||
|
||||
diff --git a/src/Android.mk b/src/Android.mk
|
||||
index f6af87c51ac..5a06137aa21 100644
|
||||
--- a/src/Android.mk
|
||||
+++ b/src/Android.mk
|
||||
@@ -46,9 +46,12 @@ LIBEFIVAR_SOURCES := \
|
||||
lib.c \
|
||||
vars.c
|
||||
|
||||
+LIBEFISEC_SOURCES := \
|
||||
+ sec.c
|
||||
+
|
||||
include $(LOCAL_PATH)/include/version.mk
|
||||
|
||||
-LOCAL_SRC_FILES := $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES)
|
||||
+LOCAL_SRC_FILES := $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES) $(LIBEFISEC_SOURCES)
|
||||
LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu11 -DLIBEFIVAR_VERSION=$(VERSION) -Wno-missing-field-initializers
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES) $(LOCAL_C_INCLUDES)/efivar $(local-generated-sources-dir)
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index b0ef8ec29a5..883e058facf 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -5,14 +5,16 @@ include $(TOPDIR)/src/include/version.mk
|
||||
include $(TOPDIR)/src/include/rules.mk
|
||||
include $(TOPDIR)/src/include/defaults.mk
|
||||
|
||||
-LIBTARGETS=libefivar.so libefiboot.so
|
||||
-STATICLIBTARGETS=libefivar.a libefiboot.a
|
||||
+LIBTARGETS=libefivar.so libefiboot.so libefisec.so
|
||||
+STATICLIBTARGETS=libefivar.a libefiboot.a libefisec.a
|
||||
BINTARGETS=efivar
|
||||
STATICBINTARGETS=efivar-static
|
||||
-PCTARGETS=efivar.pc efiboot.pc
|
||||
+PCTARGETS=efivar.pc efiboot.pc efisec.pc
|
||||
TARGETS=$(LIBTARGETS) $(BINTARGETS) $(PCTARGETS)
|
||||
STATICTARGETS=$(STATICLIBTARGETS) $(STATICBINTARGETS)
|
||||
|
||||
+LIBEFISEC_SOURCES = sec.c
|
||||
+LIBEFISEC_OBJECTS = $(patsubst %.c,%.o,$(LIBEFISEC_SOURCES))
|
||||
LIBEFIBOOT_SOURCES = crc32.c creator.c disk.c gpt.c loadopt.c path-helpers.c \
|
||||
linux.c $(sort $(wildcard linux-*.c))
|
||||
LIBEFIBOOT_OBJECTS = $(patsubst %.c,%.o,$(LIBEFIBOOT_SOURCES))
|
||||
@@ -23,8 +25,9 @@ LIBEFIVAR_OBJECTS = $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(LIBEFIVAR_SOURCES)))
|
||||
EFIVAR_SOURCES = efivar.c
|
||||
GENERATED_SOURCES = include/efivar/efivar-guids.h guid-symbols.c
|
||||
MAKEGUIDS_SOURCES = makeguids.c guid.c
|
||||
-ALL_SOURCES=$(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES) $(MAKEGUIDS_SOURCES) \
|
||||
- $(sort $(wildcard include/efivar/*.h)) $(GENERATED_SOURCES) $(EFIVAR_SOURCES)
|
||||
+ALL_SOURCES=$(LIBEFISEC_SOURCES) $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES) \
|
||||
+ $(MAKEGUIDS_SOURCES) $(GENERATED_SOURCES) $(EFIVAR_SOURCES) \
|
||||
+ $(sort $(wildcard include/efivar/*.h))
|
||||
|
||||
$(call deps-of,$(ALL_SOURCES)) : | deps
|
||||
-include $(call deps-of,$(ALL_SOURCES))
|
||||
@@ -86,6 +89,12 @@ libefiboot.so : | libefiboot.map libefivar.so
|
||||
libefiboot.so : LIBS=efivar
|
||||
libefiboot.so : MAP=libefiboot.map
|
||||
|
||||
+libefisec.a : $(patsubst %.o,%.static.o,$(LIBEFISEC_OBJECTS))
|
||||
+
|
||||
+libefisec.so : $(LIBEFISEC_OBJECTS)
|
||||
+libefisec.so : | libefisec.map
|
||||
+libefisec.so : MAP=libefisec.map
|
||||
+
|
||||
deps : $(ALL_SOURCES)
|
||||
@$(MAKE) -f $(SRCDIR)/include/deps.mk deps SOURCES="$(ALL_SOURCES)"
|
||||
|
||||
@@ -116,6 +125,7 @@ test : all
|
||||
.PHONY: test deps abiclean abixml
|
||||
.SECONDARY : libefivar.so.1.$(VERSION) libefivar.so.1
|
||||
.SECONDARY : libefiboot.so.1.$(VERSION) libefiboot.so.1
|
||||
+.SECONDARY : libefisec.so.1.$(VERSION) libefisec.so.1
|
||||
.SECONDARY : include/efivar/efivar-guids.h guid-symbols.c
|
||||
.INTERMEDIATE : guids.bin names.bin
|
||||
.PRECIOUS : guid-symbols.o makeguids
|
||||
diff --git a/src/efisec.h b/src/efisec.h
|
||||
new file mode 100644
|
||||
index 00000000000..15d0f6d10e2
|
||||
--- /dev/null
|
||||
+++ b/src/efisec.h
|
||||
@@ -0,0 +1,15 @@
|
||||
+// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+/*
|
||||
+ * efisec.h
|
||||
+ * Copyright 2018 Peter Jones <pjones@redhat.com>
|
||||
+ */
|
||||
+
|
||||
+#ifndef PRIVATE_EFISEC_H_
|
||||
+#define PRIVATE_EFISEC_H_
|
||||
+
|
||||
+#include "efivar.h"
|
||||
+#include <efivar/efisec.h>
|
||||
+
|
||||
+#endif /* !PRIVATE_EFISEC_H_ */
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/efisec.pc.in b/src/efisec.pc.in
|
||||
new file mode 100644
|
||||
index 00000000000..d3d75aac509
|
||||
--- /dev/null
|
||||
+++ b/src/efisec.pc.in
|
||||
@@ -0,0 +1,11 @@
|
||||
+prefix=@@PREFIX@@
|
||||
+exec_prefix=@@EXEC_PREFIX@@
|
||||
+libdir=@@LIBDIR@@
|
||||
+includedir=@@INCLUDEDIR@@
|
||||
+
|
||||
+Name: efisec
|
||||
+Description: UEFI Security Features
|
||||
+Version: @@VERSION@@
|
||||
+Libs: -L${libdir} -lefivar -lefisec
|
||||
+Libs.private: -ldl
|
||||
+Cflags: -I${includedir}/efivar
|
||||
diff --git a/src/include/efivar/efisec.h b/src/include/efivar/efisec.h
|
||||
new file mode 100644
|
||||
index 00000000000..0ee5abe8bfd
|
||||
--- /dev/null
|
||||
+++ b/src/include/efivar/efisec.h
|
||||
@@ -0,0 +1,17 @@
|
||||
+// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+/*
|
||||
+ * libefisec - library for the manipulation of EFI boot variables
|
||||
+ * Copyright 2020 Peter M. Jones <pjones@redhat.com>
|
||||
+ * Copyright 2020 Red Hat, Inc.
|
||||
+ */
|
||||
+#ifndef EFISEC_H
|
||||
+#define EFISEC_H 1
|
||||
+
|
||||
+#include <efivar/efivar.h>
|
||||
+
|
||||
+extern uint32_t efi_get_libefisec_version(void)
|
||||
+ __attribute__((__visibility__("default")));
|
||||
+
|
||||
+#endif /* EFISEC_H */
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/libefisec.map.in b/src/libefisec.map.in
|
||||
new file mode 100644
|
||||
index 00000000000..2e732cf1d9b
|
||||
--- /dev/null
|
||||
+++ b/src/libefisec.map.in
|
||||
@@ -0,0 +1,7 @@
|
||||
+libefisec.so.0 {
|
||||
+ local: *;
|
||||
+};
|
||||
+
|
||||
+LIBEFISEC_1.38 {
|
||||
+ global: efi_get_libefisec_version;
|
||||
+} libefisec.so.0;
|
||||
diff --git a/src/sec.c b/src/sec.c
|
||||
new file mode 100644
|
||||
index 00000000000..6b6a70bb784
|
||||
--- /dev/null
|
||||
+++ b/src/sec.c
|
||||
@@ -0,0 +1,16 @@
|
||||
+// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+/*
|
||||
+ * sec.c
|
||||
+ * Copyright 2020 Peter Jones <pjones@redhat.com>
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#include "efivar.h"
|
||||
+
|
||||
+uint32_t PUBLIC
|
||||
+efi_get_libefisec_version(void)
|
||||
+{
|
||||
+ return LIBEFIVAR_VERSION;
|
||||
+}
|
||||
+
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,62 +0,0 @@
|
||||
From fbac76acffbc300ddbc4d466fa222745d0f1cd47 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 3 Feb 2020 13:48:40 -0500
|
||||
Subject: [PATCH 82/86] Fix up some guid descriptions
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/guids.txt | 18 +++++++++---------
|
||||
1 file changed, 9 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/guids.txt b/src/guids.txt
|
||||
index 95d93c0df74..2933073e0e6 100644
|
||||
--- a/src/guids.txt
|
||||
+++ b/src/guids.txt
|
||||
@@ -1,20 +1,20 @@
|
||||
00000000-0000-0000-0000-000000000000 zero zeroed sentinel guid
|
||||
-093e0fae-a6c4-4f50-9f1b-d41e2b89c19a sha512 SHA-512
|
||||
+093e0fae-a6c4-4f50-9f1b-d41e2b89c19a sha512 SHA-512 hash
|
||||
0abba7dc-e516-4167-bbf5-4d9d1c739416 fwupdate Linux Firmware Update Tool
|
||||
-0b6e5233-a65c-44c9-9407-d9ab83bfc8bd sha224 SHA-224
|
||||
+0b6e5233-a65c-44c9-9407-d9ab83bfc8bd sha224 SHA-224 hash
|
||||
126a762d-5758-4fca-8531-201a7f57f850 lenovo_boot_menu Lenovo Boot Menu
|
||||
3b8c8162-188c-46a4-aec9-be43f1d65697 ux_capsule Firmware update localized text image
|
||||
-3bd2a492-96c0-4079-b420-fcf98ef103ed x509_sha256 SHA256 hash of X.509 Certificate
|
||||
-3c5766e8-269c-4e34-aa14-ed776e85b3b6 rsa2048 RSA 2048
|
||||
+3bd2a492-96c0-4079-b420-fcf98ef103ed x509_sha256 SHA-256 hash of X.509 Certificate
|
||||
+3c5766e8-269c-4e34-aa14-ed776e85b3b6 rsa2048 RSA 2048 pubkey
|
||||
3CC24E96-22C7-41D8-8863-8E39DCDCC2CF lenovo Lenovo
|
||||
3f7e615b-0d45-4f80-88dc-26b234958560 lenovo_diag Lenovo Diagnostics
|
||||
-446dbf63-2502-4cda-bcfa-2465d2b0fe9d x509_sha512 SHA512 hash of X.509 Certificate
|
||||
+446dbf63-2502-4cda-bcfa-2465d2b0fe9d x509_sha512 SHA-512 hash of X.509 Certificate
|
||||
452e8ced-dfff-4b8c-ae01-5118862e682c external_management External Management Mechanism
|
||||
4aafd29d-68df-49ee-8aa9-347d375665a7 pkcs7_cert PKCS7 Certificate
|
||||
605dab50-e046-4300-abb6-3dd810dd8b23 shim shim
|
||||
665d3f60-ad3e-4cad-8e26-db46eee9f1b5 lenovo_rescue Lenovo Rescue and Recovery
|
||||
-67f8444f-8743-48f1-a328-1eaab8736080 rsa2048_sha1 RSA 2048 with SHA-1
|
||||
-7076876e-80c2-4ee6-aad2-28b349a6865b x509_sha384 SHA384 hash of X.509 Certificate
|
||||
+67f8444f-8743-48f1-a328-1eaab8736080 rsa2048_sha1 RSA-2048 signature of a SHA-1 hash
|
||||
+7076876e-80c2-4ee6-aad2-28b349a6865b x509_sha384 SHA-384 hash of X.509 Certificate
|
||||
721c8b66-426c-4e86-8e99-3457c46ab0b9 lenovo_setup Lenovo Firmware Setup
|
||||
77fa9abd-0359-4d32-bd60-28f4e78f784b microsoft Microsoft
|
||||
7FACC7B6-127F-4E9C-9C5D-080F98994345 lenovo_2 Lenovo
|
||||
@@ -24,14 +24,14 @@
|
||||
8be4df61-93ca-11d2-aa0d-00e098032b8c global EFI Global Variable
|
||||
91376aff-cba6-42be-949d-06fde81128e8 grub GRUB
|
||||
a5c059a1-94e4-4aa7-87b5-ab155c2bf072 x509_cert X.509 Certificate
|
||||
-a7717414-c616-4977-9420-844712a735bf rsa2048_sha256_cert RSA 2048 with SHA-256 Certificate
|
||||
+a7717414-c616-4977-9420-844712a735bf rsa2048_sha256_cert RSA-2048 key with SHA-256 Certificate
|
||||
a7d8d9a6-6ab0-4aeb-ad9d-163e59a7a380 lenovo_diag_splash Lenovo Diagnostic Splash Screen
|
||||
ade9e48f-9cb8-98e6-31af-b4e6009e2fe3 redhat_2 Red Hat Maybe
|
||||
bc7838d2-0f82-4d60-8316-c068ee79d25b lenovo_msg Lenovo Vendor Message Device
|
||||
c1c41626-504c-4092-aca9-41f936934328 sha256 SHA-256
|
||||
c57ad6b7-0515-40a8-9d21-551652854e37 shell EFI Shell
|
||||
d719b2cb-3d3a-4596-a3bc-dad00e67656f security EFI Security Database
|
||||
-e2b36190-879b-4a3d-ad8d-f2e7bba32784 rsa2048_sha256 RSA 2048 with SHA-256
|
||||
+e2b36190-879b-4a3d-ad8d-f2e7bba32784 rsa2048_sha256 RSA-2048 signature of a SHA-256 hash
|
||||
ff3e5307-9fd0-48c9-85f1-8ad56c701e01 sha384 SHA-384
|
||||
f46ee6f4-4785-43a3-923d-7f786c3c8479 lenovo_startup_interrupt Lenovo Startup Interrupt Menu
|
||||
ffffffff-ffff-ffff-ffff-ffffffffffff zzignore-this-guid zzignore-this-guid
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,269 +0,0 @@
|
||||
From 74e3cb9e883f95ed358337df8a9841a2f47fd153 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 3 Feb 2020 13:50:07 -0500
|
||||
Subject: [PATCH 83/86] Add some of the authenticode-related defines from
|
||||
pesign
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/include/efivar/efisec-types.h | 234 ++++++++++++++++++++++++++++++
|
||||
src/include/efivar/efisec.h | 2 +
|
||||
2 files changed, 236 insertions(+)
|
||||
create mode 100644 src/include/efivar/efisec-types.h
|
||||
|
||||
diff --git a/src/include/efivar/efisec-types.h b/src/include/efivar/efisec-types.h
|
||||
new file mode 100644
|
||||
index 00000000000..5d7febfeaae
|
||||
--- /dev/null
|
||||
+++ b/src/include/efivar/efisec-types.h
|
||||
@@ -0,0 +1,234 @@
|
||||
+// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+/*
|
||||
+ * authenticode.h - Authenticode definitions and types
|
||||
+ * Copyright 2019-2020 Peter Jones <pjones@redhat.com>
|
||||
+ */
|
||||
+
|
||||
+#ifndef EFISEC_TYPES_H_
|
||||
+#define EFISEC_TYPES_H_ 1
|
||||
+
|
||||
+#include <stdint.h>
|
||||
+#include <efivar/efivar-types.h>
|
||||
+
|
||||
+/*
|
||||
+ * Storage for specific hashes and cryptographic (not pkcs7) signatures
|
||||
+ */
|
||||
+typedef uint8_t efi_sha1_hash_t[20];
|
||||
+typedef uint8_t efi_sha224_hash_t[28];
|
||||
+typedef uint8_t efi_sha256_hash_t[32];
|
||||
+typedef uint8_t efi_sha384_hash_t[48];
|
||||
+typedef uint8_t efi_sha512_hash_t[64];
|
||||
+typedef uint8_t efi_rsa2048_sig_t[256];
|
||||
+
|
||||
+/*
|
||||
+ * Security database definitions and types
|
||||
+ */
|
||||
+
|
||||
+#define EFI_GLOBAL_PLATFORM_KEY L"PK"
|
||||
+#define EFI_GLOBAL_KEY_EXCHANGE_KEY L"KEK"
|
||||
+#define EFI_IMAGE_SECURITY_DATABASE L"db"
|
||||
+#define EFI_IMAGE_SECURITY_DATABASE1 L"dbx"
|
||||
+#define EFI_IMAGE_SECURITY_DATABASE2 L"dbt"
|
||||
+#define EFI_IMAGE_SECURITY_DATABASE3 L"dbr"
|
||||
+
|
||||
+typedef struct {
|
||||
+ efi_sha256_hash_t to_be_signed_hash;
|
||||
+ efi_time_t time_of_revocation;
|
||||
+} efi_cert_x509_sha256_t __attribute__((__aligned__(1)));
|
||||
+
|
||||
+typedef struct {
|
||||
+ efi_sha384_hash_t to_be_signed_hash;
|
||||
+ efi_time_t time_of_revocation;
|
||||
+} efi_cert_x509_sha384_t __attribute__((__aligned__(1)));
|
||||
+
|
||||
+typedef struct {
|
||||
+ efi_sha512_hash_t to_be_signed_hash;
|
||||
+ efi_time_t time_of_revocation;
|
||||
+} efi_cert_x509_sha512_t __attribute__((__aligned__(1)));
|
||||
+
|
||||
+typedef struct {
|
||||
+ efi_guid_t signature_owner;
|
||||
+ uint8_t signature_data[];
|
||||
+} efi_signature_data_t __attribute__((__aligned__(1)));
|
||||
+
|
||||
+typedef struct {
|
||||
+ efi_guid_t signature_type;
|
||||
+ uint32_t signature_list_size;
|
||||
+ uint32_t signature_header_size;
|
||||
+ uint32_t signature_size;
|
||||
+ // uint8_t signature_header[];
|
||||
+ // efi_signature_data signatures[][signature_size];
|
||||
+} efi_signature_list_t __attribute__((__aligned__(1)));
|
||||
+
|
||||
+/**********************************************************
|
||||
+ * Stuff used by authenticode and authenticated variables *
|
||||
+ **********************************************************/
|
||||
+
|
||||
+#define WIN_CERT_REVISION_1_0 ((uint16_t)0x0100)
|
||||
+#define WIN_CERT_REVISION_2_0 ((uint16_t)0x0200)
|
||||
+
|
||||
+#define WIN_CERT_TYPE_PKCS_SIGNED_DATA ((uint16_t)0x0002)
|
||||
+#define WIN_CERT_TYPE_EFI_PKCS115 ((uint16_t)0x0ef0)
|
||||
+#define WIN_CERT_TYPE_EFI_GUID ((uint16_t)0x0ef1)
|
||||
+
|
||||
+typedef struct {
|
||||
+ uint32_t length;
|
||||
+ uint16_t revision;
|
||||
+ uint16_t cert_type;
|
||||
+} win_certificate_header_t;
|
||||
+
|
||||
+/*
|
||||
+ * The spec says:
|
||||
+ *
|
||||
+ * This structure is the certificate header. There may be zero or more
|
||||
+ * certificates.
|
||||
+ * • If the wCertificateType field is set to WIN_CERT_TYPE_EFI_PKCS115,
|
||||
+ * then the certificate follows the format described in
|
||||
+ * WIN_CERTIFICATE_EFI_PKCS1_15.
|
||||
+ * • If the wCertificateType field is set to WIN_CERT_TYPE_EFI_GUID, then
|
||||
+ * the certificate follows the format described in
|
||||
+ * WIN_CERTIFICATE_UEFI_GUID.
|
||||
+ * • If the wCertificateType field is set to WIN_CERT_TYPE_PKCS_SIGNED_DATA
|
||||
+ * then the certificate is formatted as described in the Authenticode
|
||||
+ * specification.
|
||||
+ *
|
||||
+ * Which basically means we see the first two in EFI signature databases,
|
||||
+ * and the third one in authenticode signatures. It goes on to say:
|
||||
+ *
|
||||
+ * Table 11.
|
||||
+ * PE/COFF Certificates Types and UEFI Signature Database Certificate Types
|
||||
+ * +---------------------------------------+-----------------------------------+
|
||||
+ * | Image Certificate Type | Verified Using Signature Database |
|
||||
+ * | | Type |
|
||||
+ * +---------------------------------------+-----------------------------------+
|
||||
+ * | WIN_CERT_TYPE_EFI_PKCS115 | EFI_CERT_RSA2048_GUID (public key)|
|
||||
+ * | ( Signature Size = 256 bytes) | |
|
||||
+ * +---------------------------------------+-----------------------------------+
|
||||
+ * | WIN_CERT_TYPE_EFI_GUID | EFI_CERT_RSA2048_GUID (public key)|
|
||||
+ * | ( CertType = | |
|
||||
+ * | EFI_CERT_TYPE_RSA2048_SHA256_GUID ) | |
|
||||
+ * +---------------------------------------+-----------------------------------+
|
||||
+ * | WIN_CERT_TYPE_EFI_GUID | EFI_CERT_X509_GUID |
|
||||
+ * | (CertType = EFI_CERT_TYPE_PKCS7_GUID) | EFI_CERT_RSA2048_GUID |
|
||||
+ * | | (when applicable) |
|
||||
+ * | | EFI_CERT_X509_SHA256_GUID |
|
||||
+ * | | (when applicable) |
|
||||
+ * | | EFI_CERT_X509_SHA384_GUID |
|
||||
+ * | | (when applicable) |
|
||||
+ * | | EFI_CERT_X509_SHA512_GUID |
|
||||
+ * | | (when applicable) |
|
||||
+ * +---------------------------------------+-----------------------------------+
|
||||
+ * | WIN_CERT_TYPE_PKCS_SIGNED_DATA | EFI_CERT_X509_GUID |
|
||||
+ * | | EFI_CERT_RSA2048_GUID |
|
||||
+ * | | (when applicable) |
|
||||
+ * | | EFI_CERT_X509_SHA256_GUID |
|
||||
+ * | | (when applicable) |
|
||||
+ * | | EFI_CERT_X509_SHA384_GUID |
|
||||
+ * | | (when applicable) |
|
||||
+ * | | EFI_CERT_X509_SHA512_GUID |
|
||||
+ * | | (when applicable) |
|
||||
+ * +---------------------------------------+-----------------------------------+
|
||||
+ * |(Always applicable regardless of | EFI_CERT_SHA1_GUID, |
|
||||
+ * | whether a certificate is present or | EFI_CERT_SHA224_GUID, |
|
||||
+ * | not) | EFI_CERT_SHA256_GUID, |
|
||||
+ * | | EFI_CERT_SHA384_GUID, |
|
||||
+ * | | EFI_CERT_SHA512_GUID |
|
||||
+ * | | In this case, the database |
|
||||
+ * | | contains the hash of the image. |
|
||||
+ * +---------------------------------------+-----------------------------------+
|
||||
+ */
|
||||
+
|
||||
+/*
|
||||
+ * hdr.cert_type = WIN_CERT_TYPE_PKCS_SIGNED_DATA
|
||||
+ */
|
||||
+typedef struct {
|
||||
+ win_certificate_header_t hdr;
|
||||
+ uint8_t data[]; // pkcs7 signedData
|
||||
+} win_certificate_pkcs_signed_data_t;
|
||||
+
|
||||
+/*
|
||||
+ * hdr.cert_type = WIN_CERT_TYPE_EFI_PKCS115
|
||||
+ */
|
||||
+typedef struct {
|
||||
+ win_certificate_header_t hdr;
|
||||
+ efi_guid_t hash_alg;
|
||||
+ uint8_t signature[];
|
||||
+} win_certificate_efi_pkcs1_15_t;
|
||||
+
|
||||
+/*
|
||||
+ * hdr.cert_type = WIN_CERT_TYPE_EFI_GUID
|
||||
+ */
|
||||
+typedef struct {
|
||||
+ win_certificate_header_t hdr;
|
||||
+ efi_guid_t type;
|
||||
+ uint8_t data[];
|
||||
+} win_certificate_uefi_guid_t;
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * public_key: pubkey that may or may not be trusted
|
||||
+ * signature: a RSA2048 signature of the SHA256 authenticode hash
|
||||
+ */
|
||||
+typedef struct {
|
||||
+ efi_guid_t hash_type;
|
||||
+ uint8_t public_key[256];
|
||||
+ uint8_t signature[256];
|
||||
+} efi_cert_rsa2048_sha256_t;
|
||||
+
|
||||
+typedef struct {
|
||||
+ uint64_t monotonic_count;
|
||||
+ win_certificate_uefi_guid_t auth_info;
|
||||
+} efi_variable_authentication_t __attribute__((aligned (1)));
|
||||
+
|
||||
+typedef struct {
|
||||
+ efi_time_t timestamp;
|
||||
+ win_certificate_uefi_guid_t auth_info;
|
||||
+} efi_variable_authentication_2_t __attribute__((aligned (1)));
|
||||
+
|
||||
+#define EFI_VARIABLE_AUTHENTICATION_3_CERT_ID_SHA256 ((uint8_t)1)
|
||||
+
|
||||
+/* XXX the spec doesn't say if this is supposed to be packed/align(1) */
|
||||
+typedef struct {
|
||||
+ uint8_t type;
|
||||
+ uint32_t id_size;
|
||||
+ uint8_t id[];
|
||||
+} efi_variable_authentication_3_cert_id_t __attribute__((aligned (1)));
|
||||
+
|
||||
+#define EFI_VARIABLE_AUTHENTICATION_3_TIMESTAMP_TYPE ((uint8_t)1)
|
||||
+#define EFI_VARIABLE_AUTHENTICATION_3_NONCE_TYPE ((uint8_t)2)
|
||||
+
|
||||
+/* XXX the spec doesn't say if this is supposed to be packed/align(1) */
|
||||
+typedef struct {
|
||||
+ uint8_t version;
|
||||
+ uint8_t type;
|
||||
+ uint32_t metadata_size; // this is everything except data[]
|
||||
+ uint32_t flags;
|
||||
+} efi_variable_authentication_3_header_t __attribute__((aligned (1)));
|
||||
+
|
||||
+#define EFI_VARIABLE_ENHANCED_AUTH_FLAG_UPDATE_CERT ((uint32_t)0x00000001)
|
||||
+
|
||||
+typedef struct {
|
||||
+ uint32_t nonce_size;
|
||||
+ uint8_t nonce[];
|
||||
+} efi_variable_authentication_3_nonce_t;
|
||||
+
|
||||
+/* XXX the spec sort of implies that this is supposed to be packed/align(1) */
|
||||
+typedef struct {
|
||||
+ efi_variable_authentication_3_header_t hdr;
|
||||
+ efi_time_t timestamp;
|
||||
+ // if EFI_VARIABLE_ENHANCED_AUTH_FLAG_UPDATE_CERT is set:
|
||||
+ // uint8_t newcert[];
|
||||
+ // uint8_t signing_cert[];
|
||||
+} efi_variable_timestamped_authentication_3 __attribute__((aligned (1)));
|
||||
+
|
||||
+/* XXX the spec sort of implies that this is supposed to be packed/align(1) */
|
||||
+typedef struct {
|
||||
+ efi_variable_authentication_3_header_t hdr;
|
||||
+ efi_variable_authentication_3_nonce_t nonce;
|
||||
+ // if EFI_VARIABLE_ENHANCED_AUTH_FLAG_UPDATE_CERT is set:
|
||||
+ // uint8_t newcert[];
|
||||
+ // uint8_t signing_cert[];
|
||||
+} efi_variable_nonced_authentication_3 __attribute__((aligned (1)));
|
||||
+
|
||||
+#endif /* !SECURITY_H_ */
|
||||
+// vim:fenc=utf-8:tw=75:noet
|
||||
diff --git a/src/include/efivar/efisec.h b/src/include/efivar/efisec.h
|
||||
index 0ee5abe8bfd..f62bcedbf6f 100644
|
||||
--- a/src/include/efivar/efisec.h
|
||||
+++ b/src/include/efivar/efisec.h
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <efivar/efivar.h>
|
||||
|
||||
+#include <efivar/efisec-types.h>
|
||||
+
|
||||
extern uint32_t efi_get_libefisec_version(void)
|
||||
__attribute__((__visibility__("default")));
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,90 +0,0 @@
|
||||
From 6ba56d23e489a38f42ed7b518bd25ae2192ed651 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 3 Feb 2020 13:50:49 -0500
|
||||
Subject: [PATCH 84/86] Add some x509 helpers.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/efisec.h | 2 ++
|
||||
src/x509.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 58 insertions(+)
|
||||
create mode 100644 src/x509.h
|
||||
|
||||
diff --git a/src/efisec.h b/src/efisec.h
|
||||
index 15d0f6d10e2..ef874da0356 100644
|
||||
--- a/src/efisec.h
|
||||
+++ b/src/efisec.h
|
||||
@@ -8,6 +8,8 @@
|
||||
#define PRIVATE_EFISEC_H_
|
||||
|
||||
#include "efivar.h"
|
||||
+#include "x509.h"
|
||||
+
|
||||
#include <efivar/efisec.h>
|
||||
|
||||
#endif /* !PRIVATE_EFISEC_H_ */
|
||||
diff --git a/src/x509.h b/src/x509.h
|
||||
new file mode 100644
|
||||
index 00000000000..16aef081bfa
|
||||
--- /dev/null
|
||||
+++ b/src/x509.h
|
||||
@@ -0,0 +1,56 @@
|
||||
+// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+/*
|
||||
+ * x509.h - X.509/ASN.1 helper functions
|
||||
+ * Copyright 2019-2020 Peter M. Jones <pjones@redhat.com>
|
||||
+ */
|
||||
+#ifndef EFIVAR_X509_H
|
||||
+#define EFIVAR_X509_H
|
||||
+
|
||||
+#define SMALLEST_POSSIBLE_DER_SEQ 3
|
||||
+
|
||||
+static inline int32_t
|
||||
+__attribute__((unused))
|
||||
+get_asn1_seq_size(uint8_t *location, uint32_t size)
|
||||
+{
|
||||
+ uint8_t i;
|
||||
+ uint8_t octets;
|
||||
+ uint32_t der_len = 0;
|
||||
+
|
||||
+ if (size < SMALLEST_POSSIBLE_DER_SEQ)
|
||||
+ return -1;
|
||||
+
|
||||
+ // If it's not a CONSTRUCTED SEQUENCE it's not a certificate
|
||||
+ if (location[0] != 0x30)
|
||||
+ return -1;
|
||||
+
|
||||
+ if (!(location[1] & 0x80)) {
|
||||
+ // Short form, which is too small to hold a certificate.
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ // Long form
|
||||
+ octets = location[1] & 0x7;
|
||||
+
|
||||
+ // There is no chance our data is more than 3GB.
|
||||
+ if (octets > 4 || (octets == 4 && (location[2] & 0x8)))
|
||||
+ return -1;
|
||||
+
|
||||
+ // and if our size won't fit in the data it's wrong as well
|
||||
+ if (size - 2 < octets)
|
||||
+ return -1;
|
||||
+
|
||||
+ for (i = 0; i < octets; i++) {
|
||||
+ der_len <<= 8;
|
||||
+ der_len |= location[i + 2];
|
||||
+ }
|
||||
+ // and if der_len is greater than what's left, it's bad too.
|
||||
+ if (size - 2 - octets < der_len)
|
||||
+ return -1;
|
||||
+
|
||||
+ // or else it's a reasonable certificate from a size point of view.
|
||||
+ return der_len + 4;
|
||||
+}
|
||||
+
|
||||
+#undef SMALLEST_POSSIBLE_DER_SEQ
|
||||
+
|
||||
+#endif
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,460 +0,0 @@
|
||||
From 8c408cbc39878f9bf9ebcc9920a245c33a2defd0 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 3 Feb 2020 13:25:40 -0500
|
||||
Subject: [PATCH 85/86] Add security types/guids and signature database
|
||||
iterators
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/Makefile | 2 +-
|
||||
src/include/efivar/efisec-secdb.h | 61 ++++++
|
||||
src/include/efivar/efisec.h | 1 +
|
||||
src/libefisec.map.in | 4 +
|
||||
src/secdb.c | 329 ++++++++++++++++++++++++++++++
|
||||
5 files changed, 396 insertions(+), 1 deletion(-)
|
||||
create mode 100644 src/include/efivar/efisec-secdb.h
|
||||
create mode 100644 src/secdb.c
|
||||
|
||||
diff --git a/src/Makefile b/src/Makefile
|
||||
index 883e058facf..a73f8f34ce9 100644
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -13,7 +13,7 @@ PCTARGETS=efivar.pc efiboot.pc efisec.pc
|
||||
TARGETS=$(LIBTARGETS) $(BINTARGETS) $(PCTARGETS)
|
||||
STATICTARGETS=$(STATICLIBTARGETS) $(STATICBINTARGETS)
|
||||
|
||||
-LIBEFISEC_SOURCES = sec.c
|
||||
+LIBEFISEC_SOURCES = sec.c secdb.c
|
||||
LIBEFISEC_OBJECTS = $(patsubst %.c,%.o,$(LIBEFISEC_SOURCES))
|
||||
LIBEFIBOOT_SOURCES = crc32.c creator.c disk.c gpt.c loadopt.c path-helpers.c \
|
||||
linux.c $(sort $(wildcard linux-*.c))
|
||||
diff --git a/src/include/efivar/efisec-secdb.h b/src/include/efivar/efisec-secdb.h
|
||||
new file mode 100644
|
||||
index 00000000000..0b7103a38d7
|
||||
--- /dev/null
|
||||
+++ b/src/include/efivar/efisec-secdb.h
|
||||
@@ -0,0 +1,61 @@
|
||||
+// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+/*
|
||||
+ * Copyright 2014-2020 Red Hat, Inc.
|
||||
+ * Copyright 2014-2020 Peter M. Jones <pjones@redhat.com>
|
||||
+ *
|
||||
+ * Author(s): Peter Jones <pjones@redhat.com>
|
||||
+ */
|
||||
+#ifndef EFISEC_SECDB_H_
|
||||
+#define EFISEC_SECDB_H_ 1
|
||||
+
|
||||
+#include <stdint.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+typedef struct efi_secdb_iter efi_secdb_iter;
|
||||
+
|
||||
+/*
|
||||
+ * efi_secdb_iter_new - create a new iterator over a efi security database
|
||||
+ * iter: pointer to a NULL efi_secdb_iter pointer.
|
||||
+ * buf: security database from the file
|
||||
+ * len: size of the file
|
||||
+ *
|
||||
+ * returns 0 on success, negative on error, sets errno.
|
||||
+ */
|
||||
+extern int efi_secdb_iter_new(efi_secdb_iter **iter, uint8_t *buf, size_t len)
|
||||
+ __attribute__((__nonnull__(1, 2)));
|
||||
+
|
||||
+/*
|
||||
+ * efi_secdb_iter_end - destroy the iterator created by efi_secdb_iter_new()
|
||||
+ * iter: the iterator being destroyed
|
||||
+ *
|
||||
+ * returns 0 on success, negative on error, sets errno.
|
||||
+ */
|
||||
+extern int efi_secdb_iter_end(efi_secdb_iter *iter)
|
||||
+ __attribute__((__nonnull__(1)));
|
||||
+
|
||||
+/*
|
||||
+ * efi_secdb_iter_next - get the next item in the list
|
||||
+ * iter: the iterator
|
||||
+ * type: the type of the entry
|
||||
+ * owner: the owner of the entry
|
||||
+ * data: the identifying data
|
||||
+ * len: the size of the data
|
||||
+ *
|
||||
+ * returns negative and sets errno on error,
|
||||
+ * 0 if there weren't any entries (type/owner/data/len are not populated)
|
||||
+ * 1 if an entry was returned.
|
||||
+ */
|
||||
+extern int efi_secdb_iter_next(efi_secdb_iter *iter, efi_guid_t *type,
|
||||
+ efi_guid_t *owner, uint8_t **data, size_t *len)
|
||||
+ __attribute__((__nonnull__(1, 2, 3, 4, 5)));
|
||||
+
|
||||
+/*
|
||||
+ * efi_secdb_iter_get_line - tell how many entries have been returned
|
||||
+ * iter: the iterator
|
||||
+ *
|
||||
+ * return value: -1 on error, with errno set, >=0 in all other cases
|
||||
+ */
|
||||
+extern int efi_secdb_iter_get_line(efi_secdb_iter *iter)
|
||||
+ __attribute__((__nonnull__(1)));
|
||||
+
|
||||
+#endif /* EFISEC_SECDB_H_ */
|
||||
diff --git a/src/include/efivar/efisec.h b/src/include/efivar/efisec.h
|
||||
index f62bcedbf6f..2072e5c9149 100644
|
||||
--- a/src/include/efivar/efisec.h
|
||||
+++ b/src/include/efivar/efisec.h
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <efivar/efivar.h>
|
||||
|
||||
#include <efivar/efisec-types.h>
|
||||
+#include <efivar/efisec-secdb.h>
|
||||
|
||||
extern uint32_t efi_get_libefisec_version(void)
|
||||
__attribute__((__visibility__("default")));
|
||||
diff --git a/src/libefisec.map.in b/src/libefisec.map.in
|
||||
index 2e732cf1d9b..50ae27df44a 100644
|
||||
--- a/src/libefisec.map.in
|
||||
+++ b/src/libefisec.map.in
|
||||
@@ -4,4 +4,8 @@ libefisec.so.0 {
|
||||
|
||||
LIBEFISEC_1.38 {
|
||||
global: efi_get_libefisec_version;
|
||||
+ efi_secdb_iter_new;
|
||||
+ efi_secdb_iter_end;
|
||||
+ efi_secdb_iter_next;
|
||||
+ efi_secdb_iter_get_line;
|
||||
} libefisec.so.0;
|
||||
diff --git a/src/secdb.c b/src/secdb.c
|
||||
new file mode 100644
|
||||
index 00000000000..e8ea0180cfd
|
||||
--- /dev/null
|
||||
+++ b/src/secdb.c
|
||||
@@ -0,0 +1,329 @@
|
||||
+// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
+/*
|
||||
+ * Copyright 2014-2020 Red Hat, Inc.
|
||||
+ * Copyright 2014-2020 Peter M. Jones <pjones@redhat.com>
|
||||
+ *
|
||||
+ * Author(s): Peter Jones <pjones@redhat.com>
|
||||
+ */
|
||||
+
|
||||
+#include "fix_coverity.h"
|
||||
+
|
||||
+#include <errno.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <inttypes.h>
|
||||
+
|
||||
+#include "efisec.h"
|
||||
+
|
||||
+typedef struct efi_secdb_list_iter efi_secdb_list_iter;
|
||||
+extern int efi_secdb_list_iter_new(efi_secdb_list_iter **iter, uint8_t *buf, size_t len);
|
||||
+extern int efi_secdb_list_iter_end(efi_secdb_list_iter *iter);
|
||||
+extern int efi_secdb_list_iter_next(efi_secdb_list_iter *iter, efi_guid_t *type,
|
||||
+ efi_signature_data_t **data, size_t *len);
|
||||
+extern int efi_secdb_list_list_size(efi_secdb_list_iter *iter, size_t *sls);
|
||||
+extern int efi_secdb_list_header_size(efi_secdb_list_iter *iter, size_t *slh);
|
||||
+extern int efi_secdb_list_sig_size(efi_secdb_list_iter *iter, size_t *ss);
|
||||
+extern int efi_secdb_list_get_type(efi_secdb_list_iter *iter, efi_guid_t *type);
|
||||
+
|
||||
+struct efi_secdb_iter {
|
||||
+ efi_secdb_list_iter *iter;
|
||||
+ int line;
|
||||
+
|
||||
+ efi_signature_data_t *esd;
|
||||
+ size_t len;
|
||||
+
|
||||
+ size_t nmemb;
|
||||
+ unsigned int i;
|
||||
+};
|
||||
+
|
||||
+int NONNULL(1, 2) PUBLIC
|
||||
+efi_secdb_iter_new(efi_secdb_iter **iter, uint8_t *buf, size_t len)
|
||||
+{
|
||||
+ int rc;
|
||||
+
|
||||
+ if (len < sizeof (efi_signature_list_t) + sizeof (efi_signature_data_t)) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ *iter = calloc(1, sizeof (efi_secdb_iter));
|
||||
+ if (!*iter)
|
||||
+ return -1;
|
||||
+
|
||||
+ rc = efi_secdb_list_iter_new(&(*iter)->iter, buf, len);
|
||||
+ if (rc < 0) {
|
||||
+ int error = errno;
|
||||
+ free(*iter);
|
||||
+ errno = error;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ (*iter)->i = -1;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int NONNULL(1) PUBLIC
|
||||
+efi_secdb_iter_end(efi_secdb_iter *iter)
|
||||
+{
|
||||
+ if (!iter) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if (iter->iter)
|
||||
+ efi_secdb_list_iter_end(iter->iter);
|
||||
+ free(iter);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int NONNULL(1, 2, 3, 4, 5) PUBLIC
|
||||
+efi_secdb_iter_next(efi_secdb_iter *iter, efi_guid_t *type,
|
||||
+ efi_guid_t *owner, uint8_t **data, size_t *len)
|
||||
+{
|
||||
+ int rc;
|
||||
+ size_t ss;
|
||||
+
|
||||
+ if (!iter)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (iter->iter == NULL)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ iter->line += 1;
|
||||
+
|
||||
+ iter->i += 1;
|
||||
+ if (iter->i == iter->nmemb) {
|
||||
+ debug("Getting next efi_signature_data_t\n");
|
||||
+ iter->i = 0;
|
||||
+ rc = efi_secdb_list_iter_next(iter->iter, type, &iter->esd, &iter->len);
|
||||
+ if (rc < 1)
|
||||
+ return rc;
|
||||
+
|
||||
+ if (!efi_guid_cmp(type, &efi_guid_x509_cert)) {
|
||||
+ int32_t asn1size;
|
||||
+
|
||||
+ asn1size = get_asn1_seq_size(iter->esd->signature_data,
|
||||
+ iter->len - sizeof (iter->esd->signature_owner));
|
||||
+
|
||||
+ if (asn1size < 0) {
|
||||
+ debug("iterator data claims to be an X.509 Cert but is not valid ASN.1 DER");
|
||||
+ } else if ((uint32_t)asn1size != iter->len -
|
||||
+ sizeof (iter->esd->signature_owner)) {
|
||||
+ debug("X.509 Cert ASN.1 size does not match signature_List Size (%d vs %zu)",
|
||||
+ asn1size, iter->len -
|
||||
+ sizeof (iter->esd->signature_owner));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ size_t sls, slh;
|
||||
+ rc = efi_secdb_list_list_size(iter->iter, &sls);
|
||||
+ if (rc < 0)
|
||||
+ return rc;
|
||||
+
|
||||
+ rc = efi_secdb_list_header_size(iter->iter, &slh);
|
||||
+ if (rc < 0)
|
||||
+ return rc;
|
||||
+
|
||||
+ rc = efi_secdb_list_sig_size(iter->iter, &ss);
|
||||
+ if (rc < 0)
|
||||
+ return rc;
|
||||
+
|
||||
+ /* if we'd have leftover data, then this ESD is garbage. */
|
||||
+ if ((sls - sizeof (efi_signature_list_t) - slh) % ss != 0)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ iter->nmemb = (sls - sizeof (efi_signature_list_t) - slh) / ss;
|
||||
+ } else {
|
||||
+ debug("Getting next esd element\n");
|
||||
+ rc = efi_secdb_list_sig_size(iter->iter, &ss);
|
||||
+ if (rc < 0)
|
||||
+ return rc;
|
||||
+
|
||||
+ iter->esd = (efi_signature_data_t *)((intptr_t)iter->esd + ss);
|
||||
+ }
|
||||
+
|
||||
+ rc = efi_secdb_list_get_type(iter->iter, type);
|
||||
+ if (rc < 0)
|
||||
+ return rc;
|
||||
+
|
||||
+ *owner = iter->esd->signature_owner;
|
||||
+ *data = iter->esd->signature_data;
|
||||
+ *len = ss - sizeof (iter->esd->signature_owner);
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+int NONNULL(1) PUBLIC
|
||||
+efi_secdb_iter_get_line(efi_secdb_iter *iter)
|
||||
+{
|
||||
+ if (!iter) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ return iter->line;
|
||||
+}
|
||||
+
|
||||
+struct efi_secdb_list_iter {
|
||||
+ uint8_t *buf;
|
||||
+ size_t len;
|
||||
+
|
||||
+ off_t offset;
|
||||
+
|
||||
+ efi_signature_list_t *esl;
|
||||
+};
|
||||
+
|
||||
+int NONNULL(1, 2)
|
||||
+efi_secdb_list_iter_new(efi_secdb_list_iter **iter, uint8_t *buf, size_t len)
|
||||
+{
|
||||
+ if (len < sizeof (efi_signature_list_t) + sizeof (efi_signature_data_t)) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ *iter = calloc(1, sizeof (efi_secdb_list_iter));
|
||||
+ if (!*iter)
|
||||
+ return -1;
|
||||
+
|
||||
+ (*iter)->buf = buf;
|
||||
+ (*iter)->len = len;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int NONNULL(1)
|
||||
+efi_secdb_list_iter_end(efi_secdb_list_iter *iter)
|
||||
+{
|
||||
+ if (!iter) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ free(iter);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int NONNULL(1, 2, 3, 4)
|
||||
+efi_secdb_list_iter_next(efi_secdb_list_iter *iter, efi_guid_t *type,
|
||||
+ efi_signature_data_t **data, size_t *len)
|
||||
+{
|
||||
+ if (!iter)
|
||||
+ return -EINVAL;
|
||||
+ if (iter->offset < 0)
|
||||
+ return -EINVAL;
|
||||
+ if ((uint32_t)iter->offset >= iter->len)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (!iter->esl) {
|
||||
+ debug("Getting next ESL buffer\n");
|
||||
+ iter->esl = (efi_signature_list_t *)iter->buf;
|
||||
+ } else {
|
||||
+ debug("Getting next efi_signature_list_t\n");
|
||||
+ efi_guid_t type;
|
||||
+ efi_secdb_list_get_type(iter, &type);
|
||||
+ if (iter->len - iter->offset < iter->esl->signature_list_size) {
|
||||
+ debug("EFI signature_ List is malformed");
|
||||
+ debug("list has %lu bytes left, element is %"PRIu32" bytes",
|
||||
+ iter->len - iter->offset,
|
||||
+ iter->esl->signature_list_size);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if (!efi_guid_cmp(&type, &efi_guid_x509_cert)) {
|
||||
+ int32_t asn1size;
|
||||
+
|
||||
+ asn1size = get_asn1_seq_size(
|
||||
+ ((uint8_t *)*data) + sizeof (efi_guid_t),
|
||||
+ *len - sizeof (efi_guid_t));
|
||||
+ if (asn1size < 0) {
|
||||
+ debug("iterator data claims to be an X.509 Cert but is not valid ASN.1 DER");
|
||||
+ } else if ((uint32_t)asn1size != iter->esl->signature_size
|
||||
+ - sizeof (efi_guid_t)) {
|
||||
+ debug("X.509 Cert ASN.1 size does not match signature_List Size (%d vs %zu)",
|
||||
+ asn1size, iter->esl->signature_size -
|
||||
+ sizeof (efi_guid_t));
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ iter->offset += iter->esl->signature_list_size;
|
||||
+ if ((uint32_t)iter->offset >= iter->len)
|
||||
+ return 0;
|
||||
+ iter->esl = (efi_signature_list_t *)((intptr_t)iter->buf
|
||||
+ + iter->offset);
|
||||
+ }
|
||||
+
|
||||
+ efi_signature_list_t esl;
|
||||
+ memset(&esl, '\0', sizeof (esl));
|
||||
+ /* if somehow we've gotten a buffer that's bigger than our
|
||||
+ * real list, this will be zeros, so we've hit the end. */
|
||||
+ if (!memcmp(&esl, iter->esl, sizeof (esl)))
|
||||
+ return 0;
|
||||
+
|
||||
+ /* if this list size is too big for our data, then it's malformed
|
||||
+ * data and we're done. */
|
||||
+ if (iter->esl->signature_list_size > iter->len - iter->offset)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ *type = iter->esl->signature_type;
|
||||
+ *data = (efi_signature_data_t *)((intptr_t)iter->esl
|
||||
+ + sizeof (efi_signature_list_t)
|
||||
+ + iter->esl->signature_header_size);
|
||||
+ *len = iter->esl->signature_list_size - sizeof (efi_signature_list_t);
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+int NONNULL(1, 2)
|
||||
+efi_secdb_list_list_size(efi_secdb_list_iter *iter, size_t *sls)
|
||||
+{
|
||||
+ if (!iter || !iter->esl) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ /* this has to be at least as large as its header to be valid */
|
||||
+ if (iter->esl->signature_list_size < sizeof (efi_signature_list_t)) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ *sls = iter->esl->signature_list_size;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int NONNULL(1, 2)
|
||||
+efi_secdb_list_header_size(efi_secdb_list_iter *iter, size_t *slh)
|
||||
+{
|
||||
+ if (!iter || !iter->esl) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ *slh = iter->esl->signature_header_size;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int NONNULL(1, 2)
|
||||
+efi_secdb_list_sig_size(efi_secdb_list_iter *iter, size_t *ss)
|
||||
+{
|
||||
+ if (!iter || !iter->esl) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ /* If signature size isn't positive, there's invalid data. */
|
||||
+ if (iter->esl->signature_size < 1) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ *ss = iter->esl->signature_size;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int NONNULL(1, 2)
|
||||
+efi_secdb_list_get_type(efi_secdb_list_iter *iter, efi_guid_t *type)
|
||||
+{
|
||||
+ if (!iter || !iter->esl) {
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(type, &iter->esl->signature_type, sizeof (*type));
|
||||
+ return 0;
|
||||
+}
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,57 +0,0 @@
|
||||
From a9ad43032acfcd8c69cd8ca651b532fac9d28847 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 19 Feb 2020 09:57:44 -0500
|
||||
Subject: [PATCH 86/86] Make declaring efi_time_t conditional on
|
||||
EFIVAR_NO_EFI_TIME_T
|
||||
|
||||
This allows you to turn off declaration of efi_time_t and related
|
||||
functions in the case where it's declared someplace else, such as in
|
||||
some local code or another library's headers.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
src/include/efivar/efivar-time.h | 6 +++++-
|
||||
src/include/efivar/efivar-types.h | 2 ++
|
||||
2 files changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/include/efivar/efivar-time.h b/src/include/efivar/efivar-time.h
|
||||
index 04c243601f5..ebe2a703ed4 100644
|
||||
--- a/src/include/efivar/efivar-time.h
|
||||
+++ b/src/include/efivar/efivar-time.h
|
||||
@@ -4,8 +4,12 @@
|
||||
* Copyright 2020 Peter Jones <pjones@redhat.com>
|
||||
*/
|
||||
|
||||
+#if defined(EFIVAR_NO_EFI_TIME_T) && EFIVAR_NO_EFI_TIME_T && !defined(EFIVAR_TIME_H_)
|
||||
+#define EFIVAR_TIME_H_ 1
|
||||
+#endif
|
||||
+
|
||||
#ifndef EFIVAR_TIME_H_
|
||||
-#define EFIVAR_TIME_H_
|
||||
+#define EFIVAR_TIME_H_ 1
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
diff --git a/src/include/efivar/efivar-types.h b/src/include/efivar/efivar-types.h
|
||||
index ce22b6c12b3..ebba511b17b 100644
|
||||
--- a/src/include/efivar/efivar-types.h
|
||||
+++ b/src/include/efivar/efivar-types.h
|
||||
@@ -51,6 +51,7 @@ typedef uint16_t efi_char16_t;
|
||||
typedef unsigned long uintn_t;
|
||||
typedef long intn_t;
|
||||
|
||||
+#if !defined(EFIVAR_NO_EFI_TIME_T) || EFIVAR_NO_EFI_TIME_T
|
||||
#define EFIVAR_HAVE_EFI_TIME_T 1
|
||||
|
||||
/*
|
||||
@@ -83,6 +84,7 @@ typedef struct {
|
||||
#define EFI_TIME_IN_DAYLIGHT ((uint8_t)0x02)
|
||||
|
||||
#define EFI_UNSPECIFIED_TIMEZONE ((uint16_t)0x07ff)
|
||||
+#endif /* !defined(EFIVAR_NO_EFI_TIME_T) || EFIVAR_NO_EFI_TIME_T */
|
||||
|
||||
#define EFI_VARIABLE_NON_VOLATILE ((uint64_t)0x0000000000000001)
|
||||
#define EFI_VARIABLE_BOOTSERVICE_ACCESS ((uint64_t)0x0000000000000002)
|
||||
--
|
||||
2.24.1
|
||||
|
@ -1,78 +0,0 @@
|
||||
Patch0001: 0001-util.h-add-unlikely-and-likely-macros.patch
|
||||
Patch0002: 0002-dp.h-make-format_guid-handle-misaligned-guid-pointer.patch
|
||||
Patch0003: 0003-linux-pci-root-remove-an-unused-assignment.patch
|
||||
Patch0004: 0004-Fix-all-the-places-Werror-address-of-packed-member-c.patch
|
||||
Patch0005: 0005-Get-rid-of-the-arrows-in-our-debug-messages.patch
|
||||
Patch0006: 0006-Define-strdupa-if-it-is-not-defined.patch
|
||||
Patch0007: 0007-Android-inital-porting-of-libefivar.patch
|
||||
Patch0008: 0008-Remove-an-unused-function.patch
|
||||
Patch0009: 0009-Fix-another-error-of-Werror-address-of-packed-member.patch
|
||||
Patch0010: 0010-ucs2.h-remove-unused-variable.patch
|
||||
Patch0011: 0011-ucs2.h-fix-logic-that-checks-for-UCS-2-string-termin.patch
|
||||
Patch0012: 0012-dp-message-fix-efidp_ipv4_addr-fields-assignment.patch
|
||||
Patch0013: 0013-Always-refer-to-MBR-and-GPT-fixed-values-as-magic-no.patch
|
||||
Patch0014: 0014-Add-more-hexdump-logging-functions.patch
|
||||
Patch0015: 0015-Add-efi_error_pop-and-pop-some-errors-sometimes.patch
|
||||
Patch0016: 0016-Always-log-to-a-memfd-regardless-of-loglevel.patch
|
||||
Patch0017: 0017-Always-initialize-any-variable-we-use-with-sscanf-s-.patch
|
||||
Patch0018: 0018-Add-efi_get_libefivar_version-and-efi_get_libefiboot.patch
|
||||
Patch0019: 0019-Fix-dbglog_seek-to-update-the-offset.patch
|
||||
Patch0020: 0020-Update-efivar-37-.abixml-for-new-libabigail-version.patch
|
||||
Patch0021: 0021-Fix-up-efi_guid_cmp-s-alignment-problem-a-different-.patch
|
||||
Patch0022: 0022-Fix-dbglog_write-to-always-return-the-status-of-writ.patch
|
||||
Patch0023: 0023-Do-a-better-job-of-making-sure-DLIBEFIVAR_VERSION-ha.patch
|
||||
Patch0024: 0024-efi_stash_loglevel_-efi_set_loglevel.patch
|
||||
Patch0025: 0025-guids-add-grub-guid-for-grubenv.patch
|
||||
Patch0026: 0026-gcc.specs-add-grecord-gcc-switches.patch
|
||||
Patch0027: 0027-Makefile-don-t-echo-our-deps-submake-invocation.patch
|
||||
Patch0028: 0028-Make-Add-some-more-stuff-to-the-toplevel-clean.patch
|
||||
Patch0029: 0029-Make-scan-build-rules-slightly-more-intuitive.patch
|
||||
Patch0030: 0030-Local-header-whitespace-cleanup.patch
|
||||
Patch0031: 0031-Exported-header-whitespace-cleanup.patch
|
||||
Patch0032: 0032-Main-code-whitespace-cleanup.patch
|
||||
Patch0033: 0033-efivar-rework-usage.patch
|
||||
Patch0034: 0034-Try-to-deal-with-some-signof-char-signof-uint8_t-mad.patch
|
||||
Patch0035: 0035-ucs2-document-things-a-little-better.patch
|
||||
Patch0036: 0036-util.h-implement-add-mul-sub-for-more-integer-types.patch
|
||||
Patch0037: 0037-Implement-efivar-export-foo.var.patch
|
||||
Patch0038: 0038-Add-some-test-cases-for-efivar-export-import.patch
|
||||
Patch0039: 0039-Fix-a-case-clang-analyzer-found-where-we-may-try-to-.patch
|
||||
Patch0040: 0040-Make-sure-makeguids-helper-is-compiled-for-the-host-.patch
|
||||
Patch0041: 0041-Makefile-sort-wildcard-output-for-reproducibility.patch
|
||||
Patch0042: 0042-guids.txt-correct-sentinal-typo.patch
|
||||
Patch0043: 0043-update-manpage-for-efivar-such-that-it-reflects-the-.patch
|
||||
Patch0044: 0044-Fix-some-32-bit-size_t-format-specifier-errors.patch
|
||||
Patch0045: 0045-Make-the-top-level-makefile-not-parallelize.patch
|
||||
Patch0046: 0046-guids-add-auto_created_boot_option.patch
|
||||
Patch0047: 0047-Move-our-infrastructure-makefiles-out-of-the-topdir.patch
|
||||
Patch0048: 0048-Make-CC_FOR_BUILD-and-CCLD_FOR_BUILD-override-HOSTCC.patch
|
||||
Patch0049: 0049-Rework-some-makefile-bits-to-make-overriding-some-op.patch
|
||||
Patch0050: 0050-Make-add-Wno-missing-field-initializers.patch
|
||||
Patch0051: 0051-debug-don-t-write-newlines-to-memfd.patch
|
||||
Patch0052: 0052-sysfs-parsing-add-some-more-debugging-output.patch
|
||||
Patch0053: 0053-gitignore-ignore-.strace.patch
|
||||
Patch0054: 0054-Fix-the-error-path-in-set_disk_and_part_name.patch
|
||||
Patch0055: 0055-sysfs-parsers-make-all-the-sys-block-link-parsers-wo.patch
|
||||
Patch0056: 0056-Improve-consistency-of-debug-prints.patch
|
||||
Patch0057: 0057-Try-even-harder-to-find-disk-device-symlinks-in-sysf.patch
|
||||
Patch0058: 0058-Handle-sys-devices-virtual-nvme-fabrics-nvme-subsyst.patch
|
||||
Patch0059: 0059-Put-some-EFI-device-paths-into-the-debug-log.patch
|
||||
Patch0060: 0060-Update-abixml.patch
|
||||
Patch0061: 0061-Update-abixml-files-and-work-around-some-inconsequen.patch
|
||||
Patch0062: 0062-Don-t-use-march-native-on-ia64.patch
|
||||
Patch0063: 0063-Work-around-autoconf-existing-in-the-world.patch
|
||||
Patch0064: 0064-Fix-efivar-w-and-efivar-a.patch
|
||||
Patch0065: 0065-Android-fix-incorrect-include-path.patch
|
||||
Patch0066: 0066-Android-fix-missing-field-initializers.patch
|
||||
Patch0067: 0067-Fix-variable-sz-uninitialized-error.patch
|
||||
Patch0068: 0068-Fix-an-argument-mismatch-error.patch
|
||||
Patch0069: 0069-Android-fix-building-errors.patch
|
||||
Patch0070: 0070-Fix-the-MSDOS_MBR_MAGIC-type-not-the-format-string.patch
|
||||
Patch0071: 0071-Make-scan-build-and-CC-clang-work-again.patch
|
||||
Patch0072: 0072-Remove-a-dead-store.patch
|
||||
Patch0073: 0073-makeguids-confuse-ccc-analyzer-less.patch
|
||||
Patch0074: 0074-SPDX-ify-all-the-license-text-in-source-files.patch
|
||||
Patch0075: 0075-Makefile-minor-typo-fix.patch
|
||||
Patch0076: 0076-util.h-minor-whitespace-cleanup.patch
|
||||
Patch0077: 0077-util.h-make-strdupa-and-strndupa-pass-NULL-straight-.patch
|
||||
Patch0078: 0078-Update-travis-to-use-a-newer-distro.patch
|
38
efivar.spec
38
efivar.spec
@ -1,30 +1,24 @@
|
||||
Name: efivar
|
||||
Version: 37
|
||||
Release: 17%{?dist}
|
||||
Version: 38
|
||||
Release: 1%{?dist}
|
||||
Summary: Tools to manage UEFI variables
|
||||
License: LGPL-2.1
|
||||
License: LGPL-2.1-only
|
||||
URL: https://github.com/rhboot/efivar
|
||||
Requires: %{name}-libs = %{version}-%{release}
|
||||
ExclusiveArch: %{efi}
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: efi-srpm-macros git glibc-static libabigail
|
||||
BuildRequires: make
|
||||
BuildRequires: make
|
||||
BuildRequires: git
|
||||
# please don't fix this to reflect github's incomprehensible url that goes
|
||||
# to a different tarball.
|
||||
Source0: https://github.com/rhboot/efivar/releases/download/%{version}/efivar-%{version}.tar.bz2
|
||||
Source1: efivar.patches
|
||||
|
||||
# include patches
|
||||
%include %{SOURCE1}
|
||||
|
||||
# Source1 patches reflect a git snapshot, this is a separate fix on top
|
||||
# with a gap in between
|
||||
Patch100: 0001-Fix-sys-block-sysfs-parsing-for-eMMC-s.patch
|
||||
# Fix XML ABI dumps that were generated with a faulty GCC and missed the
|
||||
# variadic arguments when building without LTO, bug #1863475,
|
||||
# <https://github.com/rhboot/efivar/issues/165>
|
||||
Patch101: 0001-Fix-abidw-output-for-missing-variadic-arguments.patch
|
||||
|
||||
%description
|
||||
efivar provides a simple command line interface to the UEFI variable facility.
|
||||
|
||||
@ -57,6 +51,11 @@ git config --unset user.name
|
||||
# incompatible with LTO. Disable LTO
|
||||
%define _lto_cflags %{nil}
|
||||
|
||||
# mandoc isn't packaged in RHEL, so do... this.
|
||||
for f in efisecdb.1; do
|
||||
cp docs/"$f".mdoc docs/"$f"
|
||||
done
|
||||
|
||||
make LIBDIR=%{_libdir} BINDIR=%{_bindir} CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS"
|
||||
|
||||
%install
|
||||
@ -75,6 +74,7 @@ make abicheck
|
||||
%license COPYING
|
||||
%doc README.md
|
||||
%{_bindir}/efivar
|
||||
%{_bindir}/efisecdb
|
||||
%exclude %{_bindir}/efivar-static
|
||||
%{_mandir}/man1/*
|
||||
|
||||
@ -88,12 +88,16 @@ make abicheck
|
||||
%{_libdir}/*.so.*
|
||||
|
||||
%changelog
|
||||
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com>
|
||||
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
|
||||
Related: rhbz#1991688
|
||||
* Tue Feb 01 2022 Robbie Harwood <rharwood@redhat.com> - 38-1
|
||||
- New upstream release (38)
|
||||
- Resolves: #2024374
|
||||
|
||||
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com>
|
||||
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
|
||||
* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org>
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
|
||||
|
||||
* Thu Jun 17 2021 Javier Martinez Canillas <javierm@redhat.com> - 37-16
|
||||
- Enable Intel Control-flow Enforcement Technology (CET)
|
||||
Resolves: rhbz#1808811
|
||||
|
||||
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org>
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||
|
2
sources
2
sources
@ -1 +1 @@
|
||||
SHA512 (efivar-37.tar.bz2) = 305a82ed103c7e3d8f723934019d552677c73558768dd5341f87d0364f5c60824d24f5a8e1bf90075e825908085083d4ecdccec5ac757fd38ee6ac8fea28c3e4
|
||||
SHA512 (efivar-38.tar.bz2) = c2f17297c863ece134a9dd758d237fd2df8c8d072f87af1d0bf2bcf9acfc7a53c25597f03fd4fb8cc664b205743d4ffa0ef1b068d0f73c58fa573d40993f3155
|
||||
|
Loading…
Reference in New Issue
Block a user