mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them over.
This commit is contained in:
parent
04c0136989
commit
3ffd4af220
@ -783,6 +783,8 @@ libbasic_la_SOURCES = \
|
||||
src/basic/util.h \
|
||||
src/basic/string-util.c \
|
||||
src/basic/string-util.h \
|
||||
src/basic/fd-util.c \
|
||||
src/basic/fd-util.h \
|
||||
src/basic/extract-word.c \
|
||||
src/basic/extract-word.h \
|
||||
src/basic/escape.c \
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "socket-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "fd-util.h"
|
||||
|
||||
static char** arg_listen = NULL;
|
||||
static bool arg_accept = false;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "async.h"
|
||||
#include "fd-util.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -22,11 +22,12 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "macro.h"
|
||||
#include "audit.h"
|
||||
#include "util.h"
|
||||
#include "process-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "macro.h"
|
||||
#include "process-util.h"
|
||||
#include "util.h"
|
||||
|
||||
int audit_session_from_pid(pid_t pid, uint32_t *id) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "barrier.h"
|
||||
#include "fd-util.h"
|
||||
#include "macro.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -27,7 +27,9 @@
|
||||
#endif
|
||||
|
||||
#include "btrfs-ctree.h"
|
||||
#include "btrfs-util.h"
|
||||
#include "copy.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "macro.h"
|
||||
#include "missing.h"
|
||||
@ -36,7 +38,6 @@
|
||||
#include "smack-util.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "btrfs-util.h"
|
||||
|
||||
/* WARNING: Be careful with file system ioctls! When we get an fd, we
|
||||
* need to make sure it either refers to only a regular file or
|
||||
|
@ -19,18 +19,18 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/capability.h>
|
||||
#include <sys/prctl.h>
|
||||
#include "grp.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#include "capability.h"
|
||||
#include "fileio.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
#include "fileio.h"
|
||||
#include "capability.h"
|
||||
|
||||
int have_effective_cap(int value) {
|
||||
_cleanup_cap_free_ cap_t cap;
|
||||
|
@ -29,7 +29,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "cgroup-util.h"
|
||||
#include "extract-word.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "formats-util.h"
|
||||
#include "login-util.h"
|
||||
@ -42,7 +44,6 @@
|
||||
#include "string-util.h"
|
||||
#include "unit-name.h"
|
||||
#include "util.h"
|
||||
#include "cgroup-util.h"
|
||||
|
||||
int cg_enumerate_processes(const char *controller, const char *path, FILE **_f) {
|
||||
_cleanup_free_ char *fs = NULL;
|
||||
|
@ -26,10 +26,11 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "clock-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "macro.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "clock-util.h"
|
||||
|
||||
int clock_get_hwclock(struct tm *tm) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
|
@ -21,6 +21,7 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
int clock_is_localtime(void);
|
||||
int clock_set_timezone(int *min);
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "conf-files.h"
|
||||
#include "fd-util.h"
|
||||
#include "hashmap.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
@ -33,7 +35,6 @@
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "util.h"
|
||||
#include "conf-files.h"
|
||||
|
||||
static int files_add(Hashmap *h, const char *root, const char *path, const char *suffix) {
|
||||
_cleanup_closedir_ DIR *dir = NULL;
|
||||
|
@ -23,10 +23,11 @@
|
||||
#include <sys/xattr.h>
|
||||
|
||||
#include "btrfs-util.h"
|
||||
#include "copy.h"
|
||||
#include "fd-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "util.h"
|
||||
#include "copy.h"
|
||||
|
||||
#define COPY_BUFFER_SIZE (16*1024)
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "escape.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "extract-word.h"
|
||||
|
||||
int extract_first_word(const char **p, char **ret, const char *separators, ExtractFlags flags) {
|
||||
|
321
src/basic/fd-util.c
Normal file
321
src/basic/fd-util.c
Normal file
@ -0,0 +1,321 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "util.h"
|
||||
|
||||
int close_nointr(int fd) {
|
||||
assert(fd >= 0);
|
||||
|
||||
if (close(fd) >= 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Just ignore EINTR; a retry loop is the wrong thing to do on
|
||||
* Linux.
|
||||
*
|
||||
* http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html
|
||||
* https://bugzilla.gnome.org/show_bug.cgi?id=682819
|
||||
* http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR
|
||||
* https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain
|
||||
*/
|
||||
if (errno == EINTR)
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
}
|
||||
|
||||
int safe_close(int fd) {
|
||||
|
||||
/*
|
||||
* Like close_nointr() but cannot fail. Guarantees errno is
|
||||
* unchanged. Is a NOP with negative fds passed, and returns
|
||||
* -1, so that it can be used in this syntax:
|
||||
*
|
||||
* fd = safe_close(fd);
|
||||
*/
|
||||
|
||||
if (fd >= 0) {
|
||||
PROTECT_ERRNO;
|
||||
|
||||
/* The kernel might return pretty much any error code
|
||||
* via close(), but the fd will be closed anyway. The
|
||||
* only condition we want to check for here is whether
|
||||
* the fd was invalid at all... */
|
||||
|
||||
assert_se(close_nointr(fd) != -EBADF);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void safe_close_pair(int p[]) {
|
||||
assert(p);
|
||||
|
||||
if (p[0] == p[1]) {
|
||||
/* Special case pairs which use the same fd in both
|
||||
* directions... */
|
||||
p[0] = p[1] = safe_close(p[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
p[0] = safe_close(p[0]);
|
||||
p[1] = safe_close(p[1]);
|
||||
}
|
||||
|
||||
void close_many(const int fds[], unsigned n_fd) {
|
||||
unsigned i;
|
||||
|
||||
assert(fds || n_fd <= 0);
|
||||
|
||||
for (i = 0; i < n_fd; i++)
|
||||
safe_close(fds[i]);
|
||||
}
|
||||
|
||||
int fclose_nointr(FILE *f) {
|
||||
assert(f);
|
||||
|
||||
/* Same as close_nointr(), but for fclose() */
|
||||
|
||||
if (fclose(f) == 0)
|
||||
return 0;
|
||||
|
||||
if (errno == EINTR)
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
}
|
||||
|
||||
FILE* safe_fclose(FILE *f) {
|
||||
|
||||
/* Same as safe_close(), but for fclose() */
|
||||
|
||||
if (f) {
|
||||
PROTECT_ERRNO;
|
||||
|
||||
assert_se(fclose_nointr(f) != EBADF);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DIR* safe_closedir(DIR *d) {
|
||||
|
||||
if (d) {
|
||||
PROTECT_ERRNO;
|
||||
|
||||
assert_se(closedir(d) >= 0 || errno != EBADF);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int fd_nonblock(int fd, bool nonblock) {
|
||||
int flags, nflags;
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
flags = fcntl(fd, F_GETFL, 0);
|
||||
if (flags < 0)
|
||||
return -errno;
|
||||
|
||||
if (nonblock)
|
||||
nflags = flags | O_NONBLOCK;
|
||||
else
|
||||
nflags = flags & ~O_NONBLOCK;
|
||||
|
||||
if (nflags == flags)
|
||||
return 0;
|
||||
|
||||
if (fcntl(fd, F_SETFL, nflags) < 0)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fd_cloexec(int fd, bool cloexec) {
|
||||
int flags, nflags;
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
flags = fcntl(fd, F_GETFD, 0);
|
||||
if (flags < 0)
|
||||
return -errno;
|
||||
|
||||
if (cloexec)
|
||||
nflags = flags | FD_CLOEXEC;
|
||||
else
|
||||
nflags = flags & ~FD_CLOEXEC;
|
||||
|
||||
if (nflags == flags)
|
||||
return 0;
|
||||
|
||||
if (fcntl(fd, F_SETFD, nflags) < 0)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_pure_ static bool fd_in_set(int fd, const int fdset[], unsigned n_fdset) {
|
||||
unsigned i;
|
||||
|
||||
assert(n_fdset == 0 || fdset);
|
||||
|
||||
for (i = 0; i < n_fdset; i++)
|
||||
if (fdset[i] == fd)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int close_all_fds(const int except[], unsigned n_except) {
|
||||
_cleanup_closedir_ DIR *d = NULL;
|
||||
struct dirent *de;
|
||||
int r = 0;
|
||||
|
||||
assert(n_except == 0 || except);
|
||||
|
||||
d = opendir("/proc/self/fd");
|
||||
if (!d) {
|
||||
int fd;
|
||||
struct rlimit rl;
|
||||
|
||||
/* When /proc isn't available (for example in chroots)
|
||||
* the fallback is brute forcing through the fd
|
||||
* table */
|
||||
|
||||
assert_se(getrlimit(RLIMIT_NOFILE, &rl) >= 0);
|
||||
for (fd = 3; fd < (int) rl.rlim_max; fd ++) {
|
||||
|
||||
if (fd_in_set(fd, except, n_except))
|
||||
continue;
|
||||
|
||||
if (close_nointr(fd) < 0)
|
||||
if (errno != EBADF && r == 0)
|
||||
r = -errno;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
while ((de = readdir(d))) {
|
||||
int fd = -1;
|
||||
|
||||
if (hidden_file(de->d_name))
|
||||
continue;
|
||||
|
||||
if (safe_atoi(de->d_name, &fd) < 0)
|
||||
/* Let's better ignore this, just in case */
|
||||
continue;
|
||||
|
||||
if (fd < 3)
|
||||
continue;
|
||||
|
||||
if (fd == dirfd(d))
|
||||
continue;
|
||||
|
||||
if (fd_in_set(fd, except, n_except))
|
||||
continue;
|
||||
|
||||
if (close_nointr(fd) < 0) {
|
||||
/* Valgrind has its own FD and doesn't want to have it closed */
|
||||
if (errno != EBADF && r == 0)
|
||||
r = -errno;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int same_fd(int a, int b) {
|
||||
struct stat sta, stb;
|
||||
pid_t pid;
|
||||
int r, fa, fb;
|
||||
|
||||
assert(a >= 0);
|
||||
assert(b >= 0);
|
||||
|
||||
/* Compares two file descriptors. Note that semantics are
|
||||
* quite different depending on whether we have kcmp() or we
|
||||
* don't. If we have kcmp() this will only return true for
|
||||
* dup()ed file descriptors, but not otherwise. If we don't
|
||||
* have kcmp() this will also return true for two fds of the same
|
||||
* file, created by separate open() calls. Since we use this
|
||||
* call mostly for filtering out duplicates in the fd store
|
||||
* this difference hopefully doesn't matter too much. */
|
||||
|
||||
if (a == b)
|
||||
return true;
|
||||
|
||||
/* Try to use kcmp() if we have it. */
|
||||
pid = getpid();
|
||||
r = kcmp(pid, pid, KCMP_FILE, a, b);
|
||||
if (r == 0)
|
||||
return true;
|
||||
if (r > 0)
|
||||
return false;
|
||||
if (errno != ENOSYS)
|
||||
return -errno;
|
||||
|
||||
/* We don't have kcmp(), use fstat() instead. */
|
||||
if (fstat(a, &sta) < 0)
|
||||
return -errno;
|
||||
|
||||
if (fstat(b, &stb) < 0)
|
||||
return -errno;
|
||||
|
||||
if ((sta.st_mode & S_IFMT) != (stb.st_mode & S_IFMT))
|
||||
return false;
|
||||
|
||||
/* We consider all device fds different, since two device fds
|
||||
* might refer to quite different device contexts even though
|
||||
* they share the same inode and backing dev_t. */
|
||||
|
||||
if (S_ISCHR(sta.st_mode) || S_ISBLK(sta.st_mode))
|
||||
return false;
|
||||
|
||||
if (sta.st_dev != stb.st_dev || sta.st_ino != stb.st_ino)
|
||||
return false;
|
||||
|
||||
/* The fds refer to the same inode on disk, let's also check
|
||||
* if they have the same fd flags. This is useful to
|
||||
* distinguish the read and write side of a pipe created with
|
||||
* pipe(). */
|
||||
fa = fcntl(a, F_GETFL);
|
||||
if (fa < 0)
|
||||
return -errno;
|
||||
|
||||
fb = fcntl(b, F_GETFL);
|
||||
if (fb < 0)
|
||||
return -errno;
|
||||
|
||||
return fa == fb;
|
||||
}
|
||||
|
||||
void cmsg_close_all(struct msghdr *mh) {
|
||||
struct cmsghdr *cmsg;
|
||||
|
||||
assert(mh);
|
||||
|
||||
CMSG_FOREACH(cmsg, mh)
|
||||
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS)
|
||||
close_many((int*) CMSG_DATA(cmsg), (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int));
|
||||
}
|
69
src/basic/fd-util.h
Normal file
69
src/basic/fd-util.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
int close_nointr(int fd);
|
||||
int safe_close(int fd);
|
||||
void safe_close_pair(int p[]);
|
||||
|
||||
void close_many(const int fds[], unsigned n_fd);
|
||||
|
||||
int fclose_nointr(FILE *f);
|
||||
FILE* safe_fclose(FILE *f);
|
||||
DIR* safe_closedir(DIR *f);
|
||||
|
||||
static inline void closep(int *fd) {
|
||||
safe_close(*fd);
|
||||
}
|
||||
|
||||
static inline void close_pairp(int (*p)[2]) {
|
||||
safe_close_pair(*p);
|
||||
}
|
||||
|
||||
static inline void fclosep(FILE **f) {
|
||||
safe_fclose(*f);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, pclose);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DIR*, closedir);
|
||||
|
||||
#define _cleanup_close_ _cleanup_(closep)
|
||||
#define _cleanup_fclose_ _cleanup_(fclosep)
|
||||
#define _cleanup_pclose_ _cleanup_(pclosep)
|
||||
#define _cleanup_closedir_ _cleanup_(closedirp)
|
||||
#define _cleanup_close_pair_ _cleanup_(close_pairp)
|
||||
|
||||
int fd_nonblock(int fd, bool nonblock);
|
||||
int fd_cloexec(int fd, bool cloexec);
|
||||
|
||||
int close_all_fds(const int except[], unsigned n_except);
|
||||
|
||||
int same_fd(int a, int b);
|
||||
|
||||
void cmsg_close_all(struct msghdr *mh);
|
@ -25,10 +25,11 @@
|
||||
|
||||
#include "sd-daemon.h"
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "fdset.h"
|
||||
#include "macro.h"
|
||||
#include "set.h"
|
||||
#include "util.h"
|
||||
#include "macro.h"
|
||||
#include "fdset.h"
|
||||
|
||||
#define MAKE_SET(s) ((Set*) s)
|
||||
#define MAKE_FDSET(s) ((FDSet*) s)
|
||||
|
@ -23,11 +23,12 @@
|
||||
|
||||
#include "ctype.h"
|
||||
#include "escape.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
#include "fileio.h"
|
||||
|
||||
int write_string_stream(FILE *f, const char *line, bool enforce_newline) {
|
||||
|
||||
|
@ -22,9 +22,10 @@
|
||||
#include <ctype.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "hostname-util.h"
|
||||
|
||||
bool hostname_is_set(void) {
|
||||
struct utsname u;
|
||||
|
@ -21,12 +21,13 @@
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "locale-util.h"
|
||||
#include "set.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
#include "locale-util.h"
|
||||
|
||||
static int add_locales_from_archive(Set *locales) {
|
||||
/* Stolen from glibc... */
|
||||
|
@ -27,9 +27,10 @@
|
||||
#include <limits.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "lockfile-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "lockfile-util.h"
|
||||
#include "util.h"
|
||||
|
||||
int make_lock_file(const char *p, int operation, LockFile *ret) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
|
@ -31,7 +31,9 @@
|
||||
|
||||
#include "sd-messages.h"
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "formats-util.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "missing.h"
|
||||
#include "process-util.h"
|
||||
@ -40,7 +42,6 @@
|
||||
#include "string-util.h"
|
||||
#include "terminal-util.h"
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
|
||||
#define SNDBUF_SIZE (8*1024*1024)
|
||||
|
||||
|
@ -27,11 +27,12 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "memfd-util.h"
|
||||
#include "missing.h"
|
||||
#include "string-util.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
#include "memfd-util.h"
|
||||
|
||||
int memfd_new(const char *name) {
|
||||
_cleanup_free_ char *g = NULL;
|
||||
|
@ -21,7 +21,8 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
int memfd_new(const char *name);
|
||||
int memfd_new_and_map(const char *name, size_t sz, void **p);
|
||||
|
@ -27,14 +27,15 @@
|
||||
#include <sys/statvfs.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "missing.h"
|
||||
#include "path-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "util.h"
|
||||
#include "path-util.h"
|
||||
|
||||
bool path_is_absolute(const char *p) {
|
||||
return p[0] == '/';
|
||||
|
@ -29,12 +29,13 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "escape.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "log.h"
|
||||
#include "process-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "process-util.h"
|
||||
|
||||
int get_process_state(pid_t pid) {
|
||||
const char *p;
|
||||
|
@ -17,20 +17,21 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <linux/random.h>
|
||||
#include <stdint.h>
|
||||
#ifdef HAVE_SYS_AUXV_H
|
||||
#include <sys/auxv.h>
|
||||
#endif
|
||||
#include <linux/random.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "missing.h"
|
||||
#include "random-util.h"
|
||||
#include "time-util.h"
|
||||
#include "missing.h"
|
||||
#include "util.h"
|
||||
|
||||
int dev_urandom(void *p, size_t n) {
|
||||
|
@ -20,10 +20,11 @@
|
||||
***/
|
||||
|
||||
#include "btrfs-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "path-util.h"
|
||||
#include "rm-rf.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "rm-rf.h"
|
||||
|
||||
int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
|
||||
_cleanup_closedir_ DIR *d = NULL;
|
||||
|
@ -19,18 +19,19 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "macro.h"
|
||||
#include "util.h"
|
||||
#include "mkdir.h"
|
||||
#include "missing.h"
|
||||
#include "mkdir.h"
|
||||
#include "selinux-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "util.h"
|
||||
|
||||
int socket_address_listen(
|
||||
const SocketAddress *a,
|
||||
|
@ -31,13 +31,14 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "path-util.h"
|
||||
#include "process-util.h"
|
||||
#include "string-util.h"
|
||||
#include "terminal-util.h"
|
||||
#include "time-util.h"
|
||||
#include "util.h"
|
||||
#include "terminal-util.h"
|
||||
|
||||
static volatile unsigned cached_columns = 0;
|
||||
static volatile unsigned cached_lines = 0;
|
||||
|
@ -23,11 +23,12 @@
|
||||
#include <sys/timerfd.h>
|
||||
#include <sys/timex.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "path-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "util.h"
|
||||
#include "time-util.h"
|
||||
#include "util.h"
|
||||
|
||||
usec_t now(clockid_t clock_id) {
|
||||
struct timespec ts;
|
||||
|
301
src/basic/util.c
301
src/basic/util.c
@ -79,6 +79,7 @@
|
||||
#include "env-util.h"
|
||||
#include "escape.h"
|
||||
#include "exit-status.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "formats-util.h"
|
||||
#include "gunicode.h"
|
||||
@ -98,8 +99,8 @@
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
#include "utf8.h"
|
||||
#include "virt.h"
|
||||
#include "util.h"
|
||||
#include "virt.h"
|
||||
|
||||
/* Put this test here for a lack of better place */
|
||||
assert_cc(EAGAIN == EWOULDBLOCK);
|
||||
@ -121,98 +122,6 @@ size_t page_size(void) {
|
||||
return pgsz;
|
||||
}
|
||||
|
||||
int close_nointr(int fd) {
|
||||
assert(fd >= 0);
|
||||
|
||||
if (close(fd) >= 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Just ignore EINTR; a retry loop is the wrong thing to do on
|
||||
* Linux.
|
||||
*
|
||||
* http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html
|
||||
* https://bugzilla.gnome.org/show_bug.cgi?id=682819
|
||||
* http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR
|
||||
* https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain
|
||||
*/
|
||||
if (errno == EINTR)
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
}
|
||||
|
||||
int safe_close(int fd) {
|
||||
|
||||
/*
|
||||
* Like close_nointr() but cannot fail. Guarantees errno is
|
||||
* unchanged. Is a NOP with negative fds passed, and returns
|
||||
* -1, so that it can be used in this syntax:
|
||||
*
|
||||
* fd = safe_close(fd);
|
||||
*/
|
||||
|
||||
if (fd >= 0) {
|
||||
PROTECT_ERRNO;
|
||||
|
||||
/* The kernel might return pretty much any error code
|
||||
* via close(), but the fd will be closed anyway. The
|
||||
* only condition we want to check for here is whether
|
||||
* the fd was invalid at all... */
|
||||
|
||||
assert_se(close_nointr(fd) != -EBADF);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void close_many(const int fds[], unsigned n_fd) {
|
||||
unsigned i;
|
||||
|
||||
assert(fds || n_fd <= 0);
|
||||
|
||||
for (i = 0; i < n_fd; i++)
|
||||
safe_close(fds[i]);
|
||||
}
|
||||
|
||||
int fclose_nointr(FILE *f) {
|
||||
assert(f);
|
||||
|
||||
/* Same as close_nointr(), but for fclose() */
|
||||
|
||||
if (fclose(f) == 0)
|
||||
return 0;
|
||||
|
||||
if (errno == EINTR)
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
}
|
||||
|
||||
FILE* safe_fclose(FILE *f) {
|
||||
|
||||
/* Same as safe_close(), but for fclose() */
|
||||
|
||||
if (f) {
|
||||
PROTECT_ERRNO;
|
||||
|
||||
assert_se(fclose_nointr(f) != EBADF);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DIR* safe_closedir(DIR *d) {
|
||||
|
||||
if (d) {
|
||||
PROTECT_ERRNO;
|
||||
|
||||
assert_se(closedir(d) >= 0 || errno != EBADF);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int unlink_noerrno(const char *path) {
|
||||
PROTECT_ERRNO;
|
||||
int r;
|
||||
@ -1304,123 +1213,6 @@ bool hidden_file(const char *filename) {
|
||||
return hidden_file_allow_backup(filename);
|
||||
}
|
||||
|
||||
int fd_nonblock(int fd, bool nonblock) {
|
||||
int flags, nflags;
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
flags = fcntl(fd, F_GETFL, 0);
|
||||
if (flags < 0)
|
||||
return -errno;
|
||||
|
||||
if (nonblock)
|
||||
nflags = flags | O_NONBLOCK;
|
||||
else
|
||||
nflags = flags & ~O_NONBLOCK;
|
||||
|
||||
if (nflags == flags)
|
||||
return 0;
|
||||
|
||||
if (fcntl(fd, F_SETFL, nflags) < 0)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fd_cloexec(int fd, bool cloexec) {
|
||||
int flags, nflags;
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
flags = fcntl(fd, F_GETFD, 0);
|
||||
if (flags < 0)
|
||||
return -errno;
|
||||
|
||||
if (cloexec)
|
||||
nflags = flags | FD_CLOEXEC;
|
||||
else
|
||||
nflags = flags & ~FD_CLOEXEC;
|
||||
|
||||
if (nflags == flags)
|
||||
return 0;
|
||||
|
||||
if (fcntl(fd, F_SETFD, nflags) < 0)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_pure_ static bool fd_in_set(int fd, const int fdset[], unsigned n_fdset) {
|
||||
unsigned i;
|
||||
|
||||
assert(n_fdset == 0 || fdset);
|
||||
|
||||
for (i = 0; i < n_fdset; i++)
|
||||
if (fdset[i] == fd)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int close_all_fds(const int except[], unsigned n_except) {
|
||||
_cleanup_closedir_ DIR *d = NULL;
|
||||
struct dirent *de;
|
||||
int r = 0;
|
||||
|
||||
assert(n_except == 0 || except);
|
||||
|
||||
d = opendir("/proc/self/fd");
|
||||
if (!d) {
|
||||
int fd;
|
||||
struct rlimit rl;
|
||||
|
||||
/* When /proc isn't available (for example in chroots)
|
||||
* the fallback is brute forcing through the fd
|
||||
* table */
|
||||
|
||||
assert_se(getrlimit(RLIMIT_NOFILE, &rl) >= 0);
|
||||
for (fd = 3; fd < (int) rl.rlim_max; fd ++) {
|
||||
|
||||
if (fd_in_set(fd, except, n_except))
|
||||
continue;
|
||||
|
||||
if (close_nointr(fd) < 0)
|
||||
if (errno != EBADF && r == 0)
|
||||
r = -errno;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
while ((de = readdir(d))) {
|
||||
int fd = -1;
|
||||
|
||||
if (hidden_file(de->d_name))
|
||||
continue;
|
||||
|
||||
if (safe_atoi(de->d_name, &fd) < 0)
|
||||
/* Let's better ignore this, just in case */
|
||||
continue;
|
||||
|
||||
if (fd < 3)
|
||||
continue;
|
||||
|
||||
if (fd == dirfd(d))
|
||||
continue;
|
||||
|
||||
if (fd_in_set(fd, except, n_except))
|
||||
continue;
|
||||
|
||||
if (close_nointr(fd) < 0) {
|
||||
/* Valgrind has its own FD and doesn't want to have it closed */
|
||||
if (errno != EBADF && r == 0)
|
||||
r = -errno;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
bool fstype_is_network(const char *fstype) {
|
||||
static const char table[] =
|
||||
"afs\0"
|
||||
@ -1480,20 +1272,6 @@ int flush_fd(int fd) {
|
||||
}
|
||||
}
|
||||
|
||||
void safe_close_pair(int p[]) {
|
||||
assert(p);
|
||||
|
||||
if (p[0] == p[1]) {
|
||||
/* Special case pairs which use the same fd in both
|
||||
* directions... */
|
||||
p[0] = p[1] = safe_close(p[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
p[0] = safe_close(p[0]);
|
||||
p[1] = safe_close(p[1]);
|
||||
}
|
||||
|
||||
ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) {
|
||||
uint8_t *p = buf;
|
||||
ssize_t n = 0;
|
||||
@ -4804,71 +4582,6 @@ int fd_setcrtime(int fd, usec_t usec) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int same_fd(int a, int b) {
|
||||
struct stat sta, stb;
|
||||
pid_t pid;
|
||||
int r, fa, fb;
|
||||
|
||||
assert(a >= 0);
|
||||
assert(b >= 0);
|
||||
|
||||
/* Compares two file descriptors. Note that semantics are
|
||||
* quite different depending on whether we have kcmp() or we
|
||||
* don't. If we have kcmp() this will only return true for
|
||||
* dup()ed file descriptors, but not otherwise. If we don't
|
||||
* have kcmp() this will also return true for two fds of the same
|
||||
* file, created by separate open() calls. Since we use this
|
||||
* call mostly for filtering out duplicates in the fd store
|
||||
* this difference hopefully doesn't matter too much. */
|
||||
|
||||
if (a == b)
|
||||
return true;
|
||||
|
||||
/* Try to use kcmp() if we have it. */
|
||||
pid = getpid();
|
||||
r = kcmp(pid, pid, KCMP_FILE, a, b);
|
||||
if (r == 0)
|
||||
return true;
|
||||
if (r > 0)
|
||||
return false;
|
||||
if (errno != ENOSYS)
|
||||
return -errno;
|
||||
|
||||
/* We don't have kcmp(), use fstat() instead. */
|
||||
if (fstat(a, &sta) < 0)
|
||||
return -errno;
|
||||
|
||||
if (fstat(b, &stb) < 0)
|
||||
return -errno;
|
||||
|
||||
if ((sta.st_mode & S_IFMT) != (stb.st_mode & S_IFMT))
|
||||
return false;
|
||||
|
||||
/* We consider all device fds different, since two device fds
|
||||
* might refer to quite different device contexts even though
|
||||
* they share the same inode and backing dev_t. */
|
||||
|
||||
if (S_ISCHR(sta.st_mode) || S_ISBLK(sta.st_mode))
|
||||
return false;
|
||||
|
||||
if (sta.st_dev != stb.st_dev || sta.st_ino != stb.st_ino)
|
||||
return false;
|
||||
|
||||
/* The fds refer to the same inode on disk, let's also check
|
||||
* if they have the same fd flags. This is useful to
|
||||
* distinguish the read and write side of a pipe created with
|
||||
* pipe(). */
|
||||
fa = fcntl(a, F_GETFL);
|
||||
if (fa < 0)
|
||||
return -errno;
|
||||
|
||||
fb = fcntl(b, F_GETFL);
|
||||
if (fb < 0)
|
||||
return -errno;
|
||||
|
||||
return fa == fb;
|
||||
}
|
||||
|
||||
int chattr_fd(int fd, unsigned value, unsigned mask) {
|
||||
unsigned old_attr, new_attr;
|
||||
struct stat st;
|
||||
@ -5075,16 +4788,6 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
|
||||
return -1;
|
||||
}
|
||||
|
||||
void cmsg_close_all(struct msghdr *mh) {
|
||||
struct cmsghdr *cmsg;
|
||||
|
||||
assert(mh);
|
||||
|
||||
CMSG_FOREACH(cmsg, mh)
|
||||
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS)
|
||||
close_many((int*) CMSG_DATA(cmsg), (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int));
|
||||
}
|
||||
|
||||
int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath) {
|
||||
struct stat buf;
|
||||
int ret;
|
||||
|
@ -87,16 +87,6 @@ static inline const char* one_zero(bool b) {
|
||||
return b ? "1" : "0";
|
||||
}
|
||||
|
||||
int close_nointr(int fd);
|
||||
int safe_close(int fd);
|
||||
void safe_close_pair(int p[]);
|
||||
|
||||
void close_many(const int fds[], unsigned n_fd);
|
||||
|
||||
int fclose_nointr(FILE *f);
|
||||
FILE* safe_fclose(FILE *f);
|
||||
DIR* safe_closedir(DIR *f);
|
||||
|
||||
int parse_size(const char *t, uint64_t base, uint64_t *size);
|
||||
|
||||
int parse_boolean(const char *v) _pure_;
|
||||
@ -245,11 +235,6 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
|
||||
} \
|
||||
struct __useless_struct_to_allow_trailing_semicolon__
|
||||
|
||||
int fd_nonblock(int fd, bool nonblock);
|
||||
int fd_cloexec(int fd, bool cloexec);
|
||||
|
||||
int close_all_fds(const int except[], unsigned n_except);
|
||||
|
||||
bool fstype_is_network(const char *fstype);
|
||||
|
||||
int flush_fd(int fd);
|
||||
@ -410,35 +395,16 @@ static inline void freep(void *p) {
|
||||
free(*(void**) p);
|
||||
}
|
||||
|
||||
static inline void closep(int *fd) {
|
||||
safe_close(*fd);
|
||||
}
|
||||
|
||||
static inline void umaskp(mode_t *u) {
|
||||
umask(*u);
|
||||
}
|
||||
|
||||
static inline void close_pairp(int (*p)[2]) {
|
||||
safe_close_pair(*p);
|
||||
}
|
||||
|
||||
static inline void fclosep(FILE **f) {
|
||||
safe_fclose(*f);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, pclose);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DIR*, closedir);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, endmntent);
|
||||
|
||||
#define _cleanup_free_ _cleanup_(freep)
|
||||
#define _cleanup_close_ _cleanup_(closep)
|
||||
#define _cleanup_umask_ _cleanup_(umaskp)
|
||||
#define _cleanup_globfree_ _cleanup_(globfree)
|
||||
#define _cleanup_fclose_ _cleanup_(fclosep)
|
||||
#define _cleanup_pclose_ _cleanup_(pclosep)
|
||||
#define _cleanup_closedir_ _cleanup_(closedirp)
|
||||
#define _cleanup_endmntent_ _cleanup_(endmntentp)
|
||||
#define _cleanup_close_pair_ _cleanup_(close_pairp)
|
||||
|
||||
_malloc_ _alloc_(1, 2) static inline void *malloc_multiply(size_t a, size_t b) {
|
||||
if (_unlikely_(b != 0 && a > ((size_t) -1) / b))
|
||||
@ -747,8 +713,6 @@ int fd_getcrtime(int fd, usec_t *usec);
|
||||
int path_getcrtime(const char *p, usec_t *usec);
|
||||
int fd_getcrtime_at(int dirfd, const char *name, usec_t *usec, int flags);
|
||||
|
||||
int same_fd(int a, int b);
|
||||
|
||||
int chattr_fd(int fd, unsigned value, unsigned mask);
|
||||
int chattr_path(const char *p, unsigned value, unsigned mask);
|
||||
|
||||
@ -764,8 +728,6 @@ void sigkill_wait(pid_t *pid);
|
||||
|
||||
int syslog_parse_priority(const char **p, int *priority, bool with_facility);
|
||||
|
||||
void cmsg_close_all(struct msghdr *mh);
|
||||
|
||||
int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
|
||||
|
||||
int parse_mode(const char *s, mode_t *ret);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "conf-files.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "log.h"
|
||||
#include "string-util.h"
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include "blkid-util.h"
|
||||
#include "efivars.h"
|
||||
#include "fd-util.h"
|
||||
#include "rm-rf.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
|
@ -50,6 +50,7 @@
|
||||
|
||||
#include "bootchart.h"
|
||||
#include "conf-parser.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "list.h"
|
||||
#include "macro.h"
|
||||
|
@ -33,12 +33,13 @@
|
||||
|
||||
#include "bootchart.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "store.h"
|
||||
#include "string-util.h"
|
||||
#include "strxcpyx.h"
|
||||
#include "time-util.h"
|
||||
#include "util.h"
|
||||
#include "store.h"
|
||||
|
||||
/*
|
||||
* Alloc a static 4k buffer for stdio - primarily used to increase
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "bootchart.h"
|
||||
#include "list.h"
|
||||
#include "utf8.h"
|
||||
#include "fd-util.h"
|
||||
|
||||
#define time_to_graph(t) ((t) * arg_scale_x)
|
||||
#define ps_to_graph(n) ((n) * arg_scale_y)
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "bus-xml-policy.h"
|
||||
#include "capability.h"
|
||||
#include "def.h"
|
||||
#include "fd-util.h"
|
||||
#include "formats-util.h"
|
||||
#include "log.h"
|
||||
#include "proxy.h"
|
||||
|
@ -22,27 +22,29 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <poll.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
#include "sd-daemon.h"
|
||||
#include "sd-bus.h"
|
||||
#include "sd-daemon.h"
|
||||
|
||||
#include "bus-control.h"
|
||||
#include "bus-internal.h"
|
||||
#include "bus-message.h"
|
||||
#include "bus-util.h"
|
||||
#include "strv.h"
|
||||
#include "bus-control.h"
|
||||
#include "set.h"
|
||||
#include "bus-xml-policy.h"
|
||||
#include "driver.h"
|
||||
#include "proxy.h"
|
||||
#include "synthesize.h"
|
||||
#include "fd-util.h"
|
||||
#include "formats-util.h"
|
||||
#include "log.h"
|
||||
#include "proxy.h"
|
||||
#include "set.h"
|
||||
#include "strv.h"
|
||||
#include "synthesize.h"
|
||||
#include "util.h"
|
||||
|
||||
static int proxy_create_destination(Proxy *p, const char *destination, const char *local_sec, bool negotiate_fds) {
|
||||
_cleanup_bus_flush_close_unref_ sd_bus *b = NULL;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "bus-error.h"
|
||||
#include "bus-util.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "hashmap.h"
|
||||
#include "path-util.h"
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
#include "fd-util.h"
|
||||
|
||||
static bool initialized = false;
|
||||
static int audit_fd;
|
||||
|
@ -30,9 +30,11 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "async.h"
|
||||
#include "automount.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-util.h"
|
||||
#include "dbus-automount.h"
|
||||
#include "fd-util.h"
|
||||
#include "formats-util.h"
|
||||
#include "label.h"
|
||||
#include "mkdir.h"
|
||||
@ -43,7 +45,6 @@
|
||||
#include "string-util.h"
|
||||
#include "unit-name.h"
|
||||
#include "unit.h"
|
||||
#include "automount.h"
|
||||
|
||||
static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = {
|
||||
[AUTOMOUNT_DEAD] = UNIT_INACTIVE,
|
||||
|
@ -25,14 +25,15 @@
|
||||
#include "bus-kernel.h"
|
||||
#include "bus-policy.h"
|
||||
#include "bus-util.h"
|
||||
#include "busname.h"
|
||||
#include "dbus-busname.h"
|
||||
#include "fd-util.h"
|
||||
#include "formats-util.h"
|
||||
#include "kdbus.h"
|
||||
#include "service.h"
|
||||
#include "signal-util.h"
|
||||
#include "special.h"
|
||||
#include "string-util.h"
|
||||
#include "busname.h"
|
||||
|
||||
static const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = {
|
||||
[BUSNAME_DEAD] = UNIT_INACTIVE,
|
||||
|
@ -23,11 +23,12 @@
|
||||
#include <fnmatch.h>
|
||||
|
||||
#include "cgroup-util.h"
|
||||
#include "cgroup.h"
|
||||
#include "fd-util.h"
|
||||
#include "path-util.h"
|
||||
#include "process-util.h"
|
||||
#include "special.h"
|
||||
#include "string-util.h"
|
||||
#include "cgroup.h"
|
||||
|
||||
#define CGROUP_CPU_QUOTA_PERIOD_USEC ((usec_t) 100 * USEC_PER_MSEC)
|
||||
|
||||
|
@ -20,10 +20,11 @@
|
||||
***/
|
||||
|
||||
#include "bus-util.h"
|
||||
#include "path-util.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "cgroup.h"
|
||||
#include "dbus-cgroup.h"
|
||||
#include "fd-util.h"
|
||||
#include "path-util.h"
|
||||
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_cgroup_device_policy, cgroup_device_policy, CGroupDevicePolicy);
|
||||
|
||||
|
@ -25,19 +25,20 @@
|
||||
#include <seccomp.h>
|
||||
#endif
|
||||
|
||||
#include "bus-util.h"
|
||||
#include "missing.h"
|
||||
#include "ioprio.h"
|
||||
#include "strv.h"
|
||||
#include "fileio.h"
|
||||
#include "execute.h"
|
||||
#include "capability.h"
|
||||
#include "env-util.h"
|
||||
#include "af-list.h"
|
||||
#include "bus-util.h"
|
||||
#include "capability.h"
|
||||
#include "dbus-execute.h"
|
||||
#include "env-util.h"
|
||||
#include "execute.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "ioprio.h"
|
||||
#include "missing.h"
|
||||
#include "namespace.h"
|
||||
#include "path-util.h"
|
||||
#include "strv.h"
|
||||
#include "utf8.h"
|
||||
#include "dbus-execute.h"
|
||||
|
||||
#ifdef HAVE_SECCOMP
|
||||
#include "seccomp-util.h"
|
||||
|
@ -29,10 +29,12 @@
|
||||
#include "clock-util.h"
|
||||
#include "dbus-execute.h"
|
||||
#include "dbus-job.h"
|
||||
#include "dbus-manager.h"
|
||||
#include "dbus-snapshot.h"
|
||||
#include "dbus-unit.h"
|
||||
#include "dbus.h"
|
||||
#include "env-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "formats-util.h"
|
||||
#include "install.h"
|
||||
#include "log.h"
|
||||
@ -42,7 +44,6 @@
|
||||
#include "strv.h"
|
||||
#include "virt.h"
|
||||
#include "watchdog.h"
|
||||
#include "dbus-manager.h"
|
||||
|
||||
static int property_get_version(
|
||||
sd_bus *bus,
|
||||
|
@ -24,12 +24,13 @@
|
||||
#include "dbus-cgroup.h"
|
||||
#include "dbus-execute.h"
|
||||
#include "dbus-kill.h"
|
||||
#include "dbus-service.h"
|
||||
#include "fd-util.h"
|
||||
#include "path-util.h"
|
||||
#include "service.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "unit.h"
|
||||
#include "dbus-service.h"
|
||||
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, service_type, ServiceType);
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, service_result, ServiceResult);
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include "dbus-kill.h"
|
||||
#include "dbus-manager.h"
|
||||
#include "dbus-unit.h"
|
||||
#include "dbus.h"
|
||||
#include "fd-util.h"
|
||||
#include "log.h"
|
||||
#include "missing.h"
|
||||
#include "mkdir.h"
|
||||
@ -43,7 +45,6 @@
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "strxcpyx.h"
|
||||
#include "dbus.h"
|
||||
|
||||
#define CONNECTIONS_MAX 4096
|
||||
|
||||
|
@ -53,6 +53,9 @@
|
||||
#include "sd-messages.h"
|
||||
|
||||
#include "af-list.h"
|
||||
#ifdef HAVE_APPARMOR
|
||||
#include "apparmor-util.h"
|
||||
#endif
|
||||
#include "async.h"
|
||||
#include "barrier.h"
|
||||
#include "bus-endpoint.h"
|
||||
@ -61,7 +64,9 @@
|
||||
#include "def.h"
|
||||
#include "env-util.h"
|
||||
#include "errno-list.h"
|
||||
#include "execute.h"
|
||||
#include "exit-status.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "formats-util.h"
|
||||
#include "ioprio.h"
|
||||
@ -73,6 +78,9 @@
|
||||
#include "path-util.h"
|
||||
#include "process-util.h"
|
||||
#include "rm-rf.h"
|
||||
#ifdef HAVE_SECCOMP
|
||||
#include "seccomp-util.h"
|
||||
#endif
|
||||
#include "securebits.h"
|
||||
#include "selinux-util.h"
|
||||
#include "signal-util.h"
|
||||
@ -84,16 +92,6 @@
|
||||
#include "util.h"
|
||||
#include "utmp-wtmp.h"
|
||||
|
||||
#ifdef HAVE_APPARMOR
|
||||
#include "apparmor-util.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SECCOMP
|
||||
#include "seccomp-util.h"
|
||||
#endif
|
||||
|
||||
#include "execute.h"
|
||||
|
||||
#define IDLE_TIMEOUT_USEC (5*USEC_PER_SEC)
|
||||
#define IDLE_TIMEOUT2_USEC (1*USEC_PER_SEC)
|
||||
|
||||
|
@ -24,9 +24,10 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "ima-setup.h"
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
|
||||
#define IMA_SECFS_DIR "/sys/kernel/security/ima"
|
||||
#define IMA_SECFS_POLICY IMA_SECFS_DIR "/policy"
|
||||
|
@ -24,13 +24,14 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "formats-util.h"
|
||||
#include "killall.h"
|
||||
#include "process-util.h"
|
||||
#include "set.h"
|
||||
#include "string-util.h"
|
||||
#include "terminal-util.h"
|
||||
#include "util.h"
|
||||
#include "killall.h"
|
||||
|
||||
#define TIMEOUT_USEC (10 * USEC_PER_SEC)
|
||||
|
||||
|
@ -43,7 +43,9 @@
|
||||
#include "env-util.h"
|
||||
#include "errno-list.h"
|
||||
#include "escape.h"
|
||||
#include "fd-util.h"
|
||||
#include "ioprio.h"
|
||||
#include "load-fragment.h"
|
||||
#include "log.h"
|
||||
#include "missing.h"
|
||||
#include "path-util.h"
|
||||
@ -58,7 +60,6 @@
|
||||
#include "unit-printf.h"
|
||||
#include "unit.h"
|
||||
#include "utf8.h"
|
||||
#include "load-fragment.h"
|
||||
|
||||
int config_parse_warn_compat(
|
||||
const char *unit,
|
||||
|
@ -29,8 +29,10 @@
|
||||
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "log.h"
|
||||
#include "machine-id-setup.h"
|
||||
#include "macro.h"
|
||||
#include "mkdir.h"
|
||||
#include "path-util.h"
|
||||
@ -38,7 +40,6 @@
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "virt.h"
|
||||
#include "machine-id-setup.h"
|
||||
|
||||
static int shorten_uuid(char destination[34], const char source[36]) {
|
||||
unsigned i, j;
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "dbus-manager.h"
|
||||
#include "def.h"
|
||||
#include "env-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fdset.h"
|
||||
#include "fileio.h"
|
||||
#include "formats-util.h"
|
||||
|
@ -53,10 +53,12 @@
|
||||
#include "env-util.h"
|
||||
#include "escape.h"
|
||||
#include "exit-status.h"
|
||||
#include "fd-util.h"
|
||||
#include "hashmap.h"
|
||||
#include "locale-setup.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "manager.h"
|
||||
#include "missing.h"
|
||||
#include "mkdir.h"
|
||||
#include "path-lookup.h"
|
||||
@ -75,7 +77,6 @@
|
||||
#include "util.h"
|
||||
#include "virt.h"
|
||||
#include "watchdog.h"
|
||||
#include "manager.h"
|
||||
|
||||
/* Initial delay and the interval for printing status messages about running jobs */
|
||||
#define JOBS_IN_PROGRESS_WAIT_USEC (5*USEC_PER_SEC)
|
||||
|
@ -29,15 +29,16 @@
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include "dev-setup.h"
|
||||
#include "fd-util.h"
|
||||
#include "loopback-setup.h"
|
||||
#include "missing.h"
|
||||
#include "mkdir.h"
|
||||
#include "namespace.h"
|
||||
#include "path-util.h"
|
||||
#include "selinux-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "util.h"
|
||||
#include "namespace.h"
|
||||
|
||||
typedef enum MountMode {
|
||||
/* This is ordered by priority! */
|
||||
|
@ -27,13 +27,14 @@
|
||||
#include "bus-error.h"
|
||||
#include "bus-util.h"
|
||||
#include "dbus-path.h"
|
||||
#include "fd-util.h"
|
||||
#include "macro.h"
|
||||
#include "mkdir.h"
|
||||
#include "path.h"
|
||||
#include "special.h"
|
||||
#include "string-util.h"
|
||||
#include "unit-name.h"
|
||||
#include "unit.h"
|
||||
#include "path.h"
|
||||
|
||||
static const UnitActiveState state_translation_table[_PATH_STATE_MAX] = {
|
||||
[PATH_DEAD] = UNIT_INACTIVE,
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "env-util.h"
|
||||
#include "escape.h"
|
||||
#include "exit-status.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "formats-util.h"
|
||||
#include "load-dropin.h"
|
||||
@ -40,6 +41,7 @@
|
||||
#include "manager.h"
|
||||
#include "path-util.h"
|
||||
#include "process-util.h"
|
||||
#include "service.h"
|
||||
#include "signal-util.h"
|
||||
#include "special.h"
|
||||
#include "string-util.h"
|
||||
@ -49,7 +51,6 @@
|
||||
#include "unit.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
#include "service.h"
|
||||
|
||||
static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = {
|
||||
[SERVICE_DEAD] = UNIT_INACTIVE,
|
||||
|
@ -28,12 +28,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
#include "smack-setup.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "smack-setup.h"
|
||||
|
||||
#ifdef HAVE_SMACK
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "dbus-socket.h"
|
||||
#include "def.h"
|
||||
#include "exit-status.h"
|
||||
#include "fd-util.h"
|
||||
#include "formats-util.h"
|
||||
#include "label.h"
|
||||
#include "log.h"
|
||||
@ -108,11 +109,9 @@ static void socket_unwatch_control_pid(Socket *s) {
|
||||
}
|
||||
|
||||
static void socket_cleanup_fd_list(SocketPort *p) {
|
||||
int k = p->n_auxiliary_fds;
|
||||
|
||||
while (k--)
|
||||
safe_close(p->auxiliary_fds[k]);
|
||||
assert(p);
|
||||
|
||||
close_many(p->auxiliary_fds, p->n_auxiliary_fds);
|
||||
p->auxiliary_fds = mfree(p->auxiliary_fds);
|
||||
p->n_auxiliary_fds = 0;
|
||||
}
|
||||
|
@ -29,16 +29,17 @@
|
||||
#include "dbus-swap.h"
|
||||
#include "escape.h"
|
||||
#include "exit-status.h"
|
||||
#include "fd-util.h"
|
||||
#include "formats-util.h"
|
||||
#include "fstab-util.h"
|
||||
#include "path-util.h"
|
||||
#include "special.h"
|
||||
#include "string-util.h"
|
||||
#include "swap.h"
|
||||
#include "udev-util.h"
|
||||
#include "unit-name.h"
|
||||
#include "unit.h"
|
||||
#include "virt.h"
|
||||
#include "swap.h"
|
||||
|
||||
static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = {
|
||||
[SWAP_DEAD] = UNIT_INACTIVE,
|
||||
|
@ -30,14 +30,15 @@
|
||||
#include "libudev.h"
|
||||
|
||||
#include "escape.h"
|
||||
#include "fd-util.h"
|
||||
#include "list.h"
|
||||
#include "mount-setup.h"
|
||||
#include "path-util.h"
|
||||
#include "string-util.h"
|
||||
#include "udev-util.h"
|
||||
#include "umount.h"
|
||||
#include "util.h"
|
||||
#include "virt.h"
|
||||
#include "umount.h"
|
||||
|
||||
typedef struct MountPoint {
|
||||
char *path;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "dropin.h"
|
||||
#include "fd-util.h"
|
||||
#include "fstab-util.h"
|
||||
#include "generator.h"
|
||||
#include "hashmap.h"
|
||||
|
@ -19,14 +19,15 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "util.h"
|
||||
#include "conf-parser.h"
|
||||
#include "special.h"
|
||||
#include "mkdir.h"
|
||||
#include "bus-util.h"
|
||||
#include "bus-internal.h"
|
||||
#include "unit-name.h"
|
||||
#include "bus-util.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "conf-parser.h"
|
||||
#include "fd-util.h"
|
||||
#include "mkdir.h"
|
||||
#include "special.h"
|
||||
#include "unit-name.h"
|
||||
#include "util.h"
|
||||
|
||||
static const char *arg_dest_late = "/tmp", *arg_dest = "/tmp";
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <sys/prctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "hashmap.h"
|
||||
#include "log.h"
|
||||
#include "pager.h"
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "terminal-util.h"
|
||||
#include "time-util.h"
|
||||
#include "string-util.h"
|
||||
#include "fd-util.h"
|
||||
|
||||
static char *arg_root = NULL;
|
||||
static char *arg_locale = NULL; /* $LANG */
|
||||
|
@ -32,16 +32,17 @@
|
||||
#include "sd-bus.h"
|
||||
#include "sd-device.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "bus-common-errors.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-util.h"
|
||||
#include "device-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "path-util.h"
|
||||
#include "process-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "special.h"
|
||||
#include "bus-util.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-common-errors.h"
|
||||
#include "device-util.h"
|
||||
#include "path-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "special.h"
|
||||
#include "util.h"
|
||||
|
||||
/* exit codes as defined in fsck(8) */
|
||||
enum {
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "fstab-util.h"
|
||||
#include "generator.h"
|
||||
#include "log.h"
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "log.h"
|
||||
#include "mkdir.h"
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "blkid-util.h"
|
||||
#include "btrfs-util.h"
|
||||
#include "efivars.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "fstab-util.h"
|
||||
#include "generator.h"
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "strv.h"
|
||||
#include "util.h"
|
||||
#include "verbs.h"
|
||||
#include "fd-util.h"
|
||||
|
||||
/*
|
||||
* Generic udev properties, key/value database based on modalias strings.
|
||||
|
@ -19,8 +19,9 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "string-util.h"
|
||||
#include "curl-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "string-util.h"
|
||||
|
||||
static void curl_glue_check_finished(CurlGlue *g) {
|
||||
CURLMsg *msg;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "btrfs-util.h"
|
||||
#include "copy.h"
|
||||
#include "export-raw.h"
|
||||
#include "fd-util.h"
|
||||
#include "import-common.h"
|
||||
#include "ratelimit.h"
|
||||
#include "string-util.h"
|
||||
|
@ -22,12 +22,13 @@
|
||||
#include "sd-daemon.h"
|
||||
|
||||
#include "btrfs-util.h"
|
||||
#include "export-tar.h"
|
||||
#include "fd-util.h"
|
||||
#include "import-common.h"
|
||||
#include "process-util.h"
|
||||
#include "ratelimit.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "export-tar.h"
|
||||
|
||||
#define COPY_BUFFER_SIZE (16*1024)
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "event-util.h"
|
||||
#include "export-raw.h"
|
||||
#include "export-tar.h"
|
||||
#include "fd-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-util.h"
|
||||
#include "machine-image.h"
|
||||
|
@ -26,9 +26,10 @@
|
||||
|
||||
#include "btrfs-util.h"
|
||||
#include "capability.h"
|
||||
#include "fd-util.h"
|
||||
#include "import-common.h"
|
||||
#include "signal-util.h"
|
||||
#include "util.h"
|
||||
#include "import-common.h"
|
||||
|
||||
int import_make_read_only_fd(int fd) {
|
||||
int r;
|
||||
|
@ -26,9 +26,11 @@
|
||||
|
||||
#include "btrfs-util.h"
|
||||
#include "copy.h"
|
||||
#include "fd-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-common.h"
|
||||
#include "import-compress.h"
|
||||
#include "import-raw.h"
|
||||
#include "machine-pool.h"
|
||||
#include "mkdir.h"
|
||||
#include "path-util.h"
|
||||
@ -37,7 +39,6 @@
|
||||
#include "rm-rf.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "import-raw.h"
|
||||
|
||||
struct RawImport {
|
||||
sd_event *event;
|
||||
|
@ -26,9 +26,11 @@
|
||||
|
||||
#include "btrfs-util.h"
|
||||
#include "copy.h"
|
||||
#include "fd-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-common.h"
|
||||
#include "import-compress.h"
|
||||
#include "import-tar.h"
|
||||
#include "machine-pool.h"
|
||||
#include "mkdir.h"
|
||||
#include "path-util.h"
|
||||
@ -38,7 +40,6 @@
|
||||
#include "rm-rf.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "import-tar.h"
|
||||
|
||||
struct TarImport {
|
||||
sd_event *event;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "sd-event.h"
|
||||
|
||||
#include "event-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-raw.h"
|
||||
#include "import-tar.h"
|
||||
|
@ -22,20 +22,22 @@
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "sd-bus.h"
|
||||
#include "util.h"
|
||||
#include "strv.h"
|
||||
#include "bus-util.h"
|
||||
|
||||
#include "bus-common-errors.h"
|
||||
#include "socket-util.h"
|
||||
#include "mkdir.h"
|
||||
#include "bus-util.h"
|
||||
#include "def.h"
|
||||
#include "missing.h"
|
||||
#include "machine-pool.h"
|
||||
#include "path-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-util.h"
|
||||
#include "machine-pool.h"
|
||||
#include "missing.h"
|
||||
#include "mkdir.h"
|
||||
#include "path-util.h"
|
||||
#include "process-util.h"
|
||||
#include "signal-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "strv.h"
|
||||
#include "util.h"
|
||||
|
||||
typedef struct Transfer Transfer;
|
||||
typedef struct Manager Manager;
|
||||
|
@ -25,7 +25,9 @@
|
||||
#include "capability.h"
|
||||
#include "copy.h"
|
||||
#include "escape.h"
|
||||
#include "fd-util.h"
|
||||
#include "process-util.h"
|
||||
#include "pull-common.h"
|
||||
#include "pull-job.h"
|
||||
#include "rm-rf.h"
|
||||
#include "signal-util.h"
|
||||
@ -33,7 +35,6 @@
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "util.h"
|
||||
#include "pull-common.h"
|
||||
|
||||
#define FILENAME_ESCAPE "/.#\"\'"
|
||||
#define HASH_URL_THRESHOLD_LENGTH (_POSIX_PATH_MAX - 16)
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "aufs-util.h"
|
||||
#include "btrfs-util.h"
|
||||
#include "curl-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-common.h"
|
||||
#include "import-util.h"
|
||||
|
@ -21,10 +21,11 @@
|
||||
|
||||
#include <sys/xattr.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "machine-pool.h"
|
||||
#include "pull-job.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "pull-job.h"
|
||||
|
||||
PullJob* pull_job_unref(PullJob *j) {
|
||||
if (!j)
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "btrfs-util.h"
|
||||
#include "copy.h"
|
||||
#include "curl-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-common.h"
|
||||
#include "import-util.h"
|
||||
@ -36,13 +37,13 @@
|
||||
#include "path-util.h"
|
||||
#include "pull-common.h"
|
||||
#include "pull-job.h"
|
||||
#include "pull-raw.h"
|
||||
#include "qcow2-util.h"
|
||||
#include "rm-rf.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
#include "pull-raw.h"
|
||||
|
||||
typedef enum RawProgress {
|
||||
RAW_DOWNLOADING,
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "btrfs-util.h"
|
||||
#include "copy.h"
|
||||
#include "curl-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "hostname-util.h"
|
||||
#include "import-common.h"
|
||||
#include "import-util.h"
|
||||
@ -36,12 +37,12 @@
|
||||
#include "process-util.h"
|
||||
#include "pull-common.h"
|
||||
#include "pull-job.h"
|
||||
#include "pull-tar.h"
|
||||
#include "rm-rf.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
#include "pull-tar.h"
|
||||
|
||||
typedef enum TarProgress {
|
||||
TAR_DOWNLOADING,
|
||||
|
@ -19,10 +19,10 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "qcow2-util.h"
|
||||
#include "util.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_close_ int sfd = -1, dfd = -1;
|
||||
|
@ -25,18 +25,19 @@
|
||||
#include <sys/epoll.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "sd-daemon.h"
|
||||
#include "sd-bus.h"
|
||||
#include "sd-daemon.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
#include "list.h"
|
||||
#include "initreq.h"
|
||||
#include "special.h"
|
||||
#include "bus-util.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-util.h"
|
||||
#include "def.h"
|
||||
#include "fd-util.h"
|
||||
#include "formats-util.h"
|
||||
#include "initreq.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "special.h"
|
||||
#include "util.h"
|
||||
|
||||
#define SERVER_FD_MAX 16
|
||||
#define TIMEOUT_MSEC ((int) (DEFAULT_EXIT_USEC/USEC_PER_MSEC))
|
||||
|
@ -19,21 +19,22 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <microhttpd.h>
|
||||
#ifdef HAVE_GNUTLS
|
||||
#include <gnutls/gnutls.h>
|
||||
#endif
|
||||
#include <microhttpd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sd-journal.h"
|
||||
#include "sd-daemon.h"
|
||||
#include "sd-bus.h"
|
||||
#include "sd-daemon.h"
|
||||
#include "sd-journal.h"
|
||||
|
||||
#include "bus-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "hostname-util.h"
|
||||
#include "log.h"
|
||||
|
@ -19,9 +19,10 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "journal-remote-parse.h"
|
||||
#include "journald-native.h"
|
||||
#include "string-util.h"
|
||||
#include "journal-remote-parse.h"
|
||||
|
||||
#define LINE_CHUNK 8*1024u
|
||||
|
||||
|
@ -37,16 +37,17 @@
|
||||
|
||||
#include "conf-parser.h"
|
||||
#include "escape.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "journal-file.h"
|
||||
#include "journal-remote-write.h"
|
||||
#include "journal-remote.h"
|
||||
#include "journald-native.h"
|
||||
#include "macro.h"
|
||||
#include "signal-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "journal-remote.h"
|
||||
|
||||
#define REMOTE_JOURNAL_PATH "/var/log/journal/remote"
|
||||
|
||||
|
@ -28,15 +28,16 @@
|
||||
#include "sd-daemon.h"
|
||||
|
||||
#include "conf-parser.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "formats-util.h"
|
||||
#include "journal-upload.h"
|
||||
#include "log.h"
|
||||
#include "mkdir.h"
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "journal-upload.h"
|
||||
|
||||
#define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-upload.pem"
|
||||
#define CERT_FILE CERTIFICATE_ROOT "/certs/journal-upload.pem"
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "sd-journal.h"
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "catalog.h"
|
||||
#include "conf-files.h"
|
||||
#include "fd-util.h"
|
||||
#include "hashmap.h"
|
||||
#include "log.h"
|
||||
#include "mkdir.h"
|
||||
|
@ -25,20 +25,21 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_XZ
|
||||
# include <lzma.h>
|
||||
#include <lzma.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LZ4
|
||||
# include <lz4.h>
|
||||
# include <lz4frame.h>
|
||||
#include <lz4.h>
|
||||
#include <lz4frame.h>
|
||||
#endif
|
||||
|
||||
#include "compress.h"
|
||||
#include "fd-util.h"
|
||||
#include "journal-def.h"
|
||||
#include "macro.h"
|
||||
#include "sparse-endian.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
#include "compress.h"
|
||||
|
||||
#ifdef HAVE_LZ4
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(LZ4F_compressionContext_t, LZ4F_freeCompressionContext);
|
||||
|
@ -21,12 +21,13 @@
|
||||
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
#include "coredump-vacuum.h"
|
||||
#include "fd-util.h"
|
||||
#include "hashmap.h"
|
||||
#include "macro.h"
|
||||
#include "string-util.h"
|
||||
#include "time-util.h"
|
||||
#include "util.h"
|
||||
#include "coredump-vacuum.h"
|
||||
|
||||
#define DEFAULT_MAX_USE_LOWER (uint64_t) (1ULL*1024ULL*1024ULL) /* 1 MiB */
|
||||
#define DEFAULT_MAX_USE_UPPER (uint64_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "copy.h"
|
||||
#include "coredump-vacuum.h"
|
||||
#include "escape.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "journald-native.h"
|
||||
#include "log.h"
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "sd-journal.h"
|
||||
|
||||
#include "compress.h"
|
||||
#include "fd-util.h"
|
||||
#include "journal-internal.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
|
@ -22,10 +22,11 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "fd-util.h"
|
||||
#include "fsprg.h"
|
||||
#include "journal-authenticate.h"
|
||||
#include "journal-def.h"
|
||||
#include "journal-file.h"
|
||||
#include "journal-authenticate.h"
|
||||
#include "fsprg.h"
|
||||
|
||||
static uint64_t journal_file_tag_seqnum(JournalFile *f) {
|
||||
uint64_t r;
|
||||
|
@ -21,11 +21,10 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "sparse-endian.h"
|
||||
|
||||
#include "systemd/sd-id128.h"
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "macro.h"
|
||||
#include "sparse-endian.h"
|
||||
|
||||
/*
|
||||
* If you change this file you probably should also change its documentation:
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user