- int param_len, name_len, value_len;
- struct param *param;
- char *sep;
-
- for (; len > 0; len -= param_len + 1, buf += param_len + 1) {
-
- /* find the length of the whole parameter */
- param_len = strnlen(buf, len);
- if (!param_len) {
- /* multiple NULs? skip over */
- param_len = 1;
- continue;
+ struct discover_device *ddev;
+ unsigned int i = 0;
+ const char *typestr;
+ const char *uuid;
+ const char *path;
+ const char *node;
+ const char *prop;
+ const char *type;
+ const char *devname;
+ const char *ignored_types[] = {
+ "linux_raid_member",
+ "swap",
+ "LVM2_member",
+ NULL,
+ };
+ bool cdrom, usb;
+
+ typestr = udev_device_get_devtype(dev);
+ if (!typestr) {
+ pb_debug("udev_device_get_devtype failed\n");
+ return -1;
+ }
+
+ if (!(!strcmp(typestr, "disk") || !strcmp(typestr, "partition"))) {
+ pb_log("SKIP %s: invalid type %s\n", name, typestr);
+ return 0;
+ }
+
+ node = udev_device_get_devnode(dev);
+ path = udev_device_get_devpath(dev);
+ if (path && strstr(path, "virtual/block/loop")) {
+ pb_log("SKIP: %s: ignored (path=%s)\n", name, path);
+ return 0;
+ }
+
+ if (path && strstr(path, "virtual/block/ram")) {
+ device_handler_add_ramdisk(udev->handler, node);
+ return 0;
+ }
+
+ cdrom = node && !!udev_device_get_property_value(dev, "ID_CDROM");
+ if (cdrom) {
+ /* CDROMs require a little initialisation, to get
+ * petitboot-compatible tray behaviour */
+ cdrom_init(node);
+ if (!cdrom_media_present(node)) {
+ pb_log("SKIP: %s: no media present\n", name);
+ return 0;