[PATCH] common: new function to get real device path name and basename
Dave Chinner
david at fromorbit.com
Tue Apr 22 00:10:51 CDT 2014
On Tue, Apr 22, 2014 at 11:27:27AM +0800, Eryu Guan wrote:
> If TEST_DEV or SCRATCH_DEV is symlink(mostly a lvm lv), a simple
> basename is not enough, symlink should be followed.
>
> This task is common enough, so introduce new helper functions and
> replace all readlink calls in
>
> ext4/305
> generic/009
> generic/019
> generic/285
> generic/312
>
> Signed-off-by: Eryu Guan <eguan at redhat.com>
> ---
> common/rc | 16 ++++++++++++++++
> tests/ext4/305 | 2 +-
> tests/generic/009 | 2 +-
> tests/generic/019 | 4 +---
> tests/generic/285 | 2 +-
> tests/generic/312 | 2 +-
> 6 files changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/common/rc b/common/rc
> index acf419b..68b040d 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2302,6 +2302,22 @@ init_rc()
> export XFS_IO_PROG="$XFS_IO_PROG -F"
> }
>
> +# get real device path name by following link
> +_real_dev()
> +{
> + local _dev=$1
> + if [ -b "$_dev" ] && [ -L "$_dev" ]; then
> + _dev=`readlink -f "$_dev"`
> + fi
> + echo $_dev
> +}
> +
> +# basename of a device
> +_basename_dev()
> +{
> + echo `basename $(_real_dev $1)`
> +}
I don't really like that function name. It describes the
implementation, not what the function actually returns. i.e. we're
getting the -short- device names here, basename is the implemenation
used to turn a full device name to a short device name...
Cheers,
Dave
--
Dave Chinner
david at fromorbit.com
More information about the xfs
mailing list