2011-10-07 21:06:39 +02:00
|
|
|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
|
|
|
|
2012-07-18 19:07:51 +02:00
|
|
|
#pragma once
|
2011-10-07 21:06:39 +02:00
|
|
|
|
|
|
|
/***
|
|
|
|
This file is part of systemd.
|
|
|
|
|
|
|
|
Copyright 2011 Lennart Poettering
|
|
|
|
|
|
|
|
systemd is free software; you can redistribute it and/or modify it
|
2012-04-12 00:20:58 +02:00
|
|
|
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
|
2011-10-07 21:06:39 +02:00
|
|
|
(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
|
2012-04-12 00:20:58 +02:00
|
|
|
Lesser General Public License for more details.
|
2011-10-07 21:06:39 +02:00
|
|
|
|
2012-04-12 00:20:58 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2011-10-07 21:06:39 +02:00
|
|
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
***/
|
|
|
|
|
2012-03-16 11:59:04 +01:00
|
|
|
#include "sparse-endian.h"
|
2011-10-07 21:06:39 +02:00
|
|
|
|
2012-01-05 16:01:58 +01:00
|
|
|
#include <systemd/sd-id128.h>
|
|
|
|
|
2011-10-07 21:06:39 +02:00
|
|
|
#include "macro.h"
|
|
|
|
|
2012-10-20 17:00:57 +02:00
|
|
|
/*
|
|
|
|
* If you change this file you probably should also change its documentation:
|
|
|
|
*
|
|
|
|
* http://www.freedesktop.org/wiki/Software/systemd/journal-files
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-10-07 21:06:39 +02:00
|
|
|
typedef struct Header Header;
|
2012-06-05 20:45:54 +02:00
|
|
|
|
2011-10-07 21:06:39 +02:00
|
|
|
typedef struct ObjectHeader ObjectHeader;
|
|
|
|
typedef union Object Object;
|
2012-06-05 20:45:54 +02:00
|
|
|
|
2011-10-07 21:06:39 +02:00
|
|
|
typedef struct DataObject DataObject;
|
2011-11-08 18:20:03 +01:00
|
|
|
typedef struct FieldObject FieldObject;
|
2011-10-07 21:06:39 +02:00
|
|
|
typedef struct EntryObject EntryObject;
|
|
|
|
typedef struct HashTableObject HashTableObject;
|
2011-11-08 18:20:03 +01:00
|
|
|
typedef struct EntryArrayObject EntryArrayObject;
|
2012-08-13 20:31:10 +02:00
|
|
|
typedef struct TagObject TagObject;
|
2012-06-05 20:45:54 +02:00
|
|
|
|
2011-10-07 21:06:39 +02:00
|
|
|
typedef struct EntryItem EntryItem;
|
|
|
|
typedef struct HashItem HashItem;
|
|
|
|
|
2012-08-17 00:45:18 +02:00
|
|
|
typedef struct FSSHeader FSSHeader;
|
2012-08-13 20:31:10 +02:00
|
|
|
|
2011-10-07 21:06:39 +02:00
|
|
|
/* Object types */
|
|
|
|
enum {
|
|
|
|
OBJECT_UNUSED,
|
2012-10-20 17:00:57 +02:00
|
|
|
OBJECT_DATA,
|
2011-11-08 18:20:03 +01:00
|
|
|
OBJECT_FIELD,
|
2011-10-07 21:06:39 +02:00
|
|
|
OBJECT_ENTRY,
|
2011-11-08 18:20:03 +01:00
|
|
|
OBJECT_DATA_HASH_TABLE,
|
|
|
|
OBJECT_FIELD_HASH_TABLE,
|
2012-10-20 17:00:57 +02:00
|
|
|
OBJECT_ENTRY_ARRAY,
|
2012-08-13 20:31:10 +02:00
|
|
|
OBJECT_TAG,
|
2011-11-08 18:20:03 +01:00
|
|
|
_OBJECT_TYPE_MAX
|
2011-10-07 21:06:39 +02:00
|
|
|
};
|
|
|
|
|
2011-12-21 02:40:59 +01:00
|
|
|
/* Object flags */
|
|
|
|
enum {
|
|
|
|
OBJECT_COMPRESSED = 1
|
|
|
|
};
|
|
|
|
|
2012-12-17 11:38:47 +01:00
|
|
|
struct ObjectHeader {
|
2011-10-07 21:06:39 +02:00
|
|
|
uint8_t type;
|
2011-12-21 02:40:59 +01:00
|
|
|
uint8_t flags;
|
|
|
|
uint8_t reserved[6];
|
2012-03-16 11:59:04 +01:00
|
|
|
le64_t size;
|
2011-10-07 21:06:39 +02:00
|
|
|
uint8_t payload[];
|
2012-12-17 11:38:47 +01:00
|
|
|
} _packed_;
|
2011-10-07 21:06:39 +02:00
|
|
|
|
2012-12-17 11:38:47 +01:00
|
|
|
struct DataObject {
|
2011-10-07 21:06:39 +02:00
|
|
|
ObjectHeader object;
|
2012-03-16 11:59:04 +01:00
|
|
|
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;
|
2011-11-08 18:20:03 +01:00
|
|
|
uint8_t payload[];
|
2012-12-17 11:38:47 +01:00
|
|
|
} _packed_;
|
2011-11-08 18:20:03 +01:00
|
|
|
|
2012-12-17 11:38:47 +01:00
|
|
|
struct FieldObject {
|
2011-11-08 18:20:03 +01:00
|
|
|
ObjectHeader object;
|
2012-03-16 11:59:04 +01:00
|
|
|
le64_t hash;
|
|
|
|
le64_t next_hash_offset;
|
|
|
|
le64_t head_data_offset;
|
2011-10-07 21:06:39 +02:00
|
|
|
uint8_t payload[];
|
2012-12-17 11:38:47 +01:00
|
|
|
} _packed_;
|
2011-10-07 21:06:39 +02:00
|
|
|
|
2012-12-17 11:38:47 +01:00
|
|
|
struct EntryItem {
|
2012-03-16 11:59:04 +01:00
|
|
|
le64_t object_offset;
|
|
|
|
le64_t hash;
|
2012-12-17 11:38:47 +01:00
|
|
|
} _packed_;
|
2011-10-07 21:06:39 +02:00
|
|
|
|
2012-12-17 11:38:47 +01:00
|
|
|
struct EntryObject {
|
2011-10-07 21:06:39 +02:00
|
|
|
ObjectHeader object;
|
2012-03-16 11:59:04 +01:00
|
|
|
le64_t seqnum;
|
|
|
|
le64_t realtime;
|
|
|
|
le64_t monotonic;
|
2011-10-08 02:20:44 +02:00
|
|
|
sd_id128_t boot_id;
|
2012-03-16 11:59:04 +01:00
|
|
|
le64_t xor_hash;
|
2011-10-07 21:06:39 +02:00
|
|
|
EntryItem items[];
|
2012-12-17 11:38:47 +01:00
|
|
|
} _packed_;
|
2011-10-07 21:06:39 +02:00
|
|
|
|
2012-12-17 11:38:47 +01:00
|
|
|
struct HashItem {
|
2012-03-16 11:59:04 +01:00
|
|
|
le64_t head_hash_offset;
|
|
|
|
le64_t tail_hash_offset;
|
2012-12-17 11:38:47 +01:00
|
|
|
} _packed_;
|
2011-10-07 21:06:39 +02:00
|
|
|
|
2012-12-17 11:38:47 +01:00
|
|
|
struct HashTableObject {
|
2011-10-07 21:06:39 +02:00
|
|
|
ObjectHeader object;
|
2011-11-08 18:20:03 +01:00
|
|
|
HashItem items[];
|
2012-12-17 11:38:47 +01:00
|
|
|
} _packed_;
|
2011-10-07 21:06:39 +02:00
|
|
|
|
2012-12-17 11:38:47 +01:00
|
|
|
struct EntryArrayObject {
|
2011-10-07 21:06:39 +02:00
|
|
|
ObjectHeader object;
|
2012-03-16 11:59:04 +01:00
|
|
|
le64_t next_entry_array_offset;
|
|
|
|
le64_t items[];
|
2012-12-17 11:38:47 +01:00
|
|
|
} _packed_;
|
2011-10-07 21:06:39 +02:00
|
|
|
|
2012-08-13 20:31:10 +02:00
|
|
|
#define TAG_LENGTH (256/8)
|
2012-06-05 20:45:54 +02:00
|
|
|
|
2012-12-17 11:38:47 +01:00
|
|
|
struct TagObject {
|
2012-06-05 20:45:54 +02:00
|
|
|
ObjectHeader object;
|
2012-10-20 17:10:32 +02:00
|
|
|
le64_t seqnum;
|
|
|
|
le64_t epoch;
|
2012-08-13 20:31:10 +02:00
|
|
|
uint8_t tag[TAG_LENGTH]; /* SHA-256 HMAC */
|
2012-12-17 11:38:47 +01:00
|
|
|
} _packed_;
|
2012-06-05 20:45:54 +02:00
|
|
|
|
2011-10-07 21:06:39 +02:00
|
|
|
union Object {
|
|
|
|
ObjectHeader object;
|
|
|
|
DataObject data;
|
2011-11-08 18:20:03 +01:00
|
|
|
FieldObject field;
|
2011-10-07 21:06:39 +02:00
|
|
|
EntryObject entry;
|
|
|
|
HashTableObject hash_table;
|
2011-11-08 18:20:03 +01:00
|
|
|
EntryArrayObject entry_array;
|
2012-08-13 20:31:10 +02:00
|
|
|
TagObject tag;
|
2011-10-07 21:06:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2012-08-18 00:37:21 +02:00
|
|
|
STATE_OFFLINE = 0,
|
|
|
|
STATE_ONLINE = 1,
|
|
|
|
STATE_ARCHIVED = 2,
|
|
|
|
_STATE_MAX
|
2011-10-07 21:06:39 +02:00
|
|
|
};
|
|
|
|
|
2011-12-21 02:40:59 +01:00
|
|
|
/* Header flags */
|
|
|
|
enum {
|
|
|
|
HEADER_INCOMPATIBLE_COMPRESSED = 1
|
|
|
|
};
|
|
|
|
|
2012-06-05 20:45:54 +02:00
|
|
|
enum {
|
2012-08-17 00:45:18 +02:00
|
|
|
HEADER_COMPATIBLE_SEALED = 1
|
2012-06-05 20:45:54 +02:00
|
|
|
};
|
|
|
|
|
2012-08-13 20:31:10 +02:00
|
|
|
#define HEADER_SIGNATURE ((char[]) { 'L', 'P', 'K', 'S', 'H', 'H', 'R', 'H' })
|
|
|
|
|
2012-12-17 11:38:47 +01:00
|
|
|
struct Header {
|
2011-10-07 21:06:39 +02:00
|
|
|
uint8_t signature[8]; /* "LPKSHHRH" */
|
2012-08-13 20:31:10 +02:00
|
|
|
le32_t compatible_flags;
|
|
|
|
le32_t incompatible_flags;
|
2011-11-08 18:20:03 +01:00
|
|
|
uint8_t state;
|
|
|
|
uint8_t reserved[7];
|
2011-10-07 21:06:39 +02:00
|
|
|
sd_id128_t file_id;
|
2012-08-13 20:31:10 +02:00
|
|
|
sd_id128_t machine_id;
|
2012-06-09 10:32:38 +02:00
|
|
|
sd_id128_t boot_id; /* last writer */
|
2011-10-08 02:20:44 +02:00
|
|
|
sd_id128_t seqnum_id;
|
2012-06-05 20:32:55 +02:00
|
|
|
le64_t header_size;
|
2012-03-16 11:59:04 +01:00
|
|
|
le64_t arena_size;
|
2012-10-20 17:00:57 +02:00
|
|
|
le64_t data_hash_table_offset;
|
2012-03-16 11:59:04 +01:00
|
|
|
le64_t data_hash_table_size;
|
2012-10-20 17:00:57 +02:00
|
|
|
le64_t field_hash_table_offset;
|
2012-03-16 11:59:04 +01:00
|
|
|
le64_t field_hash_table_size;
|
|
|
|
le64_t tail_object_offset;
|
|
|
|
le64_t n_objects;
|
|
|
|
le64_t n_entries;
|
2012-08-15 01:54:09 +02:00
|
|
|
le64_t tail_entry_seqnum;
|
|
|
|
le64_t head_entry_seqnum;
|
2012-03-16 11:59:04 +01:00
|
|
|
le64_t entry_array_offset;
|
|
|
|
le64_t head_entry_realtime;
|
|
|
|
le64_t tail_entry_realtime;
|
|
|
|
le64_t tail_entry_monotonic;
|
2012-07-16 22:24:02 +02:00
|
|
|
/* Added in 187 */
|
|
|
|
le64_t n_data;
|
|
|
|
le64_t n_fields;
|
2012-08-13 21:52:58 +02:00
|
|
|
/* Added in 189 */
|
|
|
|
le64_t n_tags;
|
2012-08-16 20:51:24 +02:00
|
|
|
le64_t n_entry_arrays;
|
2012-08-18 01:45:39 +02:00
|
|
|
|
|
|
|
/* Size: 224 */
|
2012-12-17 11:38:47 +01:00
|
|
|
} _packed_;
|
2012-08-13 20:31:10 +02:00
|
|
|
|
2012-08-17 00:45:18 +02:00
|
|
|
#define FSS_HEADER_SIGNATURE ((char[]) { 'K', 'S', 'H', 'H', 'R', 'H', 'L', 'P' })
|
2012-08-13 20:31:10 +02:00
|
|
|
|
2012-12-17 11:38:47 +01:00
|
|
|
struct FSSHeader {
|
2012-08-13 20:31:10 +02:00
|
|
|
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;
|
2012-08-17 00:45:18 +02:00
|
|
|
le64_t start_usec;
|
|
|
|
le64_t interval_usec;
|
|
|
|
le16_t fsprg_secpar;
|
2012-08-13 20:31:10 +02:00
|
|
|
le16_t reserved[3];
|
2012-08-17 00:45:18 +02:00
|
|
|
le64_t fsprg_state_size;
|
2012-12-17 11:38:47 +01:00
|
|
|
} _packed_;
|