]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/journal/test-journal-flush.c
tree-wide: make use of new relative time events in sd-event.h
[thirdparty/systemd.git] / src / journal / test-journal-flush.c
index e302fd61f1f94e2b623219c29f1683696cb459aa..5fedd3ed20464ad70e23261f85c7123c12346dc8 100644 (file)
@@ -1,31 +1,16 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
 
 #include <fcntl.h>
+#include <unistd.h>
 
 #include "sd-journal.h"
 
 #include "alloc-util.h"
+#include "chattr-util.h"
 #include "journal-file.h"
 #include "journal-internal.h"
 #include "macro.h"
+#include "path-util.h"
 #include "string-util.h"
 
 int main(int argc, char *argv[]) {
@@ -37,7 +22,9 @@ int main(int argc, char *argv[]) {
         int r;
 
         assert_se(mkdtemp(dn));
-        fn = strappend(dn, "/test.journal");
+        (void) chattr_path(dn, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
+
+        fn = path_join(dn, "test.journal");
 
         r = journal_file_open(-1, fn, O_CREAT|O_RDWR, 0644, false, 0, false, NULL, NULL, NULL, NULL, &new_journal);
         assert_se(r >= 0);
@@ -55,13 +42,16 @@ int main(int argc, char *argv[]) {
                 assert_se(f && f->current_offset > 0);
 
                 r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
+                if (r < 0)
+                        log_error_errno(r, "journal_file_move_to_object failed: %m");
                 assert_se(r >= 0);
 
-                r = journal_file_copy_entry(f, new_journal, o, f->current_offset, NULL, NULL, NULL);
+                r = journal_file_copy_entry(f, new_journal, o, f->current_offset);
+                if (r < 0)
+                        log_error_errno(r, "journal_file_copy_entry failed: %m");
                 assert_se(r >= 0);
 
-                n++;
-                if (n > 10000)
+                if (++n >= 10000)
                         break;
         }