discover: Change parsers to explicitly request configuration files
[petitboot] / discover / udev.c
index e996e221228804d6a16a7a41aeb25463198800a8..48ab745b4f371ac410048dc3ab7b93f9dc3ff4fb 100644 (file)
 #include "pb-discover.h"
 #include "device-handler.h"
 
-#if defined(DEBUG)
-#define DBG(fmt, args...) pb_log("DBG: " fmt, ## args)
-#define DBGS(fmt, args...) \
-       pb_log("DBG:%s:%d: " fmt, __func__, __LINE__, ## args)
-#else
-#define DBG(fmt, args...)
-#define DBGS(fmt, args...)
-#endif
-
 struct pb_udev {
        struct udev *udev;
        struct udev_monitor *monitor;
@@ -73,6 +64,7 @@ static int udev_handle_dev_add(struct pb_udev *udev, struct udev_device *dev)
        const char *serial;
        const char *path;
        const char *name;
+       const char *prop;
 
        name = udev_device_get_sysname(dev);
        if (!name) {
@@ -114,13 +106,17 @@ static int udev_handle_dev_add(struct pb_udev *udev, struct udev_device *dev)
        ddev = discover_device_create(udev->handler, name);
 
        ddev->device_path = udev_device_get_devnode(dev);
-       ddev->uuid = udev_device_get_property_value(dev, "ID_FS_UUID");
-       ddev->label = udev_device_get_property_value(dev, "ID_FS_LABEL");
+       prop = udev_device_get_property_value(dev, "ID_FS_UUID");
+       if (prop)
+               ddev->uuid = talloc_strdup(ddev, prop);
+       prop = udev_device_get_property_value(dev, "ID_FS_LABEL");
+       if (prop)
+               ddev->label = talloc_strdup(ddev, prop);
        ddev->device->type = DEVICE_TYPE_DISK;
 
        udev_setup_device_params(dev, ddev);
 
-       device_handler_discover(udev->handler, ddev, CONF_METHOD_LOCAL_FILE);
+       device_handler_discover(udev->handler, ddev);
 
        return 0;
 }
@@ -318,7 +314,7 @@ struct pb_udev *udev_init(struct waitset *waitset,
        waiter_register_io(waitset, udev_monitor_get_fd(udev->monitor), WAIT_IN,
                udev_process, udev->monitor);
 
-       pb_log("%s: waiting on udev\n", __func__);
+       pb_debug("%s: waiting on udev\n", __func__);
 
        return udev;