@@ -191,3 +191,12 @@ _scratch_ext4_options()
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}"
}
+
+# Get the inode flags for a particular inode number
+_ext4_get_inum_iflags() {
+ local dev="$1"
+ local inumber="$2"
+
+ debugfs -R "stat <${inumber}>" "${dev}" 2> /dev/null | \
+ sed -n 's/^.*Flags: \([0-9a-fx]*\).*$/\1/p'
+}
@@ -641,7 +641,7 @@ __populate_check_ext4_dformat() {
extents=0
etree=0
debugfs -R "stat <${inode}>" "${dev}" 2> /dev/null | grep 'ETB[0-9]' -q && etree=1
- iflags="$(debugfs -R "stat <${inode}>" "${dev}" 2> /dev/null | grep 'Flags:' | sed -e 's/^.*Flags: \([0-9a-fx]*\).*$/\1/g')"
+ iflags="$(_ext4_get_inum_iflags "${dev}" "${inode}")"
test "$(echo "${iflags}" | awk '{print and(strtonum($1), 0x80000);}')" -gt 0 && extents=1
case "${format}" in
@@ -688,7 +688,7 @@ __populate_check_ext4_dir() {
htree=0
inline=0
- iflags="$(debugfs -R "stat <${inode}>" "${dev}" 2> /dev/null | grep 'Flags:' | sed -e 's/^.*Flags: \([0-9a-fx]*\).*$/\1/g')"
+ iflags="$(_ext4_get_inum_iflags "${dev}" "${inode}")"
test "$(echo "${iflags}" | awk '{print and(strtonum($1), 0x1000);}')" -gt 0 && htree=1
test "$(echo "${iflags}" | awk '{print and(strtonum($1), 0x10000000);}')" -gt 0 && inline=1
@@ -179,8 +179,7 @@ _xfs_get_rtextents()
{
local path="$1"
- $XFS_INFO_PROG "$path" | grep 'rtextents' | \
- sed -e 's/^.*rtextents=\([0-9]*\).*$/\1/g'
+ $XFS_INFO_PROG "$path" | sed -n "s/^.*rtextents=\([[:digit:]]*\).*/\1/p"
}
# Get the realtime extent size of a mounted filesystem.
@@ -188,8 +187,7 @@ _xfs_get_rtextsize()
{
local path="$1"
- $XFS_INFO_PROG "$path" | grep 'realtime.*extsz' | \
- sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g'
+ $XFS_INFO_PROG "$path" | sed -n "s/^.*realtime.*extsz=\([[:digit:]]*\).*/\1/p"
}
# Get the size of an allocation unit of a file. Normally this is just the
@@ -226,8 +224,7 @@ _xfs_get_dir_blocksize()
{
local fs="$1"
- $XFS_INFO_PROG "$fs" | grep 'naming.*bsize' | \
- sed -e 's/^.*bsize=//g' -e 's/\([0-9]*\).*$/\1/g'
+ $XFS_INFO_PROG "$fs" | sed -n "s/^naming.*bsize=\([[:digit:]]*\).*/\1/p"
}
# Set or clear the realtime status of every supplied path. The first argument
@@ -1276,7 +1273,7 @@ _force_xfsv4_mount_options()
# Find AG count of mounted filesystem
_xfs_mount_agcount()
{
- $XFS_INFO_PROG "$1" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g'
+ $XFS_INFO_PROG "$1" | sed -n "s/^.*agcount=\([[:digit:]]*\).*/\1/p"
}
# Wipe the superblock of each XFS AGs