From: Dave Chinner <david@fromorbit.com>
To: Eryu Guan <eguan@redhat.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] common: new function to get real device path name and basename
Date: Tue, 22 Apr 2014 15:10:51 +1000 [thread overview]
Message-ID: <20140422051051.GI18672@dastard> (raw)
In-Reply-To: <1398137247-4883-1-git-send-email-eguan@redhat.com>
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@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@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-04-22 5:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-22 3:27 [PATCH] common: new function to get real device path name and basename Eryu Guan
2014-04-22 5:10 ` Dave Chinner [this message]
2014-04-22 6:57 ` [PATCH v2] " Eryu Guan
2014-04-25 6:30 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140422051051.GI18672@dastard \
--to=david@fromorbit.com \
--cc=eguan@redhat.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).