~ubuntu-branches/debian/jessie/systemd/jessie

« back to all changes in this revision

Viewing changes to src/journal/journal-file.h

  • Committer: Package Import Robot
  • Author(s): Tollef Fog Heen, Tollef Fog Heen, Michael Biebl
  • Date: 2012-04-03 19:59:17 UTC
  • mfrom: (1.1.10) (6.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20120403195917-l532urrbg4pkreas
Tags: 44-1
[ Tollef Fog Heen ]
* New upstream version.
  - Backport 3492207: journal: PAGE_SIZE is not known on ppc and other
    archs
  - Backport 5a2a2a1: journal: react with immediate rotation to a couple
    of more errors
  - Backport 693ce21: util: never follow symlinks in rm_rf_children()
    Fixes CVE-2012-1174, closes: #664364
* Drop output message from init-functions hook, it's pointless.
* Only rmdir /lib/init/rw if it exists.
* Explicitly order debian-fixup before sysinit.target to prevent a
  possible race condition with the creation of sockets.  Thanks to
  Michael Biebl for debugging this.
* Always restart the initctl socket on upgrades, to mask sysvinit
  removing it.

[ Michael Biebl ]
* Remove workaround for non-interactive sessions from pam config again.
* Create compat /dev/initctl symlink in case we are upgrading from a system
  running a newer version of sysvinit (using /run/initctl) and sysvinit is
  replaced with systemd-sysv during the upgrade. Closes: #663219
* Install new man pages.
* Build-Depend on valac (>= 0.12) instead of valac-0.12. Closes: #663323

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
2
 
 
3
#ifndef foojournalfilehfoo
 
4
#define foojournalfilehfoo
 
5
 
 
6
/***
 
7
  This file is part of systemd.
 
8
 
 
9
  Copyright 2011 Lennart Poettering
 
10
 
 
11
  systemd is free software; you can redistribute it and/or modify it
 
12
  under the terms of the GNU General Public License as published by
 
13
  the Free Software Foundation; either version 2 of the License, or
 
14
  (at your option) any later version.
 
15
 
 
16
  systemd is distributed in the hope that it will be useful, but
 
17
  WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
19
  General Public License for more details.
 
20
 
 
21
  You should have received a copy of the GNU General Public License
 
22
  along with systemd; If not, see <http://www.gnu.org/licenses/>.
 
23
***/
 
24
 
 
25
#include <inttypes.h>
 
26
 
 
27
#include <systemd/sd-id128.h>
 
28
 
 
29
#include "journal-def.h"
 
30
#include "util.h"
 
31
 
 
32
typedef struct Window {
 
33
        void *ptr;
 
34
        uint64_t offset;
 
35
        uint64_t size;
 
36
} Window;
 
37
 
 
38
enum {
 
39
        WINDOW_UNKNOWN = OBJECT_UNUSED,
 
40
        WINDOW_DATA = OBJECT_DATA,
 
41
        WINDOW_ENTRY = OBJECT_ENTRY,
 
42
        WINDOW_DATA_HASH_TABLE = OBJECT_DATA_HASH_TABLE,
 
43
        WINDOW_FIELD_HASH_TABLE = OBJECT_FIELD_HASH_TABLE,
 
44
        WINDOW_ENTRY_ARRAY = OBJECT_ENTRY_ARRAY,
 
45
        WINDOW_HEADER,
 
46
        _WINDOW_MAX
 
47
};
 
48
 
 
49
typedef struct JournalMetrics {
 
50
        uint64_t max_use;
 
51
        uint64_t max_size;
 
52
        uint64_t min_size;
 
53
        uint64_t keep_free;
 
54
} JournalMetrics;
 
55
 
 
56
typedef struct JournalFile {
 
57
        int fd;
 
58
        char *path;
 
59
        struct stat last_stat;
 
60
        mode_t mode;
 
61
        int flags;
 
62
        int prot;
 
63
        bool writable;
 
64
        bool tail_entry_monotonic_valid;
 
65
 
 
66
        Header *header;
 
67
        HashItem *data_hash_table;
 
68
        HashItem *field_hash_table;
 
69
 
 
70
        Window windows[_WINDOW_MAX];
 
71
 
 
72
        uint64_t current_offset;
 
73
 
 
74
        JournalMetrics metrics;
 
75
 
 
76
        bool compress;
 
77
 
 
78
#ifdef HAVE_XZ
 
79
        void *compress_buffer;
 
80
        uint64_t compress_buffer_size;
 
81
#endif
 
82
} JournalFile;
 
83
 
 
84
typedef enum direction {
 
85
        DIRECTION_UP,
 
86
        DIRECTION_DOWN
 
87
} direction_t;
 
88
 
 
89
int journal_file_open(const char *fname, int flags, mode_t mode, JournalFile *template, JournalFile **ret);
 
90
void journal_file_close(JournalFile *j);
 
91
 
 
92
int journal_file_open_reliably(const char *fname, int flags, mode_t mode, JournalFile *template, JournalFile **ret);
 
93
 
 
94
int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Object **ret);
 
95
 
 
96
uint64_t journal_file_entry_n_items(Object *o);
 
97
 
 
98
int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const struct iovec iovec[], unsigned n_iovec, uint64_t *seqno, Object **ret, uint64_t *offset);
 
99
 
 
100
int journal_file_find_data_object(JournalFile *f, const void *data, uint64_t size, Object **ret, uint64_t *offset);
 
101
int journal_file_find_data_object_with_hash(JournalFile *f, const void *data, uint64_t size, uint64_t hash, Object **ret, uint64_t *offset);
 
102
 
 
103
int journal_file_next_entry(JournalFile *f, Object *o, uint64_t p, direction_t direction, Object **ret, uint64_t *offset);
 
104
int journal_file_skip_entry(JournalFile *f, Object *o, uint64_t p, int64_t skip, Object **ret, uint64_t *offset);
 
105
 
 
106
int journal_file_next_entry_for_data(JournalFile *f, Object *o, uint64_t p, uint64_t data_offset, direction_t direction, Object **ret, uint64_t *offset);
 
107
 
 
108
int journal_file_move_to_entry_by_seqnum(JournalFile *f, uint64_t seqnum, direction_t direction, Object **ret, uint64_t *offset);
 
109
int journal_file_move_to_entry_by_realtime(JournalFile *f, uint64_t realtime, direction_t direction, Object **ret, uint64_t *offset);
 
110
int journal_file_move_to_entry_by_monotonic(JournalFile *f, sd_id128_t boot_id, uint64_t monotonic, direction_t direction, Object **ret, uint64_t *offset);
 
111
 
 
112
int journal_file_move_to_entry_by_seqnum_for_data(JournalFile *f, uint64_t data_offset, uint64_t seqnum, direction_t direction, Object **ret, uint64_t *offset);
 
113
int journal_file_move_to_entry_by_realtime_for_data(JournalFile *f, uint64_t data_offset, uint64_t realtime, direction_t direction, Object **ret, uint64_t *offset);
 
114
 
 
115
int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint64_t p, uint64_t *seqnum, Object **ret, uint64_t *offset);
 
116
 
 
117
void journal_file_dump(JournalFile *f);
 
118
 
 
119
int journal_file_rotate(JournalFile **f);
 
120
 
 
121
int journal_directory_vacuum(const char *directory, uint64_t max_use, uint64_t min_free);
 
122
 
 
123
void journal_file_post_change(JournalFile *f);
 
124
 
 
125
void journal_default_metrics(JournalMetrics *m, int fd);
 
126
 
 
127
#endif