|
|
fc6001 |
From 75a721fd7d5e5ee7e578571fe58755fe07e446fc Mon Sep 17 00:00:00 2001
|
|
|
fc6001 |
From: Lukasz Dorau <lukasz.dorau@intel.com>
|
|
|
fc6001 |
Date: Thu, 19 Dec 2013 13:02:12 +0100
|
|
|
fc6001 |
Subject: [PATCH] policy: NULL path isn't really acceptable - use the devname
|
|
|
fc6001 |
|
|
|
fc6001 |
According to:
|
|
|
fc6001 |
commit b451aa4846c5ccca5447a6b6d45e5623b8c8e961
|
|
|
fc6001 |
Fix handling for "auto" line in mdadm.conf
|
|
|
fc6001 |
|
|
|
fc6001 |
a NULL path isn't really acceptable and the devname should be used instead.
|
|
|
fc6001 |
|
|
|
fc6001 |
Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
|
|
|
fc6001 |
Signed-off-by: NeilBrown <neilb@suse.de>
|
|
|
fc6001 |
---
|
|
|
fc6001 |
policy.c | 35 +++++++++++++++++------------------
|
|
|
fc6001 |
1 file changed, 17 insertions(+), 18 deletions(-)
|
|
|
fc6001 |
|
|
|
fc6001 |
diff --git a/policy.c b/policy.c
|
|
|
fc6001 |
index b4f3943..104695d 100644
|
|
|
fc6001 |
--- a/policy.c
|
|
|
fc6001 |
+++ b/policy.c
|
|
|
fc6001 |
@@ -200,26 +200,25 @@ static char *disk_path(struct mdinfo *disk)
|
|
|
fc6001 |
int rv;
|
|
|
fc6001 |
|
|
|
fc6001 |
by_path = opendir(symlink);
|
|
|
fc6001 |
- if (!by_path)
|
|
|
fc6001 |
- return NULL;
|
|
|
fc6001 |
- prefix_len = strlen(symlink);
|
|
|
fc6001 |
-
|
|
|
fc6001 |
- while ((ent = readdir(by_path)) != NULL) {
|
|
|
fc6001 |
- if (ent->d_type != DT_LNK)
|
|
|
fc6001 |
- continue;
|
|
|
fc6001 |
- strncpy(symlink + prefix_len,
|
|
|
fc6001 |
- ent->d_name,
|
|
|
fc6001 |
- sizeof(symlink) - prefix_len);
|
|
|
fc6001 |
- if (stat(symlink, &stb) < 0)
|
|
|
fc6001 |
- continue;
|
|
|
fc6001 |
- if ((stb.st_mode & S_IFMT) != S_IFBLK)
|
|
|
fc6001 |
- continue;
|
|
|
fc6001 |
- if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor))
|
|
|
fc6001 |
- continue;
|
|
|
fc6001 |
+ if (by_path) {
|
|
|
fc6001 |
+ prefix_len = strlen(symlink);
|
|
|
fc6001 |
+ while ((ent = readdir(by_path)) != NULL) {
|
|
|
fc6001 |
+ if (ent->d_type != DT_LNK)
|
|
|
fc6001 |
+ continue;
|
|
|
fc6001 |
+ strncpy(symlink + prefix_len,
|
|
|
fc6001 |
+ ent->d_name,
|
|
|
fc6001 |
+ sizeof(symlink) - prefix_len);
|
|
|
fc6001 |
+ if (stat(symlink, &stb) < 0)
|
|
|
fc6001 |
+ continue;
|
|
|
fc6001 |
+ if ((stb.st_mode & S_IFMT) != S_IFBLK)
|
|
|
fc6001 |
+ continue;
|
|
|
fc6001 |
+ if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor))
|
|
|
fc6001 |
+ continue;
|
|
|
fc6001 |
+ closedir(by_path);
|
|
|
fc6001 |
+ return strdup(ent->d_name);
|
|
|
fc6001 |
+ }
|
|
|
fc6001 |
closedir(by_path);
|
|
|
fc6001 |
- return strdup(ent->d_name);
|
|
|
fc6001 |
}
|
|
|
fc6001 |
- closedir(by_path);
|
|
|
fc6001 |
/* A NULL path isn't really acceptable - use the devname.. */
|
|
|
fc6001 |
sprintf(symlink, "/sys/dev/block/%d:%d", disk->disk.major, disk->disk.minor);
|
|
|
fc6001 |
rv = readlink(symlink, nm, sizeof(nm)-1);
|
|
|
fc6001 |
--
|
|
|
fc6001 |
1.8.5.3
|
|
|
fc6001 |
|