-# Copyright (C) 2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# Pure-perl class for Linux non-Inline::C users to disable COW for btrfs
use strict;
use v5.10.1;
-sub set_nodatacow ($) {
- my ($fd) = @_;
- return if $^O ne 'linux';
- defined(my $path = readlink("/proc/self/fd/$fd")) or return;
+sub nodatacow_dir ($) {
+ my ($path) = @_;
open my $mh, '<', '/proc/self/mounts' or return;
for (grep(/ btrfs /, <$mh>)) {
my (undef, $mnt_path, $type) = split(/ /);
}
}
+sub nodatacow_fd ($) {
+ my ($fd) = @_;
+ return if $^O ne 'linux';
+ defined(my $path = readlink("/proc/self/fd/$fd")) or return;
+ nodatacow_dir($path);
+}
+
1;