summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-11 10:42:06 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-11 10:42:27 -0400
commit3b1a55e110ab387a8d213581983e20c0a63d7894 (patch)
tree972b5eca785f511c41d96a3f14b172c5f9180b5f
parent6017365a1d0c1c78fc34a7da63768ee5df5da511 (diff)
Fix build without any compression enabled
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac2
-rw-r--r--src/journal/compress.c4
-rw-r--r--src/journal/coredump.c2
-rw-r--r--src/journal/journal-file.c9
-rw-r--r--src/journal/sd-journal.c47
6 files changed, 45 insertions, 21 deletions
diff --git a/Makefile.am b/Makefile.am
index f934bb1473..bb8fc475b4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3667,9 +3667,11 @@ tests += \
test-mmap-cache \
test-catalog
+if HAVE_COMPRESSION
tests += \
test-compress \
test-compress-benchmark
+endif
pkginclude_HEADERS += \
src/systemd/sd-journal.h \
diff --git a/configure.ac b/configure.ac
index 19af217a22..e16d50d4cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -520,6 +520,8 @@ AS_IF([test "x$enable_lz4" == "xyes"], [
])
AM_CONDITIONAL(HAVE_LZ4, [test "$have_lz4" = "yes"])
+AM_CONDITIONAL(HAVE_COMPRESSION, [test "$have_xz" = "yes" -o "$have_lz4" = "yes"])
+
# ------------------------------------------------------------------------------
AC_ARG_ENABLE([pam],
AS_HELP_STRING([--disable-pam],[Disable optional PAM support]),
diff --git a/src/journal/compress.c b/src/journal/compress.c
index 93ac92aaad..316c1a66e3 100644
--- a/src/journal/compress.c
+++ b/src/journal/compress.c
@@ -343,6 +343,7 @@ int decompress_startswith(int compression,
}
int compress_stream_xz(int fdf, int fdt, off_t max_bytes) {
+#ifdef HAVE_XZ
_cleanup_(lzma_end) lzma_stream s = LZMA_STREAM_INIT;
lzma_ret ret;
@@ -414,6 +415,9 @@ int compress_stream_xz(int fdf, int fdt, off_t max_bytes) {
}
}
}
+#else
+ return -EPROTONOSUPPORT;
+#endif
}
#define LZ4_BUFSIZE (512*1024)
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 59c6d4b716..1b8c2e8bc0 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -402,9 +402,9 @@ static int save_external_coredump(
fail_compressed:
unlink_noerrno(tmp_compressed);
}
-#endif
uncompressed:
+#endif
r = fix_permissions(fd, tmp, fn, info, uid);
if (r < 0)
goto fail;
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index d3535d2fad..dc041dd58a 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -819,6 +819,7 @@ int journal_file_find_data_object_with_hash(
goto next;
if (o->object.flags & OBJECT_COMPRESSION_MASK) {
+#if defined(HAVE_XZ) || defined(HAVE_LZ4)
uint64_t l, rsize;
l = le64toh(o->object.size);
@@ -843,7 +844,9 @@ int journal_file_find_data_object_with_hash(
return 1;
}
-
+#else
+ return -EPROTONOSUPPORT;
+#endif
} else if (le64toh(o->object.size) == osize &&
memcmp(o->data.payload, data, size) == 0) {
@@ -2772,6 +2775,7 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
return -E2BIG;
if (o->object.flags & OBJECT_COMPRESSION_MASK) {
+#if defined(HAVE_XZ) || defined(HAVE_LZ4)
uint64_t rsize;
r = decompress_blob(o->object.flags & OBJECT_COMPRESSION_MASK,
@@ -2781,6 +2785,9 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
data = from->compress_buffer;
l = rsize;
+#else
+ return -EPROTONOSUPPORT;
+#endif
} else
data = o->data.payload;
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 8dd82ec2ac..f674abf9d7 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1997,26 +1997,30 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
l = le64toh(o->object.size) - offsetof(Object, data.payload);
compression = o->object.flags & OBJECT_COMPRESSION_MASK;
- if (compression &&
- decompress_startswith(compression,
- o->data.payload, l,
- &f->compress_buffer, &f->compress_buffer_size,
- field, field_length, '=')) {
-
- uint64_t rsize;
-
- r = decompress_blob(compression,
- o->data.payload, l,
- &f->compress_buffer, &f->compress_buffer_size, &rsize,
- j->data_threshold);
- if (r < 0)
- return r;
+ if (compression) {
+#if defined(HAVE_XZ) || defined(HAVE_LZ4)
+ if (decompress_startswith(compression,
+ o->data.payload, l,
+ &f->compress_buffer, &f->compress_buffer_size,
+ field, field_length, '=')) {
+
+ uint64_t rsize;
+
+ r = decompress_blob(compression,
+ o->data.payload, l,
+ &f->compress_buffer, &f->compress_buffer_size, &rsize,
+ j->data_threshold);
+ if (r < 0)
+ return r;
- *data = f->compress_buffer;
- *size = (size_t) rsize;
-
- return 0;
+ *data = f->compress_buffer;
+ *size = (size_t) rsize;
+ return 0;
+ }
+#else
+ return -EPROTONOSUPPORT;
+#endif
} else if (l >= field_length+1 &&
memcmp(o->data.payload, field, field_length) == 0 &&
o->data.payload[field_length] == '=') {
@@ -2043,7 +2047,7 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
static int return_data(sd_journal *j, JournalFile *f, Object *o, const void **data, size_t *size) {
size_t t;
uint64_t l;
- int compression, r;
+ int compression;
l = le64toh(o->object.size) - offsetof(Object, data.payload);
t = (size_t) l;
@@ -2054,7 +2058,9 @@ static int return_data(sd_journal *j, JournalFile *f, Object *o, const void **da
compression = o->object.flags & OBJECT_COMPRESSION_MASK;
if (compression) {
+#if defined(HAVE_XZ) || defined(HAVE_LZ4)
uint64_t rsize;
+ int r;
r = decompress_blob(compression,
o->data.payload, l, &f->compress_buffer,
@@ -2064,6 +2070,9 @@ static int return_data(sd_journal *j, JournalFile *f, Object *o, const void **da
*data = f->compress_buffer;
*size = (size_t) rsize;
+#else
+ return -EPROTONOSUPPORT;
+#endif
} else {
*data = o->data.payload;
*size = t;