chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
journal: implement seek to head/tail
[elogind.git]
/
src
/
journal
/
journald.c
diff --git
a/src/journal/journald.c
b/src/journal/journald.c
index 7a2b50b01783f0c2443e54d717c399d6550cd048..ede314a55f204d7c2fead9bcbbe398522e61be81 100644
(file)
--- a/
src/journal/journald.c
+++ b/
src/journal/journald.c
@@
-43,6
+43,8
@@
typedef struct Server {
JournalFile *runtime_journal;
JournalFile *system_journal;
Hashmap *user_journals;
JournalFile *runtime_journal;
JournalFile *system_journal;
Hashmap *user_journals;
+
+ uint64_t seqnum;
} Server;
static void fix_perms(JournalFile *f, uid_t uid) {
} Server;
static void fix_perms(JournalFile *f, uid_t uid) {
@@
-95,6
+97,8
@@
static JournalFile* find_journal(Server *s, uid_t uid) {
char *p;
int r;
JournalFile *f;
char *p;
int r;
JournalFile *f;
+ char ids[33];
+ sd_id128_t machine;
assert(s);
assert(s);
@@
-105,14
+109,18
@@
static JournalFile* find_journal(Server *s, uid_t uid) {
if (uid <= 0)
return s->system_journal;
if (uid <= 0)
return s->system_journal;
+ r = sd_id128_get_machine(&machine);
+ if (r < 0)
+ return s->system_journal;
+
f = hashmap_get(s->user_journals, UINT32_TO_PTR(uid));
if (f)
return f;
f = hashmap_get(s->user_journals, UINT32_TO_PTR(uid));
if (f)
return f;
- if (asprintf(&p, "/var/log/journal/
user-%lu.journal"
, (unsigned long) uid) < 0)
+ if (asprintf(&p, "/var/log/journal/
%s/user-%lu.journal", sd_id128_to_string(machine, ids)
, (unsigned long) uid) < 0)
return s->system_journal;
return s->system_journal;
- r = journal_file_open(p, O_RDWR|O_CREAT, 0640,
NULL
, &f);
+ r = journal_file_open(p, O_RDWR|O_CREAT, 0640,
s->system_journal
, &f);
free(p);
if (r < 0)
free(p);
if (r < 0)
@@
-246,7
+254,7
@@
static void process_message(Server *s, const char *buf, struct ucred *ucred, str
if (!f)
log_warning("Dropping message, as we can't find a place to store the data.");
else {
if (!f)
log_warning("Dropping message, as we can't find a place to store the data.");
else {
- r = journal_file_append_entry(f, NULL, iovec, n, NULL, NULL);
+ r = journal_file_append_entry(f, NULL, iovec, n,
&s->seqnum,
NULL, NULL);
if (r < 0)
log_error("Failed to write entry, ignoring: %s", strerror(-r));
if (r < 0)
log_error("Failed to write entry, ignoring: %s", strerror(-r));
@@
-401,16
+409,11
@@
static int system_journal_open(Server *s) {
/* /var didn't work, so try /run, but this time we
* create the prefix too */
/* /var didn't work, so try /run, but this time we
* create the prefix too */
- fn = strappend("/run/log/journal/", ids);
- if (!fn)
- return -ENOMEM;
- (void) mkdir_p(fn, 0755);
- free(fn);
-
- /* Then create the runtime journal file */
fn = join("/run/log/journal/", ids, "/system.journal", NULL);
if (!fn)
return -ENOMEM;
fn = join("/run/log/journal/", ids, "/system.journal", NULL);
if (!fn)
return -ENOMEM;
+
+ (void) mkdir_parents(fn, 0755);
r = journal_file_open(fn, O_RDWR|O_CREAT, 0640, NULL, &s->runtime_journal);
free(fn);
r = journal_file_open(fn, O_RDWR|O_CREAT, 0640, NULL, &s->runtime_journal);
free(fn);