sync_mountpoint takes a path, gets an open filedescriptor and calls
syncfs(2) on it.
by opening with O_PATH the syncfs call fails with EBADF (see open(2)).
found by running:
```
pkill -f 'pvedaemon worker';
strace -yyttT -s 512 -o /tmp/trace -fp $(pgrep -f pvedaemon$)
```
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
CLONE_NEWNET => 0x40000000};
use constant {O_PATH => 0x00200000,
CLONE_NEWNET => 0x40000000};
use constant {O_PATH => 0x00200000,
+ O_CLOEXEC => 0x00080000,
O_TMPFILE => 0x00410000}; # This includes O_DIRECTORY
use constant {AT_EMPTY_PATH => 0x1000,
O_TMPFILE => 0x00410000}; # This includes O_DIRECTORY
use constant {AT_EMPTY_PATH => 0x1000,
sub sync_mountpoint {
my ($path) = @_;
sub sync_mountpoint {
my ($path) = @_;
- sysopen my $fd, $path, O_PATH or die "failed to open $path: $!\n";
+ sysopen my $fd, $path, O_RDONLY|O_CLOEXEC or die "failed to open $path: $!\n";
my $result = syncfs(fileno($fd));
close($fd);
return $result;
my $result = syncfs(fileno($fd));
close($fd);
return $result;