journal-remote-write.h revision 92b10cbccdeef3896f45dc340eb7779c78577ede
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering/***
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering This file is part of systemd.
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering Copyright 2014 Zbigniew Jędrzejewski-Szmek
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering systemd is free software; you can redistribute it and/or modify it
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering under the terms of the GNU Lesser General Public License as published by
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering (at your option) any later version.
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering systemd is distributed in the hope that it will be useful, but
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering Lesser General Public License for more details.
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering You should have received a copy of the GNU Lesser General Public License
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering***/
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog#pragma once
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering#include <stdlib.h>
4871690d9e32608bbd9b18505b5326c2079c9690Allin Cottrell
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering#include "journal-file.h"
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmektypedef struct RemoteServer RemoteServer;
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poetteringstruct iovec_wrapper {
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog struct iovec *iovec;
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog size_t size_bytes;
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog size_t count;
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog};
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogint iovw_put(struct iovec_wrapper *iovw, void* data, size_t len);
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogvoid iovw_free_contents(struct iovec_wrapper *iovw);
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogsize_t iovw_size(struct iovec_wrapper *iovw);
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogvoid iovw_rebase(struct iovec_wrapper *iovw, char *old, char *new);
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogtypedef struct Writer {
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog JournalFile *journal;
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog JournalMetrics metrics;
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog MMapCache *mmap;
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering RemoteServer *server;
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering char *hashmap_key;
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering uint64_t seqnum;
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering int n_ref;
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering} Writer;
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart PoetteringWriter* writer_new(RemoteServer* server);
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar LindskogWriter* writer_free(Writer *w);
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart PoetteringWriter* writer_ref(Writer *w);
fb4729006a7174472e8a435b0887e532cd6217fcZbigniew Jędrzejewski-SzmekWriter* writer_unref(Writer *w);
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart PoetteringDEFINE_TRIVIAL_CLEANUP_FUNC(Writer*, writer_unref);
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering#define _cleanup_writer_unref_ _cleanup_(writer_unrefp)
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poetteringint writer_write(Writer *s,
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering struct iovec_wrapper *iovw,
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering dual_timestamp *ts,
3b7124a8db56ed57525b9ecfd19cfdc8c9facba0Lennart Poettering bool compress,
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog bool seal);
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskogtypedef enum JournalWriteSplitMode {
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog JOURNAL_WRITE_SPLIT_NONE,
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog JOURNAL_WRITE_SPLIT_HOST,
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog _JOURNAL_WRITE_SPLIT_MAX,
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog _JOURNAL_WRITE_SPLIT_INVALID = -1
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog} JournalWriteSplitMode;
ad79565d6b37bcc93cf773a39b975e5b85d122daUmut Tezduyar Lindskog