Discussion:
[PATCH] mdev: browse /sys/block only if directory exists
(too old to reply)
Gaël PORTAY
2017-08-26 23:19:18 UTC
Permalink
Raw Message
When the kernel block layer is disabled, mdev reports terminates in
error because it cannot browse /sys/block.

It reports the following message.

mdev: /sys/block: No such file or directory
---
toys/pending/mdev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/toys/pending/mdev.c b/toys/pending/mdev.c
index a270e52..cab56d3 100644
--- a/toys/pending/mdev.c
+++ b/toys/pending/mdev.c
@@ -223,10 +223,12 @@ static int callback(struct dirtree *node)
void mdev_main(void)
{
// Handle -s
+ struct stat st;

if (toys.optflags) {
dirtree_read("/sys/class", callback);
- dirtree_read("/sys/block", callback);
+ if (!stat("/sys/block", &st))
+ dirtree_read("/sys/block", callback);
} else { // hotplug support
make_device(NULL);
}
--
2.13.2
Loading...