Merge pull request #29130 from poettering/unit-defaults
core: introduce UnitDefaults structure for unit defaults
This commit is contained in:
@@ -362,6 +362,27 @@ void rlimit_free_all(struct rlimit **rl) {
|
||||
free_many((void**) rl, _RLIMIT_MAX);
|
||||
}
|
||||
|
||||
int rlimit_copy_all(struct rlimit* target[static _RLIMIT_MAX], struct rlimit* const source[static _RLIMIT_MAX]) {
|
||||
struct rlimit* copy[_RLIMIT_MAX] = {};
|
||||
|
||||
assert(target);
|
||||
assert(source);
|
||||
|
||||
for (int i = 0; i < _RLIMIT_MAX; i++) {
|
||||
if (!source[i])
|
||||
continue;
|
||||
|
||||
copy[i] = newdup(struct rlimit, source[i], 1);
|
||||
if (!copy[i]) {
|
||||
rlimit_free_all(copy);
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(target, copy, sizeof(struct rlimit*) * _RLIMIT_MAX);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rlimit_nofile_bump(int limit) {
|
||||
int r;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include "macro.h"
|
||||
#include "missing_resource.h"
|
||||
|
||||
const char *rlimit_to_string(int i) _const_;
|
||||
int rlimit_from_string(const char *s) _pure_;
|
||||
@@ -17,6 +18,7 @@ int rlimit_parse(int resource, const char *val, struct rlimit *ret);
|
||||
|
||||
int rlimit_format(const struct rlimit *rl, char **ret);
|
||||
|
||||
int rlimit_copy_all(struct rlimit* target[static _RLIMIT_MAX], struct rlimit* const source[static _RLIMIT_MAX]);
|
||||
void rlimit_free_all(struct rlimit **rl);
|
||||
|
||||
#define RLIMIT_MAKE_CONST(lim) ((struct rlimit) { lim, lim })
|
||||
|
||||
Reference in New Issue
Block a user