Skip to contentSkip to conversation

init/do_mounts: Add create_dev() failure log

PATCH In review Vishnu Pratap Singh 3 participants 7 messages May 25, 2015 – May 27, 2015 1 message not in the archive VFS

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 init/do_mounts: Add create_dev() failure log

In reply to a message not in the archive

if create_dev() function fails to create the root mount device (/dev/root), then it goes to panic as root device not found but there is no check/log present in case of failure, So i have added the log in case it fails to create the root device. It will help in debugging.

---
 init/do_mounts.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
init/do_mounts.c +2 -1
index 8369ffa..a68aaf6 100644
@@ -532,7 +532,8 @@ void __init mount_root(void)
 	}
 #endif
 #ifdef CONFIG_BLOCK
-	create_dev("/dev/root", ROOT_DEV);
+	if(create_dev("/dev/root", ROOT_DEV) < 0)
+		printk(KERN_ERR "Failed to create %s device !!\n", "/dev/root");
 	mount_block_root("/dev/root", root_mountflags);
 #endif
 }
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#2 lore raw
Quoted 6 lines · Vishnu Pratap Singh

if create_dev() function fails to create the root mount device (/dev/root), then it goes to panic as root device not found but there is no check/log present in case of failure, So i have added the log in case it fails to create the root device. It will help in debugging.

Quoted 9 lines
---
 init/do_mounts.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
init/do_mounts.c +0 -0
index 8369ffa..a68aaf6 100644

init/do_mounts.c void __init mount_root(void) · line 536

Quoted 6 lines
init/do_mounts.c +2 -1
@@ -532,7 +532,8 @@ void __init mount_root(void)
 	}
 #endif
 #ifdef CONFIG_BLOCK
-	create_dev("/dev/root", ROOT_DEV);
+	if(create_dev("/dev/root", ROOT_DEV) < 0)
+		printk(KERN_ERR "Failed to create %s device !!\n", "/dev/root");

But please make it "if (" and " !!" -> "!"

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw

PATCH 1/1 init/do_mounts: Add create_dev() failure log

In reply to Vishnu Pratap Singh

if create_dev() function fails to create the root mount device (/dev/root), then it goes to panic as root device not found but there is no check/log present in case of failure, So i have added the log in case it fails to create the root device. It will help in debugging.

---
 init/do_mounts.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
init/do_mounts.c +2 -1
index 8369ffa..a68aaf6 100644
@@ -532,7 +532,8 @@ void __init mount_root(void)
 	}
 #endif
 #ifdef CONFIG_BLOCK
-	create_dev("/dev/root", ROOT_DEV);
+	if(create_dev("/dev/root", ROOT_DEV) < 0)
+		printk(KERN_ERR "Failed to create %s device !!\n", "/dev/root");
 	mount_block_root("/dev/root", root_mountflags);
 #endif
 }
Signature · 1 line
1.7.9.5
#4 lore raw
Quoted 15 lines · Vishnu Pratap Singh

if create_dev() function fails to create the root mount device (/dev/root), then it goes to panic as root device not found but there is no check/log present in case of failure, So i have added the log in case it fails to create the root device. It will help in debugging.

---
 init/do_mounts.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
init/do_mounts.c +0 -0
index 8369ffa..a68aaf6 100644

init/do_mounts.c void __init mount_root(void) · line 536

Quoted 6 lines
init/do_mounts.c +2 -1
@@ -532,7 +532,8 @@ void __init mount_root(void)
 	}
 #endif
 #ifdef CONFIG_BLOCK
-	create_dev("/dev/root", ROOT_DEV);
+	if(create_dev("/dev/root", ROOT_DEV) < 0)
+		printk(KERN_ERR "Failed to create %s device !!\n", "/dev/root");

No change, AFAICT. Please fix stuff I pointed in the email, and you can get my acked-by ;-).
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw

PATCH v2 1/1 init/do_mounts: Add create_dev() failure log

In reply to Vishnu Pratap Singh

if create_dev() function fails to create the root mount device (/dev/root), then it goes to panic as root device not found but there is no check/log present in case of failure, So i have added the log in case it fails to create the root device. It will help in debugging.

---
As per the review comment.

 init/do_mounts.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
init/do_mounts.c +2 -1
index 8369ffa..f742250 100644
@@ -532,7 +532,8 @@ void __init mount_root(void)
 	}
 #endif
 #ifdef CONFIG_BLOCK
-	create_dev("/dev/root", ROOT_DEV);
+	if (create_dev("/dev/root", ROOT_DEV) < 0)
+		pr_err("Failed to create %s device !\n", "/dev/root");
 	mount_block_root("/dev/root", root_mountflags);
 #endif
 }
Signature · 1 line
1.7.9.5
Acked-by on v2 1/1
#6 lore raw
Quoted 6 lines · Vishnu Pratap Singh

if create_dev() function fails to create the root mount device (/dev/root), then it goes to panic as root device not found but there is no check/log present in case of failure, So i have added the log in case it fails to create the root device. It will help in debugging.

Quoted 20 lines

---
As per the review comment.

 init/do_mounts.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
init/do_mounts.c +2 -1
index 8369ffa..f742250 100644
@@ -532,7 +532,8 @@ void __init mount_root(void)
 	}
 #endif
 #ifdef CONFIG_BLOCK
-	create_dev("/dev/root", ROOT_DEV);
+	if (create_dev("/dev/root", ROOT_DEV) < 0)
+		pr_err("Failed to create %s device !\n", "/dev/root");
 	mount_block_root("/dev/root", root_mountflags);
 #endif
 }
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#7 lore raw
In reply to Vishnu Pratap Singh
Quoted 10 lines · On Tue, 26 May 2015 11:56:58 +0530 Vishnu Pratap Singh <[email protected]>…

if create_dev() function fails to create the root mount device (/dev/root), then it goes to panic as root device not found but there is no check/log present in case of failure, So i have added the log in case it fails to create the root device. It will help in debugging.

...

init/do_mounts.c void __init mount_root(void) · line 536

Quoted 6 lines
init/do_mounts.c +2 -1
@@ -532,7 +532,8 @@ void __init mount_root(void)
 	}
 #endif
 #ifdef CONFIG_BLOCK
-	create_dev("/dev/root", ROOT_DEV);
+	if (create_dev("/dev/root", ROOT_DEV) < 0)
+		pr_err("Failed to create %s device !\n", "/dev/root");

That's a pretty strange use of printk.

And KERN_EMERG seems more appropriate when this happens.

And we may as well let the poor user know why the mknod failed.

This?

init/do_mounts.c renamed from init/do_mounts.c~init-do_mounts-add-create_dev-failure-log-fix +7 -3
@@ -533,9 +533,13 @@ void __init mount_root(void)
 	}
 #endif
 #ifdef CONFIG_BLOCK
-	if (create_dev("/dev/root", ROOT_DEV) < 0)
-		pr_err("Failed to create %s device !\n", "/dev/root");
-	mount_block_root("/dev/root", root_mountflags);
+	{
+		int err = create_dev("/dev/root", ROOT_DEV);
+
+		if (err < 0)
+			pr_emerg("Failed to create /dev/root: %d\n", err);
+		mount_block_root("/dev/root", root_mountflags);
+	}
 #endif
 }
 

_