Linux RAID subsystem development
 help / color / mirror / Atom feed
* [PATCH] policy: NULL path isn't really acceptable - use the devname
@ 2013-12-19 12:02 Lukasz Dorau
  2013-12-19 12:06 ` Dorau, Lukasz
  2014-01-06  6:12 ` NeilBrown
  0 siblings, 2 replies; 3+ messages in thread
From: Lukasz Dorau @ 2013-12-19 12:02 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, pawel.baldysiak

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


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

end of thread, other threads:[~2014-01-06  6:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox