]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/NDC_PP.pm
support setting No_COW on Perl <5.22
[public-inbox.git] / lib / PublicInbox / NDC_PP.pm
index 0d20030d512903896dd2266fb73e2c8a4bfd369a..10a7ee2a1f0fb14edb8572b43c6e54d1fbb04d8d 100644 (file)
@@ -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;