]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/NDC_PP.pm
update copyrights for 2021
[public-inbox.git] / lib / PublicInbox / NDC_PP.pm
index 0d20030d512903896dd2266fb73e2c8a4bfd369a..57abccbe06253dcff0a252eb533bdb587bce2faf 100644 (file)
@@ -1,4 +1,4 @@
-# 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
@@ -6,10 +6,8 @@ package PublicInbox::NDC_PP;
 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(/ /);
@@ -26,4 +24,11 @@ sub set_nodatacow ($) {
        }
 }
 
+sub nodatacow_fd ($) {
+       my ($fd) = @_;
+       return if $^O ne 'linux';
+       defined(my $path = readlink("/proc/self/fd/$fd")) or return;
+       nodatacow_dir($path);
+}
+
 1;