return NULL;
}
+static enum device_type event_device_type(struct device *device,
+ struct event *event)
+{
+ const char *param;
+
+ param = event_get_param(event, "type");
+ if (!param) {
+ pb_log("%s: empty type\n", device->id);
+ return DEVICE_TYPE_UNKNOWN;
+ }
+
+ if (!strcmp(param, "disk") || !strcmp(param, "partition"))
+ return DEVICE_TYPE_DISK;
+
+ if (!strcmp(param, "net"))
+ return DEVICE_TYPE_NETWORK;
+
+ pb_log("%s: unknown type '%s'\n", device->id, param);
+ return DEVICE_TYPE_UNKNOWN;
+}
+
static struct discover_device *discover_device_create(
struct device_handler *handler,
struct discover_context *ctx,
dev->device_path = talloc_strdup(dev, devname);
dev->device->id = talloc_strdup(dev, event->device);
+ dev->device->type = event_device_type(dev->device, event);
talloc_set_destructor(dev, destroy_device);
event->n_params = 0;
event->params = NULL;
event_set_param(event, "DEVNAME", devnode);
+ event_set_param(event, "type", devtype);
udev_setup_event_params(dev, event);
#include "ui/common/discover-client.h"
+static const char *device_type_string(enum device_type type)
+{
+ switch (type) {
+ case DEVICE_TYPE_DISK:
+ return "disk";
+ case DEVICE_TYPE_NETWORK:
+ return "network";
+ case DEVICE_TYPE_OPTICAL:
+ return "optical";
+ case DEVICE_TYPE_UNKNOWN:
+ return "unknown";
+ }
+ return "invalid";
+}
+
static int print_device_add(struct device *device,
void __attribute__((unused)) *arg)
{
printf("new device:\n");
printf("\tid: %s\n", device->id);
+ printf("\ttype: %s\n", device_type_string(device->type));
printf("\tname: %s\n", device->name);
printf("\tdesc: %s\n", device->description);
printf("\ticon: %s\n", device->icon_file);