1
0
mirror of https://github.com/systemd/systemd synced 2026-03-20 03:54:45 +01:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Lennart Poettering
107e21635b hashmap: make sure hashmap_get_strv()+set_get_strv() work with a NULL object
Before we invoke n_entries() we need to check for non-NULL here, like in
all other calls to the helper function. Otherwise we'll crash when
invoked with a NULL object, which we usually consider equivalent to an
empty one though.
2021-07-02 22:32:19 +01:00
qhill
f127fed75d units: correct description of final.target
This was updated incorrectly in 4fd3fc6639.  As https://github.com/systemd/systemd/blob/main/man/systemd.special.xml decribes, this unit is about shutdown rather than boot.
2021-07-02 18:29:54 +02:00
Lennart Poettering
da636b67a6 udev: when booting without root= specification, and searching a root partition actually do the version comparison magic
Since 08fe0a53869f27a9bfbc5bd31f27058145d46745 when dissecting a disk
image we'll automatically pick the "newest" root fs if multiple exist,
by comparing GPT partition labels. This works in systemd-nspawn,
systemd-dissect, systemd-tmpfiles --image, … and so on. It also works
already in systemd-gpt-auto-generator. However, there was one missing
place: in the logic that automatically finds a root fs in case no root=
was specified on the kernel logic at all. This logic doesn't use the
dissection logic, but a much simpler one.

Let's fill the gap, and implement it there too.
2021-07-02 18:28:32 +02:00
Lennart Poettering
6d8be376e1 coredumpctl: show --help text if "coredumpctl help" is called
Most of our programs that take "verbs" make the "help" verb either
equivalent to passing the --help switch (or at least print a message
redirecting the user to that switch). Do so in coredumpctl too, in order
to minimize surprises.
2021-07-02 18:28:06 +02:00
4 changed files with 21 additions and 11 deletions

View File

@ -1761,6 +1761,9 @@ char** _hashmap_get_strv(HashmapBase *h) {
Iterator i; Iterator i;
unsigned idx, n; unsigned idx, n;
if (!h)
return new0(char*, 1);
sv = new(char*, n_entries(h)+1); sv = new(char*, n_entries(h)+1);
if (!sv) if (!sv)
return NULL; return NULL;

View File

@ -150,7 +150,7 @@ static int acquire_journal(sd_journal **ret, char **matches) {
return 0; return 0;
} }
static int help(void) { static int verb_help(int argc, char **argv, void *userdata) {
_cleanup_free_ char *link = NULL; _cleanup_free_ char *link = NULL;
int r; int r;
@ -232,7 +232,7 @@ static int parse_argv(int argc, char *argv[]) {
while ((c = getopt_long(argc, argv, "hA:o:F:1D:rS:U:qn:", options, NULL)) >= 0) while ((c = getopt_long(argc, argv, "hA:o:F:1D:rS:U:qn:", options, NULL)) >= 0)
switch(c) { switch(c) {
case 'h': case 'h':
return help(); return verb_help(0, NULL, NULL);
case ARG_VERSION: case ARG_VERSION:
return version(); return version();
@ -1242,6 +1242,7 @@ static int coredumpctl_main(int argc, char *argv[]) {
{ "dump", VERB_ANY, VERB_ANY, 0, dump_core }, { "dump", VERB_ANY, VERB_ANY, 0, dump_core },
{ "debug", VERB_ANY, VERB_ANY, 0, run_debug }, { "debug", VERB_ANY, VERB_ANY, 0, run_debug },
{ "gdb", VERB_ANY, VERB_ANY, 0, run_debug }, { "gdb", VERB_ANY, VERB_ANY, 0, run_debug },
{ "help", VERB_ANY, 1, 0, verb_help },
{} {}
}; };

View File

@ -114,7 +114,7 @@ static int find_gpt_root(sd_device *dev, blkid_probe pr, bool test) {
#if defined(GPT_ROOT_NATIVE) && ENABLE_EFI #if defined(GPT_ROOT_NATIVE) && ENABLE_EFI
_cleanup_free_ char *root_id = NULL; _cleanup_free_ char *root_id = NULL, *root_label = NULL;
bool found_esp = false; bool found_esp = false;
blkid_partlist pl; blkid_partlist pl;
int i, nvals, r; int i, nvals, r;
@ -133,7 +133,7 @@ static int find_gpt_root(sd_device *dev, blkid_probe pr, bool test) {
nvals = blkid_partlist_numof_partitions(pl); nvals = blkid_partlist_numof_partitions(pl);
for (i = 0; i < nvals; i++) { for (i = 0; i < nvals; i++) {
blkid_partition pp; blkid_partition pp;
const char *stype, *sid; const char *stype, *sid, *label;
sd_id128_t type; sd_id128_t type;
pp = blkid_partlist_get_partition(pl, i); pp = blkid_partlist_get_partition(pl, i);
@ -144,6 +144,8 @@ static int find_gpt_root(sd_device *dev, blkid_probe pr, bool test) {
if (!sid) if (!sid)
continue; continue;
label = blkid_partition_get_name(pp); /* returns NULL if empty */
stype = blkid_partition_get_type_string(pp); stype = blkid_partition_get_type_string(pp);
if (!stype) if (!stype)
continue; continue;
@ -174,13 +176,17 @@ static int find_gpt_root(sd_device *dev, blkid_probe pr, bool test) {
if (flags & GPT_FLAG_NO_AUTO) if (flags & GPT_FLAG_NO_AUTO)
continue; continue;
/* We found a suitable root partition, let's /* We found a suitable root partition, let's remember the first one, or the one with
* remember the first one. */ * the newest version, as determined by comparing the partition labels. */
if (!root_id) { if (!root_id || strverscmp_improved(label, root_label) > 0) {
root_id = strdup(sid); r = free_and_strdup(&root_id, sid);
if (!root_id) if (r < 0)
return -ENOMEM; return r;
r = free_and_strdup(&root_label, label);
if (r < 0)
return r;
} }
} }
} }

View File

@ -8,7 +8,7 @@
# (at your option) any later version. # (at your option) any later version.
[Unit] [Unit]
Description=Late Boot Services Description=Late Shutdown Services
Documentation=man:systemd.special(7) Documentation=man:systemd.special(7)
DefaultDependencies=no DefaultDependencies=no
RefuseManualStart=yes RefuseManualStart=yes