bump Linux 3.18 trunk revision to 47027; bump Linux 3.18 kernel version to 3.18.21
[ps3openwrt_patches.git] / 050-petitboot-udev-change-event.diff
blob4961940c0d71ce7e7306771b6ad471c745c8a19a
1 --- a/discover/event.h 2012-07-28 22:40:08.093065557 +0200
2 +++ b/discover/event.h 2012-07-28 22:40:24.293066501 +0200
3 @@ -9,6 +9,7 @@
4 enum event_action {
5 EVENT_ACTION_ADD = 20,
6 EVENT_ACTION_REMOVE,
7 + EVENT_ACTION_CHANGE,
8 };
10 struct event {
11 --- a/discover/event.c 2012-07-28 22:39:12.509728991 +0200
12 +++ b/discover/event.c 2012-07-28 22:39:57.603064946 +0200
13 @@ -42,6 +42,8 @@
14 *action = EVENT_ACTION_ADD;
15 else if (streq(buf, "remove"))
16 *action = EVENT_ACTION_REMOVE;
17 + else if (streq(buf, "change"))
18 + *action = EVENT_ACTION_CHANGE;
19 else {
20 pb_log("%s: unknown action: %s\n", __func__, buf);
21 return -1;
22 --- a/discover/udev.c 2012-07-28 22:41:14.429736083 +0200
23 +++ b/discover/udev.c 2012-07-28 22:42:52.393075115 +0200
24 @@ -35,7 +35,12 @@
26 int i;
28 - action = event->action == EVENT_ACTION_ADD ? "add" : "remove";
29 + if (event->action == EVENT_ACTION_ADD)
30 + action = "add";
31 + else if (event->action == EVENT_ACTION_REMOVE)
32 + action = "remove";
33 + else
34 + action = "change";
36 pb_log("udev %s event:\n", action);
37 pb_log("\tdevice: %s\n", event->device);
38 --- a/discover/device-handler.c 2012-07-28 22:43:10.363076160 +0200
39 +++ b/discover/device-handler.c 2012-07-28 23:01:50.729808008 +0200
40 @@ -349,6 +349,24 @@
41 return 0;
44 +static int handle_change_udev_event(struct device_handler *handler,
45 + struct event *event)
47 + const char *disk_media_change;
48 + const char *disk_eject_request;
50 + disk_media_change = event_get_param(event, "DISK_MEDIA_CHANGE");
51 + if (disk_media_change) {
52 + return handle_add_udev_event(handler, event);
53 + } else {
54 + disk_eject_request = event_get_param(event, "DISK_EJECT_REQUEST");
55 + if (disk_eject_request)
56 + return handle_remove_udev_event(handler, event);
57 + }
59 + return 0;
62 static int handle_add_user_event(struct device_handler *handler,
63 struct event *event)
65 @@ -409,6 +427,9 @@
66 case EVENT_ACTION_REMOVE:
67 rc = handle_remove_udev_event(handler, event);
68 break;
69 + case EVENT_ACTION_CHANGE:
70 + rc = handle_change_udev_event(handler, event);
71 + break;
72 default:
73 pb_log("%s unknown action: %d\n", __func__,
74 event->action);