diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-09-07 23:20:28 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-09-07 23:20:28 +0200 |
commit | a1a03e3075316e2376176fc54c74e071adc9d71a (patch) | |
tree | a9ae636fd1b17047398c0f9eaf8709ecb0a861f5 /src/journal/sd-journal.c | |
parent | ac59a798f2e9e616872e5c571219374c6d8f010d (diff) |
journal: add call to determine current journal file disk usage
Diffstat (limited to 'src/journal/sd-journal.c')
-rw-r--r-- | src/journal/sd-journal.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 0f7c02ce69..b4d35eebaf 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -2062,6 +2062,29 @@ void journal_print_header(sd_journal *j) { } } +_public_ int sd_journal_get_usage(sd_journal *j, uint64_t *bytes) { + Iterator i; + JournalFile *f; + uint64_t sum = 0; + + if (!j) + return -EINVAL; + if (!bytes) + return -EINVAL; + + HASHMAP_FOREACH(f, j->files, i) { + struct stat st; + + if (fstat(f->fd, &st) < 0) + return -errno; + + sum += (uint64_t) st.st_blocks * 512ULL; + } + + *bytes = sum; + return 0; +} + /* _public_ int sd_journal_query_unique(sd_journal *j, const char *field) { */ /* if (!j) */ /* return -EINVAL; */ |