5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2025-01-10 09:17:37 +03:00

added syncfs syscall and sync_mountpoint helper

This commit is contained in:
Wolfgang Bumiller 2016-02-11 09:26:29 +01:00 committed by Dietmar Maurer
parent dde69c3200
commit 44acb12c27

View 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) = @_;
@ -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;