1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 16:59:03 +03:00

Merge pull request #8710 from poettering/triviailities-yeah-yeah

some trivial additions and fixes
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-04-12 22:21:15 +02:00 committed by GitHub
commit 812724c14b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 43 additions and 14 deletions

10
TODO
View File

@ -24,6 +24,12 @@ Janitorial Clean-ups:
Features:
* pid1: lock image configured with RootDirectory=/RootImage= using the usual nspawn semantics while the unit is up
* add --vacuum-xyz options to coredumpctl, matching those journalctl already has.
* enforce that transient units are started exactly once only
* list the exit codes from the BSD/glibc <sysexits.h> in our own
exit-codes.[ch] tables.
@ -39,10 +45,6 @@ Features:
Related: add Ephemeral=<path1> <path2> … which would allow marking
specific paths only like this.
* when RootImage= is used, mark the loopback device read-only if the other
settings permit it (i.e. if ProtectSystem=strict is set, and no directory if
the image is writable)
* add CopyFile= or so as unit file setting that may be used to copy files or
directory trees from the host to te services RootImage= and RootDirectory=
environment. Which we can use for /etc/machine-id and in particular

View File

@ -350,7 +350,7 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
({ \
typeof(x) _x_ = (x); \
unsigned ans = 1; \
while (_x_ /= 10) \
while ((_x_ /= 10) != 0) \
ans++; \
ans; \
})

View File

@ -715,16 +715,23 @@ char* dirname_malloc(const char *path) {
}
const char *last_path_component(const char *path) {
/* Finds the last component of the path, preserving the
* optional trailing slash that signifies a directory.
/* Finds the last component of the path, preserving the optional trailing slash that signifies a directory.
*
* a/b/c c
* a/b/c/ c/
* x x
* x/ x/
* /y y
* /y/ y/
* / /
* // → /
* /foo/a a
* /foo/a/ a/
* This is different than basename, which returns "" when
* a trailing slash is present.
*
* Also, the empty string is mapped to itself.
*
* This is different than basename(), which returns "" when a trailing slash is present.
*/
unsigned l, k;

View File

@ -191,3 +191,11 @@ int fork_agent(const char *name, const int except[], unsigned n_except, pid_t *p
#endif
assert_cc(TASKS_MAX <= (unsigned long) PID_T_MAX)
/* Like TAKE_PTR() but for child PIDs, resetting them to 0 */
#define TAKE_PID(pid) \
({ \
pid_t _pid_ = (pid); \
(pid) = 0; \
_pid_; \
})

View File

@ -103,6 +103,14 @@ static inline void qsort_safe(void *base, size_t nmemb, size_t size, comparison_
qsort(base, nmemb, size, compar);
}
/* A wrapper around the above, but that adds typesafety: the element size is automatically derived from the type and so
* is the prototype for the comparison function */
#define typesafe_qsort(p, n, func) \
({ \
int (*_func_)(const typeof(p[0])*, const typeof(p[0])*) = func; \
qsort_safe((p), (n), sizeof((p)[0]), (__compar_fn_t) _func_); \
})
/**
* Normal memcpy requires src to be nonnull. We do nothing if n is 0.
*/

View File

@ -195,7 +195,7 @@ static int import_raw(int argc, char *argv[], void *userdata) {
fd = STDIN_FILENO;
(void) readlink_malloc("/proc/self/fd/0", &pretty);
log_info("Importing '%s', saving as '%s'.", pretty, local);
log_info("Importing '%s', saving as '%s'.", strempty(pretty), local);
}
r = sd_event_default(&event);

View File

@ -64,13 +64,13 @@ enum UnitFileChangeType {
UNIT_FILE_IS_MASKED,
UNIT_FILE_IS_DANGLING,
_UNIT_FILE_CHANGE_TYPE_MAX,
_UNIT_FILE_CHANGE_INVALID = INT_MIN
_UNIT_FILE_CHANGE_TYPE_INVALID = INT_MIN
};
enum UnitFileFlags {
UNIT_FILE_RUNTIME = 1,
UNIT_FILE_FORCE = 1 << 1,
UNIT_FILE_DRY_RUN = 1 << 2,
UNIT_FILE_RUNTIME = 1U << 0,
UNIT_FILE_FORCE = 1U << 1,
UNIT_FILE_DRY_RUN = 1U << 2,
};
/* type can either one of the UnitFileChangeTypes listed above, or a negative error.

View File

@ -399,6 +399,10 @@ static void test_last_path_component(void) {
assert_se(streq(last_path_component("/foo/a"), "a"));
assert_se(streq(last_path_component("/foo/a/"), "a/"));
assert_se(streq(last_path_component(""), ""));
assert_se(streq(last_path_component("a"), "a"));
assert_se(streq(last_path_component("a/"), "a/"));
assert_se(streq(last_path_component("/a"), "a"));
assert_se(streq(last_path_component("/a/"), "a/"));
}
static void test_filename_is_valid(void) {