]> git.proxmox.com Git - pve-common.git/commitdiff
added syncfs syscall and sync_mountpoint helper
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 11 Feb 2016 08:26:29 +0000 (09:26 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 11 Feb 2016 10:24:11 +0000 (11:24 +0100)
src/PVE/Tools.pm

index 60ba8aa5f62d01892ed2fd9189c77141d34ca74e..6303d2047f5fc02898feb553321336c702710a2c 100644 (file)
@@ -75,6 +75,8 @@ use constant {CLONE_NEWNS   => 0x00020000,
               CLONE_NEWPID  => 0x20000000,
               CLONE_NEWNET  => 0x40000000};
 
               CLONE_NEWPID  => 0x20000000,
               CLONE_NEWNET  => 0x40000000};
 
+use constant O_PATH => 0x10000000;
+
 sub run_with_timeout {
     my ($timeout, $code, @param) = @_;
 
 sub run_with_timeout {
     my ($timeout, $code, @param) = @_;
 
@@ -1195,4 +1197,17 @@ sub setns($$) {
     return 0 == syscall(308, $fileno, $nstype);
 }
 
     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;
 1;