config: Fix sysfs paths for partitions

generic/019 was failing with:

./tests/generic/019: line 65: /sys/block/pmem0p2/make-it-fail: No such file or directory

When using a partition, the file needed is located at
/sys/block/pmem0/pmem0p2/make-it-fail.

Rather than attempt to deduce whether a block device is a partition
or not, use the symlinks located in /sys/dev/block/ to find the right
location for the make-it-fail file.

Also change btrfs/088 to use the new _sysfs_dev function.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Matthew Wilcox
2015-05-26 12:51:57 +10:00
committed by Dave Chinner
parent a397d1aabe
commit 78bbab93d8
3 changed files with 18 additions and 10 deletions
+10
View File
@@ -3003,6 +3003,16 @@ _short_dev()
echo `basename $(_real_dev $1)`
}
_sysfs_dev()
{
local _dev=$1
local _maj=$(stat -c%t $_dev | tr [:lower:] [:upper:])
local _min=$(stat -c%T $_dev | tr [:lower:] [:upper:])
_maj=$(echo "ibase=16; $_maj" | bc)
_min=$(echo "ibase=16; $_min" | bc)
echo /sys/dev/block/$_maj:$_min
}
get_block_size()
{
if [ -z $1 ] || [ ! -d $1 ]; then