Determine block-size of a VPS disk in linux-lib.pl

I use Webmin with a OpenVZ VPS. The following function cannot determine the block size of the disk:

/usr/libexec/webmin/quota/linux-lib.pl

sub fs_block_size
{
if ($_[2] =~ /^ext\d+$/) {
        return 1024;
        # This code isn't needed, because the quota block size is
        # not the same as the filesystem block size!!
        #if (&has_command("dumpe2fs")) {
        #       local $out = `dumpe2fs -h $_[1] 2>&1`;
        #       if (!$? && $out =~ /block size:\s+(\d+)/i) {
        #               return $1;
        #               }
        #       }
        }
elsif ($_[2] eq "xfs") {
        return 1024;
        }
return undef;
}

The problem stems from the issue that this command doesn't work: dumpe2fs /dev/simfs dumpe2fs 1.39 (29-May-2006) dumpe2fs: Operation not permitted while trying to open /dev/simfs Couldn't find valid filesystem superblock.

The OpenVZ website states:

https://openvz.org/User_Guide/Managing_Resources The disk quota block size in OpenVZ is always 1024 bytes

So the question is how can OpenVZ be detected.... or could a forceblocksize option be added?

This webpage indicates someways of detecting that it is an openVZ vps: http://www.webhostingtalk.com/showthread.php?t=941338

Such as

/proc/user_beancounters file exists or /dev/simfs exists

Please could you provide a fix for this?

I have fixed the method by making the following change:

sub fs_block_size
{
if ($_[2] =~ /^ext\d+$/) {
        return 1024;
        # This code isn't needed, because the quota block size is
        # not the same as the filesystem block size!!
        #if (&has_command("dumpe2fs")) {
        #       local $out = `dumpe2fs -h $_[1] 2>&1`;
        #       if (!$? && $out =~ /block size:\s+(\d+)/i) {
        #               return $1;
        #               }
        #       }
        }
elsif ($_[2] eq "xfs") {
        return 1024;
        }
elsif ($_[1] eq "/dev/simfs"){
        return 1024;
}
return undef;
}

Many Thanks

Status: 
Closed (fixed)

Comments

Thanks for the fix - I will include this in the next Webmin release.

Automatically closed -- issue fixed for 2 weeks with no activity.