]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Tools.pm
Add since and until parameter to dump_journal
[pve-common.git] / src / PVE / Tools.pm
index 60ba8aa5f62d01892ed2fd9189c77141d34ca74e..1d1f4b8429e951503fe71175159796f0dbacfee7 100644 (file)
@@ -75,6 +75,8 @@ use constant {CLONE_NEWNS   => 0x00020000,
               CLONE_NEWPID  => 0x20000000,
               CLONE_NEWNET  => 0x40000000};
 
+use constant O_PATH => 0x10000000;
+
 sub run_with_timeout {
     my ($timeout, $code, @param) = @_;
 
@@ -1059,7 +1061,7 @@ sub dump_logfile {
 }
 
 sub dump_journal {
-    my ($start, $limit, $filter) = @_;
+    my ($start, $limit, $since, $until) = @_;
 
     my $lines = [];
     my $count = 0;
@@ -1077,6 +1079,9 @@ sub dump_journal {
     };
 
     my $cmd = ['journalctl', '-o', 'short', '--no-pager'];
+
+    push @$cmd, '--since', $since if $since;
+    push @$cmd, '--until', $until if $until;
     run_command($cmd, outfunc => $parser);
 
     # HACK: ExtJS store.guaranteeRange() does not like empty array
@@ -1195,4 +1200,17 @@ sub setns($$) {
     return 0 == syscall(308, $fileno, $nstype);
 }
 
+sub syncfs($) {
+    my ($fileno) = @_;
+    return 0 == syscall(306, $fileno);
+}
+
+sub sync_mountpoint {
+    my ($path) = @_;
+    sysopen my $fd, $path, O_PATH or die "failed to open $path: $!\n";
+    my $result = syncfs(fileno($fd));
+    close($fd);
+    return $result;
+}
+
 1;