summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-02-03 02:05:59 +0100
committerLennart Poettering <lennart@poettering.net>2015-02-03 02:05:59 +0100
commit63c372cb9df3bee01e3bf8cd7f96f336bddda846 (patch)
treebf4d1b6e41f72927a2b58e7dd21daa0c496aaa96 /src/journal
parent44de0efc6e406515fc1cf8b95d9655d0d7f7ffff (diff)
util: rework strappenda(), and rename it strjoina()
After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/coredump.c30
-rw-r--r--src/journal/journalctl.c2
-rw-r--r--src/journal/journald-server.c46
-rw-r--r--src/journal/journald-syslog.c6
-rw-r--r--src/journal/sd-journal.c10
5 files changed, 47 insertions, 47 deletions
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index f6b95145d2..f7ba0191e1 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -634,11 +634,11 @@ int main(int argc, char* argv[]) {
goto finish;
}
- core_unit = strappenda("COREDUMP_UNIT=", t);
+ core_unit = strjoina("COREDUMP_UNIT=", t);
free(t);
} else if (cg_pid_get_user_unit(pid, &t) >= 0) {
- core_unit = strappenda("COREDUMP_USER_UNIT=", t);
+ core_unit = strjoina("COREDUMP_USER_UNIT=", t);
free(t);
}
@@ -650,20 +650,20 @@ int main(int argc, char* argv[]) {
log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
log_open();
- core_pid = strappenda("COREDUMP_PID=", info[INFO_PID]);
+ core_pid = strjoina("COREDUMP_PID=", info[INFO_PID]);
IOVEC_SET_STRING(iovec[j++], core_pid);
- core_uid = strappenda("COREDUMP_UID=", info[INFO_UID]);
+ core_uid = strjoina("COREDUMP_UID=", info[INFO_UID]);
IOVEC_SET_STRING(iovec[j++], core_uid);
- core_gid = strappenda("COREDUMP_GID=", info[INFO_GID]);
+ core_gid = strjoina("COREDUMP_GID=", info[INFO_GID]);
IOVEC_SET_STRING(iovec[j++], core_gid);
- core_signal = strappenda("COREDUMP_SIGNAL=", info[INFO_SIGNAL]);
+ core_signal = strjoina("COREDUMP_SIGNAL=", info[INFO_SIGNAL]);
IOVEC_SET_STRING(iovec[j++], core_signal);
if (sd_pid_get_session(pid, &t) >= 0) {
- core_session = strappenda("COREDUMP_SESSION=", t);
+ core_session = strjoina("COREDUMP_SESSION=", t);
free(t);
IOVEC_SET_STRING(iovec[j++], core_session);
@@ -677,31 +677,31 @@ int main(int argc, char* argv[]) {
}
if (sd_pid_get_slice(pid, &t) >= 0) {
- core_slice = strappenda("COREDUMP_SLICE=", t);
+ core_slice = strjoina("COREDUMP_SLICE=", t);
free(t);
IOVEC_SET_STRING(iovec[j++], core_slice);
}
if (comm) {
- core_comm = strappenda("COREDUMP_COMM=", comm);
+ core_comm = strjoina("COREDUMP_COMM=", comm);
IOVEC_SET_STRING(iovec[j++], core_comm);
}
if (exe) {
- core_exe = strappenda("COREDUMP_EXE=", exe);
+ core_exe = strjoina("COREDUMP_EXE=", exe);
IOVEC_SET_STRING(iovec[j++], core_exe);
}
if (get_process_cmdline(pid, 0, false, &t) >= 0) {
- core_cmdline = strappenda("COREDUMP_CMDLINE=", t);
+ core_cmdline = strjoina("COREDUMP_CMDLINE=", t);
free(t);
IOVEC_SET_STRING(iovec[j++], core_cmdline);
}
if (cg_pid_get_path_shifted(pid, NULL, &t) >= 0) {
- core_cgroup = strappenda("COREDUMP_CGROUP=", t);
+ core_cgroup = strjoina("COREDUMP_CGROUP=", t);
free(t);
IOVEC_SET_STRING(iovec[j++], core_cgroup);
@@ -752,14 +752,14 @@ int main(int argc, char* argv[]) {
}
if (get_process_cwd(pid, &t) >= 0) {
- core_cwd = strappenda("COREDUMP_CWD=", t);
+ core_cwd = strjoina("COREDUMP_CWD=", t);
free(t);
IOVEC_SET_STRING(iovec[j++], core_cwd);
}
if (get_process_root(pid, &t) >= 0) {
- core_root = strappenda("COREDUMP_ROOT=", t);
+ core_root = strjoina("COREDUMP_ROOT=", t);
free(t);
IOVEC_SET_STRING(iovec[j++], core_root);
@@ -799,7 +799,7 @@ int main(int argc, char* argv[]) {
if (r == 0) {
const char *coredump_filename;
- coredump_filename = strappenda("COREDUMP_FILENAME=", filename);
+ coredump_filename = strjoina("COREDUMP_FILENAME=", filename);
IOVEC_SET_STRING(iovec[j++], coredump_filename);
}
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index c17cf55c30..55c7786331 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1269,7 +1269,7 @@ static int add_syslog_identifier(sd_journal *j) {
STRV_FOREACH(i, arg_syslog_identifier) {
char *u;
- u = strappenda("SYSLOG_IDENTIFIER=", *i);
+ u = strjoina("SYSLOG_IDENTIFIER=", *i);
r = sd_journal_add_match(j, u, 0);
if (r < 0)
return r;
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index aecf8596dc..7ee8174ea2 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -378,7 +378,7 @@ static void do_vacuum(
if (!f)
return;
- p = strappenda(path, id);
+ p = strjoina(path, id);
r = journal_directory_vacuum(p, metrics->max_use, s->max_retention_usec, &s->oldest_file_usec, false);
if (r < 0 && r != -ENOENT)
log_error_errno(r, "Failed to vacuum %s: %m", p);
@@ -589,28 +589,28 @@ static void dispatch_message_real(
r = get_process_comm(ucred->pid, &t);
if (r >= 0) {
- x = strappenda("_COMM=", t);
+ x = strjoina("_COMM=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
r = get_process_exe(ucred->pid, &t);
if (r >= 0) {
- x = strappenda("_EXE=", t);
+ x = strjoina("_EXE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
r = get_process_cmdline(ucred->pid, 0, false, &t);
if (r >= 0) {
- x = strappenda("_CMDLINE=", t);
+ x = strjoina("_CMDLINE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
r = get_process_capeff(ucred->pid, &t);
if (r >= 0) {
- x = strappenda("_CAP_EFFECTIVE=", t);
+ x = strjoina("_CAP_EFFECTIVE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
@@ -633,12 +633,12 @@ static void dispatch_message_real(
if (r >= 0) {
char *session = NULL;
- x = strappenda("_SYSTEMD_CGROUP=", c);
+ x = strjoina("_SYSTEMD_CGROUP=", c);
IOVEC_SET_STRING(iovec[n++], x);
r = cg_path_get_session(c, &t);
if (r >= 0) {
- session = strappenda("_SYSTEMD_SESSION=", t);
+ session = strjoina("_SYSTEMD_SESSION=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], session);
}
@@ -651,32 +651,32 @@ static void dispatch_message_real(
}
if (cg_path_get_unit(c, &t) >= 0) {
- x = strappenda("_SYSTEMD_UNIT=", t);
+ x = strjoina("_SYSTEMD_UNIT=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
} else if (unit_id && !session) {
- x = strappenda("_SYSTEMD_UNIT=", unit_id);
+ x = strjoina("_SYSTEMD_UNIT=", unit_id);
IOVEC_SET_STRING(iovec[n++], x);
}
if (cg_path_get_user_unit(c, &t) >= 0) {
- x = strappenda("_SYSTEMD_USER_UNIT=", t);
+ x = strjoina("_SYSTEMD_USER_UNIT=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
} else if (unit_id && session) {
- x = strappenda("_SYSTEMD_USER_UNIT=", unit_id);
+ x = strjoina("_SYSTEMD_USER_UNIT=", unit_id);
IOVEC_SET_STRING(iovec[n++], x);
}
if (cg_path_get_slice(c, &t) >= 0) {
- x = strappenda("_SYSTEMD_SLICE=", t);
+ x = strjoina("_SYSTEMD_SLICE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
free(c);
} else if (unit_id) {
- x = strappenda("_SYSTEMD_UNIT=", unit_id);
+ x = strjoina("_SYSTEMD_UNIT=", unit_id);
IOVEC_SET_STRING(iovec[n++], x);
}
@@ -691,7 +691,7 @@ static void dispatch_message_real(
security_context_t con;
if (getpidcon(ucred->pid, &con) >= 0) {
- x = strappenda("_SELINUX_CONTEXT=", con);
+ x = strjoina("_SELINUX_CONTEXT=", con);
freecon(con);
IOVEC_SET_STRING(iovec[n++], x);
@@ -717,21 +717,21 @@ static void dispatch_message_real(
r = get_process_comm(object_pid, &t);
if (r >= 0) {
- x = strappenda("OBJECT_COMM=", t);
+ x = strjoina("OBJECT_COMM=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
r = get_process_exe(object_pid, &t);
if (r >= 0) {
- x = strappenda("OBJECT_EXE=", t);
+ x = strjoina("OBJECT_EXE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
r = get_process_cmdline(object_pid, 0, false, &t);
if (r >= 0) {
- x = strappenda("OBJECT_CMDLINE=", t);
+ x = strjoina("OBJECT_CMDLINE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
@@ -752,12 +752,12 @@ static void dispatch_message_real(
r = cg_pid_get_path_shifted(object_pid, s->cgroup_root, &c);
if (r >= 0) {
- x = strappenda("OBJECT_SYSTEMD_CGROUP=", c);
+ x = strjoina("OBJECT_SYSTEMD_CGROUP=", c);
IOVEC_SET_STRING(iovec[n++], x);
r = cg_path_get_session(c, &t);
if (r >= 0) {
- x = strappenda("OBJECT_SYSTEMD_SESSION=", t);
+ x = strjoina("OBJECT_SYSTEMD_SESSION=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
@@ -768,13 +768,13 @@ static void dispatch_message_real(
}
if (cg_path_get_unit(c, &t) >= 0) {
- x = strappenda("OBJECT_SYSTEMD_UNIT=", t);
+ x = strjoina("OBJECT_SYSTEMD_UNIT=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
if (cg_path_get_user_unit(c, &t) >= 0) {
- x = strappenda("OBJECT_SYSTEMD_USER_UNIT=", t);
+ x = strjoina("OBJECT_SYSTEMD_USER_UNIT=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
@@ -944,10 +944,10 @@ static int system_journal_open(Server *s, bool flush_requested) {
if (s->storage == STORAGE_PERSISTENT)
(void) mkdir("/var/log/journal/", 0755);
- fn = strappenda("/var/log/journal/", ids);
+ fn = strjoina("/var/log/journal/", ids);
(void) mkdir(fn, 0755);
- fn = strappenda(fn, "/system.journal");
+ fn = strjoina(fn, "/system.journal");
r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, NULL, &s->system_journal);
if (r >= 0)
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
index ba6e3316d6..355f6e6a4b 100644
--- a/src/journal/journald-syslog.c
+++ b/src/journal/journald-syslog.c
@@ -356,18 +356,18 @@ void server_process_syslog_message(
}
if (identifier) {
- syslog_identifier = strappenda("SYSLOG_IDENTIFIER=", identifier);
+ syslog_identifier = strjoina("SYSLOG_IDENTIFIER=", identifier);
if (syslog_identifier)
IOVEC_SET_STRING(iovec[n++], syslog_identifier);
}
if (pid) {
- syslog_pid = strappenda("SYSLOG_PID=", pid);
+ syslog_pid = strjoina("SYSLOG_PID=", pid);
if (syslog_pid)
IOVEC_SET_STRING(iovec[n++], syslog_pid);
}
- message = strappenda("MESSAGE=", buf);
+ message = strjoina("MESSAGE=", buf);
if (message)
IOVEC_SET_STRING(iovec[n++], message);
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 9dea5470be..ecf47fda3d 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1155,9 +1155,9 @@ static void check_network(sd_journal *j, int fd) {
static bool file_has_type_prefix(const char *prefix, const char *filename) {
const char *full, *tilded, *atted;
- full = strappenda(prefix, ".journal");
- tilded = strappenda(full, "~");
- atted = strappenda(prefix, "@");
+ full = strjoina(prefix, ".journal");
+ tilded = strjoina(full, "~");
+ atted = strjoina(prefix, "@");
return streq(filename, full) ||
streq(filename, tilded) ||
@@ -1399,7 +1399,7 @@ static int add_root_directory(sd_journal *j, const char *p) {
return -EINVAL;
if (j->prefix)
- p = strappenda(j->prefix, p);
+ p = strjoina(j->prefix, p);
d = opendir(p);
if (!d)
@@ -1643,7 +1643,7 @@ _public_ int sd_journal_open_container(sd_journal **ret, const char *machine, in
assert_return((flags & ~(SD_JOURNAL_LOCAL_ONLY|SD_JOURNAL_SYSTEM)) == 0, -EINVAL);
assert_return(machine_name_is_valid(machine), -EINVAL);
- p = strappenda("/run/systemd/machines/", machine);
+ p = strjoina("/run/systemd/machines/", machine);
r = parse_env_file(p, NEWLINE, "ROOT", &root, "CLASS", &class, NULL);
if (r == -ENOENT)
return -EHOSTDOWN;