discover/discover-server: Restrict clients based on uid
[petitboot] / discover / parser-utils.c
1
2 #include <string.h>
3
4 #include <log/log.h>
5 #include <talloc/talloc.h>
6
7 #include "types/types.h"
8 #include "event.h"
9 #include "udev.h"
10 #include "device-handler.h"
11 #include "parser-utils.h"
12
13 const char *generic_icon_file(enum generic_icon_type type)
14 {
15         switch (type) {
16         case ICON_TYPE_DISK:
17                 return artwork_pathname("hdd.png");
18         case ICON_TYPE_USB:
19                 return artwork_pathname("usbpen.png");
20         case ICON_TYPE_OPTICAL:
21                 return artwork_pathname("cdrom.png");
22         case ICON_TYPE_NETWORK:
23         case ICON_TYPE_UNKNOWN:
24                 break;
25         }
26         return artwork_pathname("hdd.png");
27 }
28
29 enum generic_icon_type guess_device_type(struct discover_context *ctx)
30 {
31         struct event *event;
32         const char *type, *bus;
33
34         event = ctx->event;
35
36         type = event_get_param(event, "ID_TYPE");
37         bus = event_get_param(event, "ID_BUS");
38
39         if (type && streq(type, "cd"))
40                 return ICON_TYPE_OPTICAL;
41         if (!bus)
42                 return ICON_TYPE_UNKNOWN;
43         if (streq(bus, "usb"))
44                 return ICON_TYPE_USB;
45         if (streq(bus, "ata") || streq(bus, "scsi"))
46                 return ICON_TYPE_DISK;
47         return ICON_TYPE_UNKNOWN;
48 }