mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
Merge pull request #30851 from lnussel/kernel-install
kernel-install fixes
This commit is contained in:
@@ -123,6 +123,22 @@ char** strv_copy_n(char * const *l, size_t m) {
|
||||
return TAKE_PTR(result);
|
||||
}
|
||||
|
||||
int strv_copy_unless_empty(char * const *l, char ***ret) {
|
||||
assert(ret);
|
||||
|
||||
if (strv_isempty(l)) {
|
||||
*ret = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char **copy = strv_copy(l);
|
||||
if (!copy)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = TAKE_PTR(copy);
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t strv_length(char * const *l) {
|
||||
size_t n = 0;
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ char** strv_copy_n(char * const *l, size_t n);
|
||||
static inline char** strv_copy(char * const *l) {
|
||||
return strv_copy_n(l, SIZE_MAX);
|
||||
}
|
||||
int strv_copy_unless_empty(char * const *l, char ***ret);
|
||||
|
||||
size_t strv_length(char * const *l) _pure_;
|
||||
|
||||
int strv_extend_strv(char ***a, char * const *b, bool filter_duplicates);
|
||||
|
||||
@@ -133,9 +133,10 @@ static int context_copy(const Context *source, Context *ret) {
|
||||
|
||||
assert(source);
|
||||
assert(ret);
|
||||
assert(source->rfd >= 0 || source->rfd == AT_FDCWD);
|
||||
|
||||
_cleanup_(context_done) Context copy = (Context) {
|
||||
.rfd = -EBADF,
|
||||
.rfd = AT_FDCWD,
|
||||
.action = source->action,
|
||||
.machine_id = source->machine_id,
|
||||
.machine_id_is_random = source->machine_id_is_random,
|
||||
@@ -144,9 +145,11 @@ static int context_copy(const Context *source, Context *ret) {
|
||||
.entry_token_type = source->entry_token_type,
|
||||
};
|
||||
|
||||
copy.rfd = fd_reopen(source->rfd, O_CLOEXEC|O_DIRECTORY|O_PATH);
|
||||
if (copy.rfd < 0)
|
||||
return copy.rfd;
|
||||
if (source->rfd >= 0) {
|
||||
copy.rfd = fd_reopen(source->rfd, O_CLOEXEC|O_DIRECTORY|O_PATH);
|
||||
if (copy.rfd < 0)
|
||||
return copy.rfd;
|
||||
}
|
||||
|
||||
r = strdup_or_null(source->layout_other, ©.layout_other);
|
||||
if (r < 0)
|
||||
@@ -169,9 +172,9 @@ static int context_copy(const Context *source, Context *ret) {
|
||||
r = strdup_or_null(source->kernel, ©.kernel);
|
||||
if (r < 0)
|
||||
return r;
|
||||
copy.initrds = strv_copy(source->initrds);
|
||||
if (!copy.initrds)
|
||||
return -ENOMEM;
|
||||
r = strv_copy_unless_empty(source->initrds, ©.initrds);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = strdup_or_null(source->initrd_generator, ©.initrd_generator);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -181,15 +184,15 @@ static int context_copy(const Context *source, Context *ret) {
|
||||
r = strdup_or_null(source->staging_area, ©.staging_area);
|
||||
if (r < 0)
|
||||
return r;
|
||||
copy.plugins = strv_copy(source->plugins);
|
||||
if (!copy.plugins)
|
||||
return -ENOMEM;
|
||||
copy.argv = strv_copy(source->argv);
|
||||
if (!copy.argv)
|
||||
return -ENOMEM;
|
||||
copy.envp = strv_copy(source->envp);
|
||||
if (!copy.envp)
|
||||
return -ENOMEM;
|
||||
r = strv_copy_unless_empty(source->plugins, ©.plugins);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = strv_copy_unless_empty(source->argv, ©.argv);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = strv_copy_unless_empty(source->envp, ©.envp);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = copy;
|
||||
copy = CONTEXT_NULL;
|
||||
@@ -1265,7 +1268,7 @@ static int verb_add_all(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
|
||||
if (n > 0)
|
||||
log_info("Installed %zu kernels.", n);
|
||||
log_debug("Installed %zu kernel(s).", n);
|
||||
else if (ret == 0)
|
||||
ret = log_error_errno(SYNTHETIC_ERRNO(ENOENT), "No kernels to install found.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user