linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Monitor: dev should be a block file in waitclean
@ 2017-02-14  7:50 Zhilong Liu
  2017-02-24  3:07 ` zhilong
  0 siblings, 1 reply; 2+ messages in thread
From: Zhilong Liu @ 2017-02-14  7:50 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: linux-raid, Zhilong Liu

    mdadm --wait-clean /dev/mdX, the dev should
    be a block file, otherwise fd2devnm returns
    NULL and triggers core dumped.

Signed-off-by: Zhilong Liu <zlliu@suse.com>

diff --git a/Monitor.c b/Monitor.c
index 802a9d9..d16ac49 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -1060,7 +1060,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));
+		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)
-- 
2.6.6


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Monitor: dev should be a block file in waitclean
  2017-02-14  7:50 [PATCH] Monitor: dev should be a block file in waitclean Zhilong Liu
@ 2017-02-24  3:07 ` zhilong
  0 siblings, 0 replies; 2+ messages in thread
From: zhilong @ 2017-02-24  3:07 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: linux-raid

Hi, Jes;
   I just wanted to ping and see if this could get a review:


On 02/14/2017 03:50 PM, Zhilong Liu wrote:
>      mdadm --wait-clean /dev/mdX, the dev should
>      be a block file, otherwise fd2devnm returns
>      NULL and triggers core dumped.
>
> Signed-off-by: Zhilong Liu <zlliu@suse.com>
>
> diff --git a/Monitor.c b/Monitor.c
> index 802a9d9..d16ac49 100644
> --- a/Monitor.c
> +++ b/Monitor.c
> @@ -1060,7 +1060,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));
> +		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)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-24  3:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-14  7:50 [PATCH] Monitor: dev should be a block file in waitclean Zhilong Liu
2017-02-24  3:07 ` zhilong

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).