From: NeilBrown <neilb@suse.de>
To: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Cc: linux-raid@vger.kernel.org, wojciech.neubauer@intel.com,
adam.kwolek@intel.com, dan.j.williams@intel.com,
ed.ciechanowski@intel.com
Subject: Re: [PATCH] FIX: sysfs_disk_to_scsi_id() adapted to current sysfs format
Date: Thu, 17 Feb 2011 17:17:51 +1100 [thread overview]
Message-ID: <20110217171751.264709cd@notabene.brown> (raw)
In-Reply-To: <20110216124021.9092.83943.stgit@gklab-128-111.igk.intel.com>
On Wed, 16 Feb 2011 13:40:21 +0100 Krzysztof Wojcik
<krzysztof.wojcik@intel.com> wrote:
> Problem: sysfs_disk_to_scsi_id() not returns correct scsi_id value.
> Reason: sysfs format has been changed
>
> This patch adapt sysfs_disk_to_scsi_id() to new sysfs format.
If there has been a change in sysfs format, we want the code to work in both
old and new cases.
Do you know if this new code works in the 'old' case? Do you know when
(which kernel version) the change happened, or at least can you name a kernel
version when the 'old' style worked.
The patch looks OK, but I want to be sure all bases are covered.
Thanks,
NeilBrown
>
> Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
> ---
> sysfs.c | 14 ++++++--------
> 1 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/sysfs.c b/sysfs.c
> index f0773d4..883a834 100644
> --- a/sysfs.c
> +++ b/sysfs.c
> @@ -705,7 +705,7 @@ int sysfs_disk_to_scsi_id(int fd, __u32 *id)
> if (fstat(fd, &st))
> return 1;
>
> - snprintf(path, sizeof(path), "/sys/dev/block/%d:%d/device",
> + snprintf(path, sizeof(path), "/sys/dev/block/%d:%d/device/scsi_device",
> major(st.st_rdev), minor(st.st_rdev));
>
> dir = opendir(path);
> @@ -714,8 +714,7 @@ int sysfs_disk_to_scsi_id(int fd, __u32 *id)
>
> de = readdir(dir);
> while (de) {
> - if (strncmp("scsi_disk:", de->d_name,
> - strlen("scsi_disk:")) == 0)
> + if (strchr(de->d_name, ':'))
> break;
> de = readdir(dir);
> }
> @@ -724,21 +723,20 @@ int sysfs_disk_to_scsi_id(int fd, __u32 *id)
> if (!de)
> return 1;
>
> - c1 = strchr(de->d_name, ':');
> - c1++;
> + c1 = de->d_name;
> c2 = strchr(c1, ':');
> *c2 = '\0';
> *id = strtol(c1, NULL, 10) << 24; /* host */
> c1 = c2 + 1;
> c2 = strchr(c1, ':');
> *c2 = '\0';
> - *id |= strtol(c1, NULL, 10) << 16; /* channel */
> + *id |= strtol(c1, NULL, 10) << 16; /* bus */
> c1 = c2 + 1;
> c2 = strchr(c1, ':');
> *c2 = '\0';
> - *id |= strtol(c1, NULL, 10) << 8; /* lun */
> + *id |= strtol(c1, NULL, 10) << 8; /* target */
> c1 = c2 + 1;
> - *id |= strtol(c1, NULL, 10); /* id */
> + *id |= strtol(c1, NULL, 10); /* lun */
>
> return 0;
> }
next prev parent reply other threads:[~2011-02-17 6:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-16 12:40 [PATCH] FIX: sysfs_disk_to_scsi_id() adapted to current sysfs format Krzysztof Wojcik
2011-02-17 6:17 ` NeilBrown [this message]
2011-02-17 12:35 ` Wojcik, Krzysztof
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=20110217171751.264709cd@notabene.brown \
--to=neilb@suse.de \
--cc=adam.kwolek@intel.com \
--cc=dan.j.williams@intel.com \
--cc=ed.ciechanowski@intel.com \
--cc=krzysztof.wojcik@intel.com \
--cc=linux-raid@vger.kernel.org \
--cc=wojciech.neubauer@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