Merge ~juliank/grub/+git/ubuntu:ubuntu into ~ubuntu-core-dev/grub/+git/ubuntu:ubuntu
- Git
- lp:~juliank/grub/+git/ubuntu
- ubuntu
- Merge into ubuntu
Status: | Merged |
---|---|
Merged at revision: | ab6f97c7c85cfdc0558dc0af95a6ce0b2050653e |
Proposed branch: | ~juliank/grub/+git/ubuntu:ubuntu |
Merge into: | ~ubuntu-core-dev/grub/+git/ubuntu:ubuntu |
Diff against target: |
196 lines (+119/-2) 5 files modified
debian/.git-dpm (+2/-2) debian/changelog (+6/-0) debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch (+86/-0) debian/patches/series (+1/-0) grub-core/commands/smbios.c (+24/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Coulson (community) | Approve | ||
Dimitri John Ledkov | Approve | ||
Review via email: mp+380548@code.launchpad.net |
Commit message
Description of the change
Julian Andres Klode (juliank) wrote : | # |
Dimitri John Ledkov (xnox) wrote : | # |
One could have implemented the filtering without a new memory allocation; but that has been discussed on the upstream mailing list and this implementation is more trivial.
Chris Coulson (chrisccoulson) wrote : | # |
This looks ok to me.
Seth Arnold (seth-arnold) wrote : | # |
I've marked a spot where a char comparison may not necessarily be useful on systems with signed-by-default chars like the s390. Does this code ever run on any of those architectures?
Thanks
Dimitri John Ledkov (xnox) wrote : | # |
No, s390x does not use grub. It uses zipl (z itial program load).
PowerPC uses prep partitions & petiboot.
Some armhf, arm64, riscv64 use grub.
Amd64 uses grub.
i386 is dead to us.
On Wed, 11 Mar 2020, 17:00 Seth Arnold, <email address hidden> wrote:
> I've marked a spot where a char comparison may not necessarily be useful
> on systems with signed-by-default chars like the s390. Does this code ever
> run on any of those architectures?
>
> Thanks
>
> Diff comments:
>
> > diff --git
> a/debian/
> b/debian/
> > new file mode 100644
> > index 0000000..f656509
> > --- /dev/null
> > +++
> b/debian/
> > @@ -0,0 +1,86 @@
> > +From 79d4ae1df7b63ef
> > +From: Julian Andres Klode <email address hidden>
> > +Date: Tue, 3 Mar 2020 16:06:34 +0100
> > +Subject: smbios: Add a --linux argument to apply linux modalias-like
> filtering
> > +
> > +Linux creates modalias strings by filtering out non-ASCII, space,
> > +and colon characters. Provide an option that does the same filtering
> > +so people can create a modalias string in GRUB, and then match their
> > +modalias patterns against it.
> > +
> > +Signed-off-by: Julian Andres Klode <email address hidden>
> > +Reviewed-by: Daniel Kiper <email address hidden>
> > +Origin: upstream,
> https:/
> > +---
> > + grub-core/
> > + 1 file changed, 24 insertions(+)
> > +
> > +diff --git a/grub-
> > +index 7a6a391fc.
> > +--- a/grub-
> > ++++ b/grub-
> > +@@ -64,6 +64,21 @@ grub_smbios_
> > + return eps;
> > + }
> > +
> > ++static char *
> > ++linux_string (const char *value)
> > ++{
> > ++ char *out = grub_malloc( grub_strlen (value) + 1);
> > ++ const char *src = value;
> > ++ char *dst = out;
> > ++
> > ++ for (; *src; src++)
> > ++ if (*src > ' ' && *src < 127 && *src != ':')
>
> Is grub ever used on architectures with signed-by-default chars like
> s390x? (Are there others?)
>
> > ++ *dst++ = *src;
> > ++
> > ++ *dst = 0;
> > ++ return out;
> > ++}
> > ++
> > + /*
> > + * These functions convert values from the various SMBIOS structure
> field types
> > + * into a string formatted to be returned to the user. They expect
> that the
> > +@@ -176,6 +191,7 @@ static const struct {
> > + /* List command options, with structure field getters ordered as
> above. */
> > + #define FIRST_GETTER_OPT (3)
> > + #define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(
> > ++#define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(
> > +
> > + static const struct grub_arg_option options[] = {
> > + {"type", 't', 0, N_("Match structures with the given type."),
> > +@@ -198,6 +214,8 @@ static const struct grub_arg_option options[] = {
> >...
Preview Diff
1 | diff --git a/debian/.git-dpm b/debian/.git-dpm | |||
2 | index 77b21d2..89761e2 100644 | |||
3 | --- a/debian/.git-dpm | |||
4 | +++ b/debian/.git-dpm | |||
5 | @@ -1,6 +1,6 @@ | |||
6 | 1 | # see git-dpm(1) from git-dpm package | 1 | # see git-dpm(1) from git-dpm package |
9 | 2 | 3fd849d69e8213885f3fe4b6ad88cf6a41a7b863 | 2 | 79d4ae1df7b63ef106a85ad18bfedb6d709ef29a |
10 | 3 | 3fd849d69e8213885f3fe4b6ad88cf6a41a7b863 | 3 | 79d4ae1df7b63ef106a85ad18bfedb6d709ef29a |
11 | 4 | 578bb115fbd47e1c464696f1f8d6183e5443975d | 4 | 578bb115fbd47e1c464696f1f8d6183e5443975d |
12 | 5 | 578bb115fbd47e1c464696f1f8d6183e5443975d | 5 | 578bb115fbd47e1c464696f1f8d6183e5443975d |
13 | 6 | grub2_2.04.orig.tar.xz | 6 | grub2_2.04.orig.tar.xz |
14 | diff --git a/debian/changelog b/debian/changelog | |||
15 | index e36f7a8..aa3f194 100644 | |||
16 | --- a/debian/changelog | |||
17 | +++ b/debian/changelog | |||
18 | @@ -1,3 +1,9 @@ | |||
19 | 1 | grub2 (2.04-1ubuntu22) UNRELEASED; urgency=medium | ||
20 | 2 | |||
21 | 3 | * smbios: Add a --linux argument to apply linux modalias-like filtering | ||
22 | 4 | |||
23 | 5 | -- Julian Andres Klode <juliank@ubuntu.com> Wed, 11 Mar 2020 14:16:40 +0100 | ||
24 | 6 | |||
25 | 1 | grub2 (2.04-1ubuntu21) focal; urgency=medium | 7 | grub2 (2.04-1ubuntu21) focal; urgency=medium |
26 | 2 | 8 | ||
27 | 3 | * Make ZFS menu generation depending on new zsysd binary instead of eoan | 9 | * Make ZFS menu generation depending on new zsysd binary instead of eoan |
28 | diff --git a/debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch b/debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch | |||
29 | 4 | new file mode 100644 | 10 | new file mode 100644 |
30 | index 0000000..f656509 | |||
31 | --- /dev/null | |||
32 | +++ b/debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch | |||
33 | @@ -0,0 +1,86 @@ | |||
34 | 1 | From 79d4ae1df7b63ef106a85ad18bfedb6d709ef29a Mon Sep 17 00:00:00 2001 | ||
35 | 2 | From: Julian Andres Klode <julian.klode@canonical.com> | ||
36 | 3 | Date: Tue, 3 Mar 2020 16:06:34 +0100 | ||
37 | 4 | Subject: smbios: Add a --linux argument to apply linux modalias-like filtering | ||
38 | 5 | |||
39 | 6 | Linux creates modalias strings by filtering out non-ASCII, space, | ||
40 | 7 | and colon characters. Provide an option that does the same filtering | ||
41 | 8 | so people can create a modalias string in GRUB, and then match their | ||
42 | 9 | modalias patterns against it. | ||
43 | 10 | |||
44 | 11 | Signed-off-by: Julian Andres Klode <julian.klode@canonical.com> | ||
45 | 12 | Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> | ||
46 | 13 | Origin: upstream, https://git.savannah.gnu.org/cgit/grub.git/commit/?id=87049f9716fb095aecb595fb8f45497bbbb1b4a2 | ||
47 | 14 | --- | ||
48 | 15 | grub-core/commands/smbios.c | 24 ++++++++++++++++++++++++ | ||
49 | 16 | 1 file changed, 24 insertions(+) | ||
50 | 17 | |||
51 | 18 | diff --git a/grub-core/commands/smbios.c b/grub-core/commands/smbios.c | ||
52 | 19 | index 7a6a391fc..1a9086ddd 100644 | ||
53 | 20 | --- a/grub-core/commands/smbios.c | ||
54 | 21 | +++ b/grub-core/commands/smbios.c | ||
55 | 22 | @@ -64,6 +64,21 @@ grub_smbios_get_eps3 (void) | ||
56 | 23 | return eps; | ||
57 | 24 | } | ||
58 | 25 | |||
59 | 26 | +static char * | ||
60 | 27 | +linux_string (const char *value) | ||
61 | 28 | +{ | ||
62 | 29 | + char *out = grub_malloc( grub_strlen (value) + 1); | ||
63 | 30 | + const char *src = value; | ||
64 | 31 | + char *dst = out; | ||
65 | 32 | + | ||
66 | 33 | + for (; *src; src++) | ||
67 | 34 | + if (*src > ' ' && *src < 127 && *src != ':') | ||
68 | 35 | + *dst++ = *src; | ||
69 | 36 | + | ||
70 | 37 | + *dst = 0; | ||
71 | 38 | + return out; | ||
72 | 39 | +} | ||
73 | 40 | + | ||
74 | 41 | /* | ||
75 | 42 | * These functions convert values from the various SMBIOS structure field types | ||
76 | 43 | * into a string formatted to be returned to the user. They expect that the | ||
77 | 44 | @@ -176,6 +191,7 @@ static const struct { | ||
78 | 45 | /* List command options, with structure field getters ordered as above. */ | ||
79 | 46 | #define FIRST_GETTER_OPT (3) | ||
80 | 47 | #define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors)) | ||
81 | 48 | +#define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors) + 1) | ||
82 | 49 | |||
83 | 50 | static const struct grub_arg_option options[] = { | ||
84 | 51 | {"type", 't', 0, N_("Match structures with the given type."), | ||
85 | 52 | @@ -198,6 +214,8 @@ static const struct grub_arg_option options[] = { | ||
86 | 53 | N_("offset"), ARG_TYPE_INT}, | ||
87 | 54 | {"set", '\0', 0, N_("Store the value in the given variable name."), | ||
88 | 55 | N_("variable"), ARG_TYPE_STRING}, | ||
89 | 56 | + {"linux", '\0', 0, N_("Filter the result like linux does."), | ||
90 | 57 | + N_("variable"), ARG_TYPE_NONE}, | ||
91 | 58 | {0, 0, 0, 0, 0, 0} | ||
92 | 59 | }; | ||
93 | 60 | |||
94 | 61 | @@ -261,6 +279,7 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt, | ||
95 | 62 | |||
96 | 63 | const grub_uint8_t *structure; | ||
97 | 64 | const char *value; | ||
98 | 65 | + char *modified_value = NULL; | ||
99 | 66 | grub_int32_t option; | ||
100 | 67 | grub_int8_t field_type = -1; | ||
101 | 68 | grub_uint8_t i; | ||
102 | 69 | @@ -334,12 +353,17 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt, | ||
103 | 70 | return grub_error (GRUB_ERR_IO, | ||
104 | 71 | N_("failed to retrieve the structure field")); | ||
105 | 72 | |||
106 | 73 | + if (state[LINUX_OPT].set) | ||
107 | 74 | + value = modified_value = linux_string (value); | ||
108 | 75 | + | ||
109 | 76 | /* Store or print the formatted value. */ | ||
110 | 77 | if (state[SETTER_OPT].set) | ||
111 | 78 | grub_env_set (state[SETTER_OPT].arg, value); | ||
112 | 79 | else | ||
113 | 80 | grub_printf ("%s\n", value); | ||
114 | 81 | |||
115 | 82 | + grub_free(modified_value); | ||
116 | 83 | + | ||
117 | 84 | return GRUB_ERR_NONE; | ||
118 | 85 | } | ||
119 | 86 | |||
120 | diff --git a/debian/patches/series b/debian/patches/series | |||
121 | index bb417c4..4666699 100644 | |||
122 | --- a/debian/patches/series | |||
123 | +++ b/debian/patches/series | |||
124 | @@ -73,3 +73,4 @@ cherrypick-lsefisystab-define-smbios3.patch | |||
125 | 73 | cherrypick-smbios-module.patch | 73 | cherrypick-smbios-module.patch |
126 | 74 | cherrypick-lsefisystab-show-dtb.patch | 74 | cherrypick-lsefisystab-show-dtb.patch |
127 | 75 | 0075-uefi-firmware-rename-fwsetup-menuentry-to-UEFI-Firmw.patch | 75 | 0075-uefi-firmware-rename-fwsetup-menuentry-to-UEFI-Firmw.patch |
128 | 76 | 0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch | ||
129 | diff --git a/grub-core/commands/smbios.c b/grub-core/commands/smbios.c | |||
130 | index 7a6a391..1a9086d 100644 | |||
131 | --- a/grub-core/commands/smbios.c | |||
132 | +++ b/grub-core/commands/smbios.c | |||
133 | @@ -64,6 +64,21 @@ grub_smbios_get_eps3 (void) | |||
134 | 64 | return eps; | 64 | return eps; |
135 | 65 | } | 65 | } |
136 | 66 | 66 | ||
137 | 67 | static char * | ||
138 | 68 | linux_string (const char *value) | ||
139 | 69 | { | ||
140 | 70 | char *out = grub_malloc( grub_strlen (value) + 1); | ||
141 | 71 | const char *src = value; | ||
142 | 72 | char *dst = out; | ||
143 | 73 | |||
144 | 74 | for (; *src; src++) | ||
145 | 75 | if (*src > ' ' && *src < 127 && *src != ':') | ||
146 | 76 | *dst++ = *src; | ||
147 | 77 | |||
148 | 78 | *dst = 0; | ||
149 | 79 | return out; | ||
150 | 80 | } | ||
151 | 81 | |||
152 | 67 | /* | 82 | /* |
153 | 68 | * These functions convert values from the various SMBIOS structure field types | 83 | * These functions convert values from the various SMBIOS structure field types |
154 | 69 | * into a string formatted to be returned to the user. They expect that the | 84 | * into a string formatted to be returned to the user. They expect that the |
155 | @@ -176,6 +191,7 @@ static const struct { | |||
156 | 176 | /* List command options, with structure field getters ordered as above. */ | 191 | /* List command options, with structure field getters ordered as above. */ |
157 | 177 | #define FIRST_GETTER_OPT (3) | 192 | #define FIRST_GETTER_OPT (3) |
158 | 178 | #define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors)) | 193 | #define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors)) |
159 | 194 | #define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors) + 1) | ||
160 | 179 | 195 | ||
161 | 180 | static const struct grub_arg_option options[] = { | 196 | static const struct grub_arg_option options[] = { |
162 | 181 | {"type", 't', 0, N_("Match structures with the given type."), | 197 | {"type", 't', 0, N_("Match structures with the given type."), |
163 | @@ -198,6 +214,8 @@ static const struct grub_arg_option options[] = { | |||
164 | 198 | N_("offset"), ARG_TYPE_INT}, | 214 | N_("offset"), ARG_TYPE_INT}, |
165 | 199 | {"set", '\0', 0, N_("Store the value in the given variable name."), | 215 | {"set", '\0', 0, N_("Store the value in the given variable name."), |
166 | 200 | N_("variable"), ARG_TYPE_STRING}, | 216 | N_("variable"), ARG_TYPE_STRING}, |
167 | 217 | {"linux", '\0', 0, N_("Filter the result like linux does."), | ||
168 | 218 | N_("variable"), ARG_TYPE_NONE}, | ||
169 | 201 | {0, 0, 0, 0, 0, 0} | 219 | {0, 0, 0, 0, 0, 0} |
170 | 202 | }; | 220 | }; |
171 | 203 | 221 | ||
172 | @@ -261,6 +279,7 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt, | |||
173 | 261 | 279 | ||
174 | 262 | const grub_uint8_t *structure; | 280 | const grub_uint8_t *structure; |
175 | 263 | const char *value; | 281 | const char *value; |
176 | 282 | char *modified_value = NULL; | ||
177 | 264 | grub_int32_t option; | 283 | grub_int32_t option; |
178 | 265 | grub_int8_t field_type = -1; | 284 | grub_int8_t field_type = -1; |
179 | 266 | grub_uint8_t i; | 285 | grub_uint8_t i; |
180 | @@ -334,12 +353,17 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt, | |||
181 | 334 | return grub_error (GRUB_ERR_IO, | 353 | return grub_error (GRUB_ERR_IO, |
182 | 335 | N_("failed to retrieve the structure field")); | 354 | N_("failed to retrieve the structure field")); |
183 | 336 | 355 | ||
184 | 356 | if (state[LINUX_OPT].set) | ||
185 | 357 | value = modified_value = linux_string (value); | ||
186 | 358 | |||
187 | 337 | /* Store or print the formatted value. */ | 359 | /* Store or print the formatted value. */ |
188 | 338 | if (state[SETTER_OPT].set) | 360 | if (state[SETTER_OPT].set) |
189 | 339 | grub_env_set (state[SETTER_OPT].arg, value); | 361 | grub_env_set (state[SETTER_OPT].arg, value); |
190 | 340 | else | 362 | else |
191 | 341 | grub_printf ("%s\n", value); | 363 | grub_printf ("%s\n", value); |
192 | 342 | 364 | ||
193 | 365 | grub_free(modified_value); | ||
194 | 366 | |||
195 | 343 | return GRUB_ERR_NONE; | 367 | return GRUB_ERR_NONE; |
196 | 344 | } | 368 | } |
197 | 345 | 369 |
This goes into signed grub image and is needed for OEM work.