Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the mogilefs-server CPAN distribution.

Report information
The Basics
Id: 49703
Status: resolved
Priority: 0/
Queue: mogilefs-server

People
Owner: Nobody in particular
Requestors: cpan [...] otoh.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.30
Fixed in: (no value)



Subject: GNU df is broken. Allow the use of local non-gnu df if it exists.
Download (untitled) / with headers
text/plain 2.1k
Mogstored uses the -P flag to df due to GNU df's broken behavior with splitting line output and requiring -P to do the right thing. For those of us not using GNU df, it'd be nice to have mogstored just work with our local df. Here's the patch to make this work: --- DiskUsage.pm.gnu Mon Sep 14 22:32:53 2009 +++ DiskUsage.pm Mon Sep 14 22:37:26 2009 @@ -36,7 +36,13 @@ my $err = sub { warn "$_[0]\n"; }; my $path = $ENV{MOG_DOCROOT}; $path =~ s!/$!!; + my $gnu_df; + # gnu df is broken as it splits output onto multiple lines by default + if($^O eq 'Linux') { + $gnu_df = '-P'; + } + # find all devices below us my @devnum; if (opendir(D, $path)) { @@ -47,7 +53,7 @@ } foreach my $devnum (@devnum) { - my $rval = `df -P -l -k $path/$devnum`; + my $rval = `df $gnu_df -l -k $path/$devnum`; my $uperK = ($rval =~ /512-blocks/i) ? 2 : 1; # units per kB foreach my $l (split /\r?\n/, $rval) { next unless $l =~ /^(.+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(.+)\s+(.+)$/; That patch does assume Linux is the only place to find GNU df, to be really sure, the fix would be something more like the following (although it does end up making 2 system calls instead of one each time) --- DiskUsage.pm.gnu Mon Sep 14 22:32:53 2009 +++ DiskUsage.pm Mon Sep 14 22:49:26 2009 @@ -36,7 +36,14 @@ my $err = sub { warn "$_[0]\n"; }; my $path = $ENV{MOG_DOCROOT}; $path =~ s!/$!!; + my $gnu_df; + # gnu df is broken as it splits output onto multiple lines by default + `df -P / 2>/dev/null >/dev/null`; + if($? eq 0) { + $gnu_df = '-P'; + } + # find all devices below us my @devnum; if (opendir(D, $path)) { @@ -47,7 +54,7 @@ } foreach my $devnum (@devnum) { - my $rval = `df -P -l -k $path/$devnum`; + my $rval = `df $gnu_df -l -k $path/$devnum`; my $uperK = ($rval =~ /512-blocks/i) ? 2 : 1; # units per kB foreach my $l (split /\r?\n/, $rval) { next unless $l =~ /^(.+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(.+)\s+(.+)$/; -- Save our economy, demand finishing metric conversion from your federal and state representatives.
this was fixed a while ago.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.