linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jes.sorensen@gmail.com
To: Zhilong Liu <zlliu@suse.com>
Cc: linux-raid@vger.kernel.org
Subject: Re: [PATCH] mdadm/Monitor:dev should be a block file when use --waitclean
Date: Mon, 27 Mar 2017 18:29:40 -0400	[thread overview]
Message-ID: <wrfj37dyica3.fsf@gmail.com> (raw)
In-Reply-To: <1489987317-22895-1-git-send-email-zlliu@suse.com> (Zhilong Liu's message of "Mon, 20 Mar 2017 13:21:57 +0800")

Zhilong Liu <zlliu@suse.com> writes:
> Monitor: mdadm --wait-clean /dev/mdX, the dev should
> be a block file, otherwise fd2devnm returns NULL and
> then triggers core dumped.
>
> Signed-off-by: Zhilong Liu <zlliu@suse.com>
> ---
>  Monitor.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/Monitor.c b/Monitor.c
> index f8850d3..5a2b5ca 100644
> --- a/Monitor.c
> +++ b/Monitor.c
> @@ -1065,7 +1065,17 @@ int WaitClean(char *dev, int sock, int verbose)
>  	struct mdinfo *mdi;
>  	int rv = 1;
>  	char devnm[32];
> +	struct stat stb;
>  
> +	if (stat(dev, &stb) != 0) {
> +		pr_err("Cannot find %s: %s\n", dev,
> +			strerror(errno));

Please use the 80 characters in the line.

> +		return 2;
> +	}
> +	if ((S_IFMT & stb.st_mode) != S_IFBLK) {
> +		pr_err("%s is not a block device.\n", dev);
> +		return 2;
> +	}
>  	fd = open(dev, O_RDONLY);
>  	if (fd < 0) {
>  		if (verbose)

We have 7-8 instances of this throughout the code (stat and fstat).
Maybe we should make it a utility function instead of duplicating it
further.

Cheers,
Jes

      reply	other threads:[~2017-03-27 22:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20  5:21 [PATCH] mdadm/Monitor:dev should be a block file when use --waitclean Zhilong Liu
2017-03-27 22:29 ` jes.sorensen [this message]

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=wrfj37dyica3.fsf@gmail.com \
    --to=jes.sorensen@gmail.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=zlliu@suse.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).