674eb68520107d771e3458287025a73387f938c4Lennart Poettering/***
674eb68520107d771e3458287025a73387f938c4Lennart Poettering This file is part of systemd.
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart Poettering Copyright 2014 Zbigniew Jędrzejewski-Szmek
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart Poettering systemd is free software; you can redistribute it and/or modify it
674eb68520107d771e3458287025a73387f938c4Lennart Poettering under the terms of the GNU Lesser General Public License as published by
674eb68520107d771e3458287025a73387f938c4Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
674eb68520107d771e3458287025a73387f938c4Lennart Poettering (at your option) any later version.
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart Poettering systemd is distributed in the hope that it will be useful, but
674eb68520107d771e3458287025a73387f938c4Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
674eb68520107d771e3458287025a73387f938c4Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
674eb68520107d771e3458287025a73387f938c4Lennart Poettering Lesser General Public License for more details.
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart Poettering You should have received a copy of the GNU Lesser General Public License
674eb68520107d771e3458287025a73387f938c4Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
674eb68520107d771e3458287025a73387f938c4Lennart Poettering***/
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
b5efdb8af40ea759a1ea584c1bc44ecc81dd00ceLennart Poettering#pragma once
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering#include "journal-file.h"
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
a09561746f15b84da9471b5c4be74e53d19e4f3fLennart Poetteringtypedef struct RemoteServer RemoteServer;
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering
0d39fa9c69b97a2ceb156053deef69c0866c2b97Lennart Poetteringstruct iovec_wrapper {
674eb68520107d771e3458287025a73387f938c4Lennart Poettering struct iovec *iovec;
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering size_t size_bytes;
674eb68520107d771e3458287025a73387f938c4Lennart Poettering size_t count;
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering};
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
7c9a6f906308a6474f1ebb98058c4a33a02c33f1Lennart Poetteringint iovw_put(struct iovec_wrapper *iovw, void* data, size_t len);
674eb68520107d771e3458287025a73387f938c4Lennart Poetteringvoid iovw_free_contents(struct iovec_wrapper *iovw);
674eb68520107d771e3458287025a73387f938c4Lennart Poetteringsize_t iovw_size(struct iovec_wrapper *iovw);
674eb68520107d771e3458287025a73387f938c4Lennart Poetteringvoid iovw_rebase(struct iovec_wrapper *iovw, char *old, char *new);
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart Poetteringtypedef struct Writer {
674eb68520107d771e3458287025a73387f938c4Lennart Poettering JournalFile *journal;
674eb68520107d771e3458287025a73387f938c4Lennart Poettering JournalMetrics metrics;
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart Poettering MMapCache *mmap;
674eb68520107d771e3458287025a73387f938c4Lennart Poettering RemoteServer *server;
674eb68520107d771e3458287025a73387f938c4Lennart Poettering char *hashmap_key;
0975b63fb31263e535a2d26ed41e66e23f468bc5Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart Poettering uint64_t seqnum;
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart Poettering int n_ref;
5c817d31d9d239421cf9b01a9c06b90f50b18d75Lennart Poettering} Writer;
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart PoetteringWriter* writer_new(RemoteServer* server);
674eb68520107d771e3458287025a73387f938c4Lennart PoetteringWriter* writer_free(Writer *w);
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart PoetteringWriter* writer_ref(Writer *w);
674eb68520107d771e3458287025a73387f938c4Lennart PoetteringWriter* writer_unref(Writer *w);
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart PoetteringDEFINE_TRIVIAL_CLEANUP_FUNC(Writer*, writer_unref);
7c9a6f906308a6474f1ebb98058c4a33a02c33f1Lennart Poettering#define _cleanup_writer_unref_ _cleanup_(writer_unrefp)
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart Poetteringint writer_write(Writer *s,
674eb68520107d771e3458287025a73387f938c4Lennart Poettering struct iovec_wrapper *iovw,
674eb68520107d771e3458287025a73387f938c4Lennart Poettering dual_timestamp *ts,
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt bool compress,
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidt bool seal);
674eb68520107d771e3458287025a73387f938c4Lennart Poettering
674eb68520107d771e3458287025a73387f938c4Lennart Poetteringtypedef enum JournalWriteSplitMode {
674eb68520107d771e3458287025a73387f938c4Lennart Poettering JOURNAL_WRITE_SPLIT_NONE,
674eb68520107d771e3458287025a73387f938c4Lennart Poettering JOURNAL_WRITE_SPLIT_HOST,
5c817d31d9d239421cf9b01a9c06b90f50b18d75Lennart Poettering _JOURNAL_WRITE_SPLIT_MAX,
c3834f9b881f2b1a68dc7d797c134f0b66b47b57Lennart Poettering _JOURNAL_WRITE_SPLIT_INVALID = -1
c3834f9b881f2b1a68dc7d797c134f0b66b47b57Lennart Poettering} JournalWriteSplitMode;
674eb68520107d771e3458287025a73387f938c4Lennart Poettering