journal-send.c revision a09abc4ae0bdc0200324eaa0416f23ff2170ec4e
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen This file is part of systemd.
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen Copyright 2011 Lennart Poettering
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen systemd is free software; you can redistribute it and/or modify it
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen under the terms of the GNU Lesser General Public License as published by
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen the Free Software Foundation; either version 2.1 of the License, or
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen (at your option) any later version.
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen systemd is distributed in the hope that it will be useful, but
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen Lesser General Public License for more details.
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen You should have received a copy of the GNU Lesser General Public License
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
85a8eeee36b57c1ab382b0225fa9a87525bbeee9Susant Sahani char **_f = &(f); \
85a8eeee36b57c1ab382b0225fa9a87525bbeee9Susant Sahani } while(false)
cffacc741cb79f63999720525ceaa65aae01a542Susant Sahani/* We open a single fd, and we'll share it with the current process,
cffacc741cb79f63999720525ceaa65aae01a542Susant Sahani * all its threads, and all its subprocesses. This means we need to
cffacc741cb79f63999720525ceaa65aae01a542Susant Sahani * initialize it atomically, and need to operate on it atomically
aa9f11405829fd4755fef28602a7167dba3ddc89Tom Gundersen * never assuming we are the only user */
3be1d7e0c5bf60658d34eb6311d4e77c6803578cTom Gundersenstatic int journal_fd(void) {
a94d64d256d1a2b73c578116f341824eb5d0fab1Susant Sahani static int fd_plus_one = 0;
a94d64d256d1a2b73c578116f341824eb5d0fab1Susant Sahani fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
goto retry;
return fd;
char_array_0(p);
_printf_(1, 0) static int fill_iovec_sprintf(const char *format, va_list ap, int extra, struct iovec **_iov) {
if (extra > 0) {
if (!iov) {
r = -ENOMEM;
goto fail;
i = extra;
while (format) {
struct iovec *c;
char *buffer;
r = -ENOMEM;
goto fail;
iov = c;
r = -ENOMEM;
goto fail;
fail:
if (_unlikely_(i < 0)) {
goto finish;
int fd, r;
struct iovec *w;
uint64_t *l;
ssize_t k;
} control;
bool have_syslog_identifier = false;
bool seal = true;
char *c, *nl;
return -EINVAL;
return -EINVAL;
if (nl) {
return -EINVAL;
w[j].iov_base = &l[i];
w[j++] = iov[i];
if (!have_syslog_identifier &&
return fd;
return -errno;
if (buffer_fd < 0) {
if (buffer_fd < 0)
return buffer_fd;
seal = false;
return buffer_fd;
return -errno;
if (seal) {
return -errno;
size_t n, k;
char buffer[n];
errno = 0;
if (errno == 0) {
return -errno;
char *header;
size_t l;
if (fd < 0)
return -errno;
return -errno;
return -errno;
if (!identifier)
if ((size_t) r != l)
return -errno;
r = fd;
_public_ int sd_journal_print_with_location(int priority, const char *file, const char *line, const char *func, const char *format, ...) {
_public_ int sd_journal_printv_with_location(int priority, const char *file, const char *line, const char *func, const char *format, va_list ap) {
char_array_0(p);
_public_ int sd_journal_send_with_location(const char *file, const char *line, const char *func, const char *format, ...) {
if (_unlikely_(i < 0)) {
goto finish;
const char *func,
const char *func,
const char *message) {