mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 05:10:09 +01:00
systemd: merge branch systemd into master
Seems there is nothing relevant really. Just do our regular resync to keep the diff to upstream systemd small.
This commit is contained in:
commit
17e984d4cb
6 changed files with 82 additions and 11 deletions
|
|
@ -73,7 +73,7 @@ int write_string_stream_ts(FILE *f, const char *line, bool enforce_newline, stru
|
|||
return fflush_and_check(f);
|
||||
}
|
||||
|
||||
static int write_string_file_atomic(const char *fn, const char *line, bool enforce_newline) {
|
||||
static int write_string_file_atomic(const char *fn, const char *line, bool enforce_newline, bool do_fsync) {
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
_cleanup_free_ char *p = NULL;
|
||||
int r;
|
||||
|
|
@ -88,6 +88,9 @@ static int write_string_file_atomic(const char *fn, const char *line, bool enfor
|
|||
(void) fchmod_umask(fileno(f), 0644);
|
||||
|
||||
r = write_string_stream(f, line, enforce_newline);
|
||||
if (r >= 0 && do_fsync)
|
||||
r = fflush_sync_and_check(f);
|
||||
|
||||
if (r >= 0) {
|
||||
if (rename(p, fn) < 0)
|
||||
r = -errno;
|
||||
|
|
@ -106,10 +109,14 @@ int write_string_file_ts(const char *fn, const char *line, WriteStringFileFlags
|
|||
assert(fn);
|
||||
assert(line);
|
||||
|
||||
/* We don't know how to verify whether the file contents was already on-disk. */
|
||||
assert(!((flags & WRITE_STRING_FILE_VERIFY_ON_FAILURE) && (flags & WRITE_STRING_FILE_SYNC)));
|
||||
|
||||
if (flags & WRITE_STRING_FILE_ATOMIC) {
|
||||
assert(flags & WRITE_STRING_FILE_CREATE);
|
||||
|
||||
r = write_string_file_atomic(fn, line, !(flags & WRITE_STRING_FILE_AVOID_NEWLINE));
|
||||
r = write_string_file_atomic(fn, line, !(flags & WRITE_STRING_FILE_AVOID_NEWLINE),
|
||||
flags & WRITE_STRING_FILE_SYNC);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
|
|
@ -146,6 +153,12 @@ int write_string_file_ts(const char *fn, const char *line, WriteStringFileFlags
|
|||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
if (flags & WRITE_STRING_FILE_SYNC) {
|
||||
r = fflush_sync_and_check(f);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
|
|
@ -1132,6 +1145,21 @@ int fflush_and_check(FILE *f) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int fflush_sync_and_check(FILE *f) {
|
||||
int r;
|
||||
|
||||
assert(f);
|
||||
|
||||
r = fflush_and_check(f);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (fsync(fileno(f)) < 0)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This is much like mkostemp() but is subject to umask(). */
|
||||
int mkostemp_safe(char *pattern) {
|
||||
_cleanup_umask_ mode_t u = 0;
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@
|
|||
#include "time-util.h"
|
||||
|
||||
typedef enum {
|
||||
WRITE_STRING_FILE_CREATE = 1,
|
||||
WRITE_STRING_FILE_ATOMIC = 2,
|
||||
WRITE_STRING_FILE_AVOID_NEWLINE = 4,
|
||||
WRITE_STRING_FILE_VERIFY_ON_FAILURE = 8,
|
||||
WRITE_STRING_FILE_CREATE = 1<<0,
|
||||
WRITE_STRING_FILE_ATOMIC = 1<<1,
|
||||
WRITE_STRING_FILE_AVOID_NEWLINE = 1<<2,
|
||||
WRITE_STRING_FILE_VERIFY_ON_FAILURE = 1<<3,
|
||||
WRITE_STRING_FILE_SYNC = 1<<4,
|
||||
} WriteStringFileFlags;
|
||||
|
||||
int write_string_stream_ts(FILE *f, const char *line, bool enforce_newline, struct timespec *ts);
|
||||
|
|
@ -77,6 +78,7 @@ int search_and_fopen_nulstr(const char *path, const char *mode, const char *root
|
|||
} else
|
||||
|
||||
int fflush_and_check(FILE *f);
|
||||
int fflush_sync_and_check(FILE *f);
|
||||
|
||||
int fopen_temporary(const char *path, FILE **_f, char **_temp_path);
|
||||
int mkostemp_safe(char *pattern);
|
||||
|
|
|
|||
|
|
@ -143,3 +143,13 @@ bool is_deviceallow_pattern(const char *path);
|
|||
int systemd_installation_has_version(const char *root, unsigned minimal_version);
|
||||
|
||||
bool dot_or_dot_dot(const char *path);
|
||||
|
||||
static inline const char *skip_dev_prefix(const char *p) {
|
||||
const char *e;
|
||||
|
||||
/* Drop any /dev prefix if there is any */
|
||||
|
||||
e = path_startswith(p, "/dev/");
|
||||
|
||||
return e ?: p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -478,7 +478,7 @@ static int get_process_id(pid_t pid, const char *field, uid_t *uid) {
|
|||
assert(field);
|
||||
assert(uid);
|
||||
|
||||
if (pid < 0)
|
||||
if (!pid_is_valid(pid))
|
||||
return -EINVAL;
|
||||
|
||||
p = procfs_file_alloca(pid, "status");
|
||||
|
|
@ -791,7 +791,7 @@ int getenv_for_pid(pid_t pid, const char *field, char **_value) {
|
|||
bool pid_is_unwaited(pid_t pid) {
|
||||
/* Checks whether a PID is still valid at all, including a zombie */
|
||||
|
||||
if (pid < 0)
|
||||
if (!pid_is_valid(pid))
|
||||
return false;
|
||||
|
||||
if (pid <= 1) /* If we or PID 1 would be dead and have been waited for, this code would not be running */
|
||||
|
|
@ -811,7 +811,7 @@ bool pid_is_alive(pid_t pid) {
|
|||
|
||||
/* Checks whether a PID is still valid and not a zombie */
|
||||
|
||||
if (pid < 0)
|
||||
if (!pid_is_valid(pid))
|
||||
return false;
|
||||
|
||||
if (pid <= 1) /* If we or PID 1 would be a zombie, this code would not be running */
|
||||
|
|
@ -830,7 +830,7 @@ bool pid_is_alive(pid_t pid) {
|
|||
int pid_from_same_root_fs(pid_t pid) {
|
||||
const char *root;
|
||||
|
||||
if (pid < 0)
|
||||
if (!pid_is_valid(pid))
|
||||
return false;
|
||||
|
||||
if (pid == 0 || pid == getpid_cached())
|
||||
|
|
@ -909,6 +909,25 @@ const char* personality_to_string(unsigned long p) {
|
|||
return architecture_to_string(architecture);
|
||||
}
|
||||
|
||||
int opinionated_personality(unsigned long *ret) {
|
||||
int current;
|
||||
|
||||
/* Returns the current personality, or PERSONALITY_INVALID if we can't determine it. This function is a bit
|
||||
* opinionated though, and ignores all the finer-grained bits and exotic personalities, only distinguishing the
|
||||
* two most relevant personalities: PER_LINUX and PER_LINUX32. */
|
||||
|
||||
current = personality(PERSONALITY_INVALID);
|
||||
if (current < 0)
|
||||
return -errno;
|
||||
|
||||
if (((unsigned long) current & 0xffff) == PER_LINUX32)
|
||||
*ret = PER_LINUX32;
|
||||
else
|
||||
*ret = PER_LINUX;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void valgrind_summary_hack(void) {
|
||||
#ifdef HAVE_VALGRIND_VALGRIND_H
|
||||
if (getpid_cached() == 1 && RUNNING_ON_VALGRIND) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
***/
|
||||
|
||||
#include <alloca.h>
|
||||
#include <sched.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
|
@ -90,6 +91,8 @@ bool oom_score_adjust_is_valid(int oa);
|
|||
unsigned long personality_from_string(const char *p);
|
||||
const char *personality_to_string(unsigned long);
|
||||
|
||||
int opinionated_personality(unsigned long *ret);
|
||||
|
||||
int ioprio_class_to_string_alloc(int i, char **s);
|
||||
int ioprio_class_from_string(const char *s);
|
||||
|
||||
|
|
@ -111,6 +114,14 @@ static inline bool nice_is_valid(int n) {
|
|||
return n >= PRIO_MIN && n < PRIO_MAX;
|
||||
}
|
||||
|
||||
static inline bool sched_policy_is_valid(int i) {
|
||||
return IN_SET(i, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_FIFO, SCHED_RR);
|
||||
}
|
||||
|
||||
static inline bool sched_priority_is_valid(int i) {
|
||||
return i >= 0 && i <= sched_get_priority_max(SCHED_RR);
|
||||
}
|
||||
|
||||
static inline bool ioprio_class_is_valid(int i) {
|
||||
return IN_SET(i, IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -796,7 +796,8 @@ static const char* const netlink_family_table[] = {
|
|||
[NETLINK_KOBJECT_UEVENT] = "kobject-uevent",
|
||||
[NETLINK_GENERIC] = "generic",
|
||||
[NETLINK_SCSITRANSPORT] = "scsitransport",
|
||||
[NETLINK_ECRYPTFS] = "ecryptfs"
|
||||
[NETLINK_ECRYPTFS] = "ecryptfs",
|
||||
[NETLINK_RDMA] = "rdma",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(netlink_family, int, INT_MAX);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue