chiark / gitweb /
Fix build without any compression enabled
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 11 Jul 2014 14:42:06 +0000 (10:42 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 11 Jul 2014 14:42:27 +0000 (10:42 -0400)
Makefile.am
configure.ac
src/journal/compress.c
src/journal/coredump.c
src/journal/journal-file.c
src/journal/sd-journal.c

index f934bb1..bb8fc47 100644 (file)
@@ -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 \
index 19af217..e16d50d 100644 (file)
@@ -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]),
index 93ac92a..316c1a6 100644 (file)
@@ -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)
index 59c6d4b..1b8c2e8 100644 (file)
@@ -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;
index d3535d2..dc041dd 100644 (file)
@@ -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;
 
index 8dd82ec..f674abf 100644 (file)
@@ -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;