From: NeilBrown <neilb@suse.de>
To: Lukasz Dorau <lukasz.dorau@intel.com>
Cc: linux-raid@vger.kernel.org, pawel.baldysiak@intel.com
Subject: Re: [PATCH] policy: NULL path isn't really acceptable - use the devname
Date: Mon, 6 Jan 2014 17:12:07 +1100 [thread overview]
Message-ID: <20140106171207.2a7b83cc@notabene.brown> (raw)
In-Reply-To: <20131219120212.16976.96892.stgit@gklab-154-244.igk.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2016 bytes --]
On Thu, 19 Dec 2013 13:02:12 +0100 Lukasz Dorau <lukasz.dorau@intel.com>
wrote:
> According to:
> commit b451aa4846c5ccca5447a6b6d45e5623b8c8e961
> Fix handling for "auto" line in mdadm.conf
>
> a NULL path isn't really acceptable and the devname should be used instead.
>
> Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
> ---
> policy.c | 35 +++++++++++++++++------------------
> 1 file changed, 17 insertions(+), 18 deletions(-)
>
> diff --git a/policy.c b/policy.c
> index b4f3943..104695d 100644
> --- a/policy.c
> +++ b/policy.c
> @@ -200,26 +200,25 @@ static char *disk_path(struct mdinfo *disk)
> int rv;
>
> by_path = opendir(symlink);
> - if (!by_path)
> - return NULL;
> - prefix_len = strlen(symlink);
> -
> - while ((ent = readdir(by_path)) != NULL) {
> - if (ent->d_type != DT_LNK)
> - continue;
> - strncpy(symlink + prefix_len,
> - ent->d_name,
> - sizeof(symlink) - prefix_len);
> - if (stat(symlink, &stb) < 0)
> - continue;
> - if ((stb.st_mode & S_IFMT) != S_IFBLK)
> - continue;
> - if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor))
> - continue;
> + if (by_path) {
> + prefix_len = strlen(symlink);
> + while ((ent = readdir(by_path)) != NULL) {
> + if (ent->d_type != DT_LNK)
> + continue;
> + strncpy(symlink + prefix_len,
> + ent->d_name,
> + sizeof(symlink) - prefix_len);
> + if (stat(symlink, &stb) < 0)
> + continue;
> + if ((stb.st_mode & S_IFMT) != S_IFBLK)
> + continue;
> + if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor))
> + continue;
> + closedir(by_path);
> + return xstrdup(ent->d_name);
> + }
> closedir(by_path);
> - return xstrdup(ent->d_name);
> }
> - closedir(by_path);
> /* A NULL path isn't really acceptable - use the devname.. */
> sprintf(symlink, "/sys/dev/block/%d:%d", disk->disk.major, disk->disk.minor);
> rv = readlink(symlink, nm, sizeof(nm)-1);
Applied, thanks.
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
prev parent reply other threads:[~2014-01-06 6:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-19 12:02 [PATCH] policy: NULL path isn't really acceptable - use the devname Lukasz Dorau
2013-12-19 12:06 ` Dorau, Lukasz
2014-01-06 6:12 ` NeilBrown [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=20140106171207.2a7b83cc@notabene.brown \
--to=neilb@suse.de \
--cc=linux-raid@vger.kernel.org \
--cc=lukasz.dorau@intel.com \
--cc=pawel.baldysiak@intel.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