X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fjournal%2Fjournal-def.h;h=7e407a416cb1ca1674202c1162cddcc745d91d46;hp=5f026ee0f643037300003a63ab1b056e0fb90060;hb=244692cbfb46df5ff79d07da8fb848a1165bd2fb;hpb=bc85bfee87e11317fbcd1160c9003860dc6edde9 diff --git a/src/journal/journal-def.h b/src/journal/journal-def.h index 5f026ee0f..7e407a416 100644 --- a/src/journal/journal-def.h +++ b/src/journal/journal-def.h @@ -1,7 +1,6 @@ /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ -#ifndef foojournaldefhfoo -#define foojournaldefhfoo +#pragma once /*** This file is part of systemd. @@ -9,35 +8,49 @@ Copyright 2011 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ -#include +#include "sparse-endian.h" + +#include #include "macro.h" -#include "sd-id128.h" + +/* + * If you change this file you probably should also change its documentation: + * + * http://www.freedesktop.org/wiki/Software/systemd/journal-files + * + */ typedef struct Header Header; + typedef struct ObjectHeader ObjectHeader; typedef union Object Object; + typedef struct DataObject DataObject; typedef struct FieldObject FieldObject; typedef struct EntryObject EntryObject; typedef struct HashTableObject HashTableObject; typedef struct EntryArrayObject EntryArrayObject; +typedef struct TagObject TagObject; + typedef struct EntryItem EntryItem; typedef struct HashItem HashItem; +typedef struct FSSHeader FSSHeader; + /* Object types */ enum { OBJECT_UNUSED, @@ -47,66 +60,81 @@ enum { OBJECT_DATA_HASH_TABLE, OBJECT_FIELD_HASH_TABLE, OBJECT_ENTRY_ARRAY, + OBJECT_TAG, _OBJECT_TYPE_MAX }; -_packed_ struct ObjectHeader { +/* Object flags */ +enum { + OBJECT_COMPRESSED = 1 +}; + +struct ObjectHeader { uint8_t type; - uint8_t reserved[7]; - uint64_t size; + uint8_t flags; + uint8_t reserved[6]; + le64_t size; uint8_t payload[]; -}; +} _packed_; -_packed_ struct DataObject { +struct DataObject { ObjectHeader object; - uint64_t hash; - uint64_t next_hash_offset; - uint64_t next_field_offset; - uint64_t entry_offset; /* the first array entry we store inline */ - uint64_t entry_array_offset; - uint64_t n_entries; + le64_t hash; + le64_t next_hash_offset; + le64_t next_field_offset; + le64_t entry_offset; /* the first array entry we store inline */ + le64_t entry_array_offset; + le64_t n_entries; uint8_t payload[]; -}; +} _packed_; -_packed_ struct FieldObject { +struct FieldObject { ObjectHeader object; - uint64_t hash; - uint64_t next_hash_offset; - uint64_t head_data_offset; - uint64_t tail_data_offset; + le64_t hash; + le64_t next_hash_offset; + le64_t head_data_offset; uint8_t payload[]; -}; +} _packed_; -_packed_ struct EntryItem { - uint64_t object_offset; - uint64_t hash; -}; +struct EntryItem { + le64_t object_offset; + le64_t hash; +} _packed_; -_packed_ struct EntryObject { +struct EntryObject { ObjectHeader object; - uint64_t seqnum; - uint64_t realtime; - uint64_t monotonic; + le64_t seqnum; + le64_t realtime; + le64_t monotonic; sd_id128_t boot_id; - uint64_t xor_hash; + le64_t xor_hash; EntryItem items[]; -}; +} _packed_; -_packed_ struct HashItem { - uint64_t head_hash_offset; - uint64_t tail_hash_offset; -}; +struct HashItem { + le64_t head_hash_offset; + le64_t tail_hash_offset; +} _packed_; -_packed_ struct HashTableObject { +struct HashTableObject { ObjectHeader object; HashItem items[]; -}; +} _packed_; -_packed_ struct EntryArrayObject { +struct EntryArrayObject { ObjectHeader object; - uint64_t next_entry_array_offset; - uint64_t items[]; -}; + le64_t next_entry_array_offset; + le64_t items[]; +} _packed_; + +#define TAG_LENGTH (256/8) + +struct TagObject { + ObjectHeader object; + le64_t seqnum; + le64_t epoch; + uint8_t tag[TAG_LENGTH]; /* SHA-256 HMAC */ +} _packed_; union Object { ObjectHeader object; @@ -115,39 +143,74 @@ union Object { EntryObject entry; HashTableObject hash_table; EntryArrayObject entry_array; + TagObject tag; +}; + +enum { + STATE_OFFLINE = 0, + STATE_ONLINE = 1, + STATE_ARCHIVED = 2, + _STATE_MAX }; +/* Header flags */ enum { - STATE_OFFLINE, - STATE_ONLINE, - STATE_ARCHIVED + HEADER_INCOMPATIBLE_COMPRESSED = 1 }; -_packed_ struct Header { +enum { + HEADER_COMPATIBLE_SEALED = 1 +}; + +#define HEADER_SIGNATURE ((char[]) { 'L', 'P', 'K', 'S', 'H', 'H', 'R', 'H' }) + +struct Header { uint8_t signature[8]; /* "LPKSHHRH" */ - uint32_t compatible_flags; - uint32_t incompatible_flags; + le32_t compatible_flags; + le32_t incompatible_flags; uint8_t state; uint8_t reserved[7]; sd_id128_t file_id; sd_id128_t machine_id; - sd_id128_t boot_id; + sd_id128_t boot_id; /* last writer */ sd_id128_t seqnum_id; - uint64_t arena_offset; - uint64_t arena_size; - uint64_t data_hash_table_offset; /* for looking up data objects */ - uint64_t data_hash_table_size; - uint64_t field_hash_table_offset; /* for looking up field objects */ - uint64_t field_hash_table_size; - uint64_t tail_object_offset; - uint64_t n_objects; - uint64_t n_entries; - uint64_t seqnum; - uint64_t first_seqnum; - uint64_t entry_array_offset; - uint64_t head_entry_realtime; - uint64_t tail_entry_realtime; - uint64_t tail_entry_monotonic; -}; - -#endif + le64_t header_size; + le64_t arena_size; + le64_t data_hash_table_offset; + le64_t data_hash_table_size; + le64_t field_hash_table_offset; + le64_t field_hash_table_size; + le64_t tail_object_offset; + le64_t n_objects; + le64_t n_entries; + le64_t tail_entry_seqnum; + le64_t head_entry_seqnum; + le64_t entry_array_offset; + le64_t head_entry_realtime; + le64_t tail_entry_realtime; + le64_t tail_entry_monotonic; + /* Added in 187 */ + le64_t n_data; + le64_t n_fields; + /* Added in 189 */ + le64_t n_tags; + le64_t n_entry_arrays; + + /* Size: 224 */ +} _packed_; + +#define FSS_HEADER_SIGNATURE ((char[]) { 'K', 'S', 'H', 'H', 'R', 'H', 'L', 'P' }) + +struct FSSHeader { + uint8_t signature[8]; /* "KSHHRHLP" */ + le32_t compatible_flags; + le32_t incompatible_flags; + sd_id128_t machine_id; + sd_id128_t boot_id; /* last writer */ + le64_t header_size; + le64_t start_usec; + le64_t interval_usec; + le16_t fsprg_secpar; + le16_t reserved[3]; + le64_t fsprg_state_size; +} _packed_;