[pve-devel] [RFC PATCH common] added syncfs syscall and sync_mountpoint helper

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Feb 11 09:26:29 CET 2016


---
This patch goes hand in hand with the namespace-sync patch for pve-container

 src/PVE/Tools.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index 60ba8aa..6303d20 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -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) = @_;
 
@@ -1195,4 +1197,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;
-- 
2.1.4





More information about the pve-devel mailing list