This patch adds support for automounting CDROM on insert event.

Signed-off-by: Phileas Fogg <[email protected]>
---

--- a/discover/event.h    2012-07-28 22:40:08.093065557 +0200
+++ b/discover/event.h    2012-07-28 22:40:24.293066501 +0200
@@ -9,6 +9,7 @@
 enum event_action {
     EVENT_ACTION_ADD = 20,
     EVENT_ACTION_REMOVE,
+    EVENT_ACTION_CHANGE,
 };

 struct event {
--- a/discover/event.c    2012-07-28 22:39:12.509728991 +0200
+++ b/discover/event.c    2012-07-28 22:39:57.603064946 +0200
@@ -42,6 +42,8 @@
         *action = EVENT_ACTION_ADD;
     else if (streq(buf, "remove"))
         *action = EVENT_ACTION_REMOVE;
+    else if (streq(buf, "change"))
+        *action = EVENT_ACTION_CHANGE;
     else {
         pb_log("%s: unknown action: %s\n", __func__, buf);
         return -1;
--- a/discover/udev.c    2012-07-28 22:41:14.429736083 +0200
+++ b/discover/udev.c    2012-07-28 22:42:52.393075115 +0200
@@ -35,7 +35,12 @@
     };
     int i;

-    action = event->action == EVENT_ACTION_ADD ? "add" : "remove";
+    if (event->action == EVENT_ACTION_ADD)
+        action = "add";
+    else if (event->action == EVENT_ACTION_REMOVE)
+        action = "remove";
+    else
+        action = "change";

     pb_log("udev %s event:\n", action);
     pb_log("\tdevice: %s\n", event->device);
--- a/discover/device-handler.c    2012-07-28 22:43:10.363076160 +0200
+++ b/discover/device-handler.c    2012-07-28 23:01:50.729808008 +0200
@@ -349,6 +349,24 @@
     return 0;
 }

+static int handle_change_udev_event(struct device_handler *handler,
+        struct event *event)
+{
+    const char *disk_media_change;
+    const char *disk_eject_request;
+
+    disk_media_change = event_get_param(event, "DISK_MEDIA_CHANGE");
+    if (disk_media_change) {
+        return handle_add_udev_event(handler, event);
+    } else {
+        disk_eject_request = event_get_param(event, "DISK_EJECT_REQUEST");
+        if (disk_eject_request)
+            return handle_remove_udev_event(handler, event);
+    }
+
+    return 0;
+}
+
 static int handle_add_user_event(struct device_handler *handler,
         struct event *event)
 {
@@ -409,6 +427,9 @@
         case EVENT_ACTION_REMOVE:
             rc = handle_remove_udev_event(handler, event);
             break;
+        case EVENT_ACTION_CHANGE:
+            rc = handle_change_udev_event(handler, event);
+            break;
         default:
             pb_log("%s unknown action: %d\n", __func__,
                 event->action);

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to