mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
dissect: officially support initrd DDIs (to implement 2nd stage initrds)
Let's complete support for DDI discovery, and also support 2nd stage initrds.
This commit is contained in:
parent
00fa567d4a
commit
fab2294646
@ -518,6 +518,8 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
|
||||
"Mach. Info:");
|
||||
strv_pair_print(m->os_release,
|
||||
"OS Release:");
|
||||
strv_pair_print(m->initrd_release,
|
||||
"initrd R.:");
|
||||
strv_pair_print(m->extension_release,
|
||||
" Ext. Rel.:");
|
||||
|
||||
@ -525,6 +527,7 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
|
||||
!sd_id128_is_null(m->machine_id) ||
|
||||
!strv_isempty(m->machine_info) ||
|
||||
!strv_isempty(m->os_release) ||
|
||||
!strv_isempty(m->initrd_release) ||
|
||||
!strv_isempty(m->extension_release))
|
||||
putc('\n', stdout);
|
||||
|
||||
@ -535,6 +538,8 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
|
||||
|
||||
printf(" %s portable service\n",
|
||||
COLOR_MARK_BOOL(strv_env_pairs_get(m->os_release, "PORTABLE_PREFIXES")));
|
||||
printf(" %s initrd\n",
|
||||
COLOR_MARK_BOOL(!strv_isempty(m->initrd_release)));
|
||||
|
||||
r = get_sysext_scopes(m, &sysext_scopes);
|
||||
if (r < 0)
|
||||
@ -549,7 +554,7 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
|
||||
|
||||
putc('\n', stdout);
|
||||
} else {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *mi = NULL, *osr = NULL, *exr = NULL;
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *mi = NULL, *osr = NULL, *irdr = NULL, *exr = NULL;
|
||||
_cleanup_strv_free_ char **sysext_scopes = NULL;
|
||||
|
||||
if (!strv_isempty(m->machine_info)) {
|
||||
@ -564,6 +569,12 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
if (!strv_isempty(m->initrd_release)) {
|
||||
r = strv_pair_to_json(m->initrd_release, &irdr);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
if (!strv_isempty(m->extension_release)) {
|
||||
r = strv_pair_to_json(m->extension_release, &exr);
|
||||
if (r < 0)
|
||||
@ -581,9 +592,11 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
|
||||
JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(m->machine_id), "machineId", JSON_BUILD_ID128(m->machine_id)),
|
||||
JSON_BUILD_PAIR_CONDITION(mi, "machineInfo", JSON_BUILD_VARIANT(mi)),
|
||||
JSON_BUILD_PAIR_CONDITION(osr, "osRelease", JSON_BUILD_VARIANT(osr)),
|
||||
JSON_BUILD_PAIR_CONDITION(osr, "initrdRelease", JSON_BUILD_VARIANT(irdr)),
|
||||
JSON_BUILD_PAIR_CONDITION(exr, "extensionRelease", JSON_BUILD_VARIANT(exr)),
|
||||
JSON_BUILD_PAIR("useBootableUefi", JSON_BUILD_BOOLEAN(m->partitions[PARTITION_ESP].found)),
|
||||
JSON_BUILD_PAIR_CONDITION(m->has_init_system >= 0, "useBootableContainer", JSON_BUILD_BOOLEAN(m->has_init_system)),
|
||||
JSON_BUILD_PAIR("useInitrd", JSON_BUILD_BOOLEAN(!strv_isempty(m->initrd_release))),
|
||||
JSON_BUILD_PAIR("usePortableService", JSON_BUILD_BOOLEAN(strv_env_pairs_get(m->os_release, "PORTABLE_MATCHES"))),
|
||||
JSON_BUILD_PAIR("useSystemExtension", JSON_BUILD_BOOLEAN(strv_contains(sysext_scopes, "system"))),
|
||||
JSON_BUILD_PAIR("useInitRDExtension", JSON_BUILD_BOOLEAN(strv_contains(sysext_scopes, "initrd"))),
|
||||
|
@ -1296,6 +1296,7 @@ DissectedImage* dissected_image_unref(DissectedImage *m) {
|
||||
free(m->hostname);
|
||||
strv_free(m->machine_info);
|
||||
strv_free(m->os_release);
|
||||
strv_free(m->initrd_release);
|
||||
strv_free(m->extension_release);
|
||||
|
||||
return mfree(m);
|
||||
@ -2771,6 +2772,7 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_
|
||||
META_MACHINE_ID,
|
||||
META_MACHINE_INFO,
|
||||
META_OS_RELEASE,
|
||||
META_INITRD_RELEASE,
|
||||
META_EXTENSION_RELEASE,
|
||||
META_HAS_INIT_SYSTEM,
|
||||
_META_MAX,
|
||||
@ -2782,11 +2784,13 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_
|
||||
[META_MACHINE_INFO] = "/etc/machine-info\0",
|
||||
[META_OS_RELEASE] = ("/etc/os-release\0"
|
||||
"/usr/lib/os-release\0"),
|
||||
[META_INITRD_RELEASE] = ("/etc/initrd-release\0"
|
||||
"/usr/lib/initrd-release\0"),
|
||||
[META_EXTENSION_RELEASE] = "extension-release\0", /* Used only for logging. */
|
||||
[META_HAS_INIT_SYSTEM] = "has-init-system\0", /* ditto */
|
||||
};
|
||||
|
||||
_cleanup_strv_free_ char **machine_info = NULL, **os_release = NULL, **extension_release = NULL;
|
||||
_cleanup_strv_free_ char **machine_info = NULL, **os_release = NULL, **initrd_release = NULL, **extension_release = NULL;
|
||||
_cleanup_close_pair_ int error_pipe[2] = { -1, -1 };
|
||||
_cleanup_(rmdir_and_freep) char *t = NULL;
|
||||
_cleanup_(sigkill_waitp) pid_t child = 0;
|
||||
@ -2982,6 +2986,13 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_
|
||||
|
||||
break;
|
||||
|
||||
case META_INITRD_RELEASE:
|
||||
r = load_env_file_pairs(f, "initrd-release", &initrd_release);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to read initrd release file of image: %m");
|
||||
|
||||
break;
|
||||
|
||||
case META_EXTENSION_RELEASE:
|
||||
r = load_env_file_pairs(f, "extension-release", &extension_release);
|
||||
if (r < 0)
|
||||
@ -3024,6 +3035,7 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_
|
||||
m->machine_id = machine_id;
|
||||
strv_free_and_replace(m->machine_info, machine_info);
|
||||
strv_free_and_replace(m->os_release, os_release);
|
||||
strv_free_and_replace(m->initrd_release, initrd_release);
|
||||
strv_free_and_replace(m->extension_release, extension_release);
|
||||
m->has_init_system = has_init_system;
|
||||
|
||||
|
@ -233,6 +233,7 @@ struct DissectedImage {
|
||||
sd_id128_t machine_id;
|
||||
char **machine_info;
|
||||
char **os_release;
|
||||
char **initrd_release;
|
||||
char **extension_release;
|
||||
int has_init_system;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user