Commit 606ad7e6 authored by Thomas Haller's avatar Thomas Haller

systemd: update code from upstream

This is a direct dump from systemd git on 2016-01-04, git commit
993898a2af5bc34e600b81aafec055cc93be0b02.

======

SYSTEMD_DIR=../systemd
COMMIT=993898a2af5bc34e600b81aafec055cc93be0b02

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files :/src/systemd/src/ | xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd "src/basic/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/io-util.c"
nm_copy_sd "src/basic/io-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/set.h"
nm_copy_sd "src/basic/siphash24.c"
nm_copy_sd "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/umask-util.h"
nm_copy_sd "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/lldp.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-port.c"
nm_copy_sd "src/libsystemd-network/lldp-port.h"
nm_copy_sd "src/libsystemd-network/lldp-tlv.c"
nm_copy_sd "src/libsystemd-network/lldp-tlv.h"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
parent aa9d0d14
......@@ -19,7 +19,11 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdint.h>
#include <string.h>
#include "alloc-util.h"
#include "macro.h"
#include "util.h"
void* memdup(const void *p, size_t l) {
......
......@@ -22,6 +22,7 @@
***/
#include <alloca.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
......
......@@ -19,12 +19,15 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "alloc-util.h"
#include "escape.h"
#include "hexdecoct.h"
#include "string-util.h"
#include "macro.h"
#include "utf8.h"
#include "util.h"
size_t cescape_char(char c, char *buf) {
char * buf_old = buf;
......@@ -89,20 +92,20 @@ size_t cescape_char(char c, char *buf) {
return buf - buf_old;
}
char *cescape(const char *s) {
char *r, *t;
char *cescape_length(const char *s, size_t n) {
const char *f;
char *r, *t;
assert(s);
assert(s || n == 0);
/* Does C style string escaping. May be reversed with
* cunescape(). */
r = new(char, strlen(s)*4 + 1);
r = new(char, n*4 + 1);
if (!r)
return NULL;
for (f = s, t = r; *f; f++)
for (f = s, t = r; f < s + n; f++)
t += cescape_char(*f, t);
*t = 0;
......@@ -110,6 +113,12 @@ char *cescape(const char *s) {
return r;
}
char *cescape(const char *s) {
assert(s);
return cescape_length(s, strlen(s));
}
int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode) {
int r = 1;
......
......@@ -22,8 +22,12 @@
***/
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include "string-util.h"
/* What characters are special in the shell? */
/* must be escaped outside and inside double-quotes */
#define SHELL_NEED_ESCAPE "\"\\`$"
......@@ -35,6 +39,7 @@ typedef enum UnescapeFlags {
} UnescapeFlags;
char *cescape(const char *s);
char *cescape_length(const char *s, size_t n);
size_t cescape_char(char c, char *buf);
int cunescape(const char *s, UnescapeFlags flags, char **ret);
......
......@@ -19,9 +19,18 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "dirent-util.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <unistd.h>
#include "fd-util.h"
#include "macro.h"
#include "missing.h"
#include "parse-util.h"
#include "path-util.h"
#include "socket-util.h"
#include "util.h"
......
......@@ -19,6 +19,15 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "alloc-util.h"
......@@ -28,15 +37,17 @@
#include "fileio.h"
#include "fs-util.h"
#include "hexdecoct.h"
#include "log.h"
#include "macro.h"
#include "parse-util.h"
#include "path-util.h"
#include "random-util.h"
#include "stdio-util.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
#include "umask-util.h"
#include "utf8.h"
#include "util.h"
int write_string_stream(FILE *f, const char *line, bool enforce_newline) {
......
......@@ -19,16 +19,30 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <dirent.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include "alloc-util.h"
#include "dirent-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "log.h"
#include "macro.h"
#include "missing.h"
#include "mkdir.h"
#include "parse-util.h"
#include "path-util.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
#include "user-util.h"
#include "util.h"
......
......@@ -23,6 +23,8 @@
#include <fcntl.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/inotify.h>
#include <sys/types.h>
#include <unistd.h>
......
......@@ -21,8 +21,9 @@
***/
#include <errno.h>
#include <pthread.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "alloc-util.h"
#include "hashmap.h"
......@@ -36,6 +37,7 @@
#include "util.h"
#ifdef ENABLE_DEBUG_HASHMAP
#include <pthread.h>
#include "list.h"
#endif
......
......@@ -22,7 +22,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include "macro.h"
#include "siphash24.h"
......
......@@ -20,11 +20,13 @@
***/
#include <ctype.h>
#include <inttypes.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include "alloc-util.h"
#include "hexdecoct.h"
#include "util.h"
#include "macro.h"
char octchar(int x) {
return '0' + (x & 7);
......
......@@ -22,6 +22,7 @@
***/
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
......
......@@ -19,14 +19,19 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <ctype.h>
#include <bits/local_lim.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <sys/utsname.h>
#include <unistd.h>
#include "fd-util.h"
#include "fileio.h"
#include "hostname-util.h"
#include "macro.h"
#include "string-util.h"
#include "util.h"
bool hostname_is_set(void) {
struct utsname u;
......
......@@ -20,9 +20,15 @@
***/
#include <arpa/inet.h>
#include <endian.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include "alloc-util.h"
#include "in-addr-util.h"
#include "macro.h"
#include "util.h"
int in_addr_is_null(int family, const union in_addr_union *u) {
assert(u);
......@@ -44,7 +50,7 @@ int in_addr_is_link_local(int family, const union in_addr_union *u) {
assert(u);
if (family == AF_INET)
return (be32toh(u->in.s_addr) & 0xFFFF0000) == (169U << 24 | 254U << 16);
return (be32toh(u->in.s_addr) & UINT32_C(0xFFFF0000)) == (UINT32_C(169) << 24 | UINT32_C(254) << 16);
if (family == AF_INET6)
return IN6_IS_ADDR_LINKLOCAL(&u->in6);
......@@ -52,6 +58,19 @@ int in_addr_is_link_local(int family, const union in_addr_union *u) {
return -EAFNOSUPPORT;
}
int in_addr_is_localhost(int family, const union in_addr_union *u) {
assert(u);
if (family == AF_INET)
/* All of 127.x.x.x is localhost. */
return (be32toh(u->in.s_addr) & UINT32_C(0xFF000000)) == UINT32_C(127) << 24;
if (family == AF_INET6)
return IN6_IS_ADDR_LOOPBACK(&u->in6);
return -EAFNOSUPPORT;
}
int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b) {
assert(a);
assert(b);
......
......@@ -22,6 +22,8 @@
***/
#include <netinet/in.h>
#include <stddef.h>
#include <sys/socket.h>
#include "macro.h"
#include "util.h"
......@@ -33,6 +35,7 @@ union in_addr_union {
int in_addr_is_null(int family, const union in_addr_union *u);
int in_addr_is_link_local(int family, const union in_addr_union *u);
int in_addr_is_localhost(int family, const union in_addr_union *u);
int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b);
int in_addr_prefix_intersect(int family, const union in_addr_union *a, unsigned aprefixlen, const union in_addr_union *b, unsigned bprefixlen);
int in_addr_prefix_next(int family, union in_addr_union *u, unsigned prefixlen);
......
......@@ -19,10 +19,15 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <limits.h>
#include <poll.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "io-util.h"
#include "time-util.h"
int flush_fd(int fd) {
struct pollfd pollfd = {
......
......@@ -22,9 +22,12 @@
***/
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/uio.h>
#include "macro.h"
#include "time-util.h"
int flush_fd(int fd);
......
......@@ -20,6 +20,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdint.h>
#include <stdlib.h>
#include "macro.h"
#include "mempool.h"
#include "util.h"
......
......@@ -19,11 +19,19 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <inttypes.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <xlocale.h>
#include "alloc-util.h"
#include "extract-word.h"
#include "macro.h"
#include "parse-util.h"
#include "string-util.h"
#include "util.h"
int parse_boolean(const char *v) {
assert(v);
......
......@@ -22,6 +22,9 @@
***/
#include <inttypes.h>
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include "macro.h"
......
......@@ -20,11 +20,11 @@
***/
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/statvfs.h>
#include <sys/stat.h>
#include <unistd.h>
/* When we include libgen.h because we need dirname() we immediately
......@@ -34,18 +34,16 @@
#undef basename
#include "alloc-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "extract-word.h"
#include "fs-util.h"
#include "log.h"
#include "macro.h"
#include "missing.h"
#include "parse-util.h"
#include "path-util.h"
#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
#include "time-util.h"
bool path_is_absolute(const char *p) {
return p[0] == '/';
......
......@@ -21,7 +21,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <alloca.h>
#include <stdbool.h>
#include <stddef.h>
#include "macro.h"
#include "time-util.h"
......
......@@ -29,9 +29,12 @@
* The underlying algorithm used in this implementation is a Heap.
*/
#include <errno.h>
#include <stdlib.h>
#include "alloc-util.h"
#include "hashmap.h"
#include "prioq.h"
#include "util.h"
struct prioq_item {
void *data;
......
......@@ -21,7 +21,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdbool.h>
#include "hashmap.h"
#include "macro.h"
typedef struct Prioq Prioq;
......
......@@ -17,23 +17,24 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <elf.h>
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/time.h>
#include <linux/random.h>
#include <stdint.h>
#ifdef HAVE_SYS_AUXV_H
#include <sys/auxv.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include "fd-util.h"
#include "io-util.h"
#include "missing.h"
#include "random-util.h"
#include "time-util.h"
#include "util.h"
int dev_urandom(void *p, size_t n) {
static int have_syscall = -1;
......
......@@ -19,6 +19,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stddef.h>
#include <stdint.h>
int dev_urandom(void *p, size_t n);
......
......@@ -27,7 +27,6 @@
Set *internal_set_new(const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS);
#define set_new(ops) internal_set_new(ops HASHMAP_DEBUG_SRC_ARGS)
static inline Set *set_free(Set *s) {
internal_hashmap_free(HASHMAP_BASE(s));
return NULL;
......
......@@ -17,10 +17,9 @@
coding style)
*/
#include "macro.h"
#include "siphash24.h"
#include "sparse-endian.h"
#include "unaligned.h"
#include "util.h"
static inline uint64_t rotate_left(uint64_t x, uint8_t b) {
assert(b < 64);
......
#pragma once
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
struct siphash {
......
......@@ -23,7 +23,10 @@
#include <netinet/ether.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stddef.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <linux/netlink.h>
#include <linux/if_packet.h>
......@@ -125,7 +128,11 @@ int ip_tos_from_string(const char *s);
int getpeercred(int fd, struct ucred *ucred);
int getpeersec(int fd, char **ret);
int send_one_fd(int transport_fd, int fd, int flags);
int send_one_fd_sa(int transport_fd,
int fd,
const struct sockaddr *sa, socklen_t len,
int flags);
#define send_one_fd(transport_fd, fd, flags) send_one_fd_sa(transport_fd, fd, NULL, 0, flags)
int receive_one_fd(int transport_fd, int flags);
#define CMSG_FOREACH(cmsg, mh) \
......
......@@ -20,6 +20,7 @@
***/
#include "string-table.h"
#include "string-util.h"
ssize_t string_table_lookup(const char * const *table, size_t len, const char *key) {
size_t i;
......
......@@ -22,6 +22,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
......
......@@ -19,8 +19,15 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "alloc-util.h"
#include "gunicode.h"
#include "macro.h"
#include "string-util.h"
#include "utf8.h"
#include "util.h"
......
......@@ -21,7 +21,9 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <alloca.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include "macro.h"
......
......@@ -20,12 +20,15 @@
***/
#include <errno.h>
#include <fnmatch.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "alloc-util.h"
#include "escape.h"
#include "extract-word.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
......
......@@ -24,8 +24,11 @@
#include <fnmatch.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include "alloc-util.h"
#include "extract-word.h"
#include "macro.h"
#include "util.h"
char *strv_find(char **l, const char *name) _pure_;
......
......@@ -19,20 +19,28 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/timerfd.h>
#include <sys/timex.h>
#include <sys/types.h>
#include <unistd.h>
#include "alloc-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "log.h"
#include "macro.h"
#include "parse-util.h"
#include "path-util.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
#include "util.h"
usec_t now(clockid_t clock_id) {
struct timespec ts;
......
......@@ -22,6 +22,9 @@
***/
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
......
......@@ -44,15 +44,14 @@
*/
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "alloc-util.h"
#include "hexdecoct.h"
#include "macro.h"
#include "utf8.h"
#include "util.h"
bool unichar_is_valid(uint32_t ch) {
......
......@@ -22,6 +22,8 @@
***/
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>