]> git.ozlabs.org Git - petitboot/commitdiff
pb-discover: Ignore ram, loop and no-name devices
authorGeoff Levand <geoff@infradead.org>
Tue, 27 Mar 2012 03:18:32 +0000 (20:18 -0700)
committerGeoff Levand <geoff@infradead.org>
Tue, 27 Mar 2012 03:18:32 +0000 (20:18 -0700)
Signed-off-by: Geoff Levand <geoff@infradead.org>
discover/device-handler.c
discover/udev.c

index 0783181147edab9f0f8c6b7de9fa2ea35c516cb8..12bc40f7283a83bf24dac77e3e4f0f353deb55af 100644 (file)
@@ -294,11 +294,7 @@ static int handle_add_udev_event(struct device_handler *handler,
        ctx->id = talloc_strdup(ctx, event->device);
 
        devname = event_get_param(ctx->event, "DEVNAME");
-       if (!devname) {
-               pb_log("no devname for %s?\n", event->device);
-               return 0;
-       }
-
+       assert(devname);
        ctx->device_path = talloc_strdup(ctx, devname);
 
        rc = mount_device(ctx);
index bd7c6bd1abb28f2038fb828e2253fc665632f661..a5d9e03006dd2af346a1418296526a47aece88ca 100644 (file)
@@ -1,17 +1,18 @@
 
 #define _GNU_SOURCE
 
-#include <stdlib.h>
+#include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/types.h>
 #include <sys/un.h>
 
+#include <log/log.h>
 #include <talloc/talloc.h>
 #include <waiter/waiter.h>
-#include <log/log.h>
 
 #include "event.h"
 #include "udev.h"
@@ -54,6 +55,7 @@ static void udev_handle_message(struct udev *udev, char *buf, int len)
 {
        int result;
        struct event *event;
+       const char *devpath;
 
        event = talloc(udev, struct event);
        event->type = EVENT_TYPE_UDEV;
@@ -66,7 +68,17 @@ static void udev_handle_message(struct udev *udev, char *buf, int len)
                return;
 
        udev_print_event(event);
-       device_handler_event(udev->handler, event);
+
+       /* Ignore ram, loop, and devices with no DEVNAME. */
+
+       devpath = event_get_param(event, "DEVPATH");
+
+       if (event_get_param(event, "DEVNAME")
+               && !strstr(devpath, "virtual/block/loop")
+               && !strstr(devpath, "virtual/block/ram")) {
+               device_handler_event(udev->handler, event);
+       }
+
        talloc_free(event);
 
        return;