linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Print concrete error when creating mddev
@ 2022-04-25 13:27 Marius Kittler
  2022-04-26 14:38 ` Mariusz Tkaczyk
  0 siblings, 1 reply; 2+ messages in thread
From: Marius Kittler @ 2022-04-25 13:27 UTC (permalink / raw)
  To: linux-raid; +Cc: Marius Kittler

Example from my testing:
```
mdadm: unexpected failure opening /dev/md127: No such device or address
```

Before it would just print:
```
mdadm: unexpected failure opening /dev/md127
```
---
 mdopen.c | 4 ++--
 util.c   | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/mdopen.c b/mdopen.c
index 245be537..c8e5cb9d 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -444,8 +444,8 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
 	}
 	mdfd = open_dev_excl(devnm);
 	if (mdfd < 0)
-		pr_err("unexpected failure opening %s\n",
-			devname);
+		pr_err("unexpected failure opening %s: %s\n",
+			devname, strerror(errno));
 	return mdfd;
 }

diff --git a/util.c b/util.c
index cc94f96e..7c8c0bb1 100644
--- a/util.c
+++ b/util.c
@@ -1088,8 +1088,9 @@ int open_dev_excl(char *devnm)
 	long delay = 1000;

 	sprintf(buf, "%d:%d", major(devid), minor(devid));
+	int fd = -1;
 	for (i = 0; i < 25; i++) {
-		int fd = dev_open(buf, flags|O_EXCL);
+		fd = dev_open(buf, flags|O_EXCL);
 		if (fd >= 0)
 			return fd;
 		if (errno == EACCES && flags == O_RDWR) {
@@ -1102,7 +1103,7 @@ int open_dev_excl(char *devnm)
 		if (delay < 200000)
 			delay *= 2;
 	}
-	return -1;
+	return fd;
 }

 int same_dev(char *one, char *two)
--
2.35.3


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

end of thread, other threads:[~2022-04-26 14:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-25 13:27 [PATCH] Print concrete error when creating mddev Marius Kittler
2022-04-26 14:38 ` Mariusz Tkaczyk

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