Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d118394d authored by Igor Murashkin's avatar Igor Murashkin Committed by Android (Google) Code Review
Browse files

Merge "Properly handle cases of multiple inotify events" into jb-mr2-dev

parents 6b5de1cd f75ea8d0
Loading
Loading
Loading
Loading
+44 −39
Original line number Diff line number Diff line
@@ -223,12 +223,14 @@ int usb_host_read_event(struct usb_host_context *context)
    char event_buf[512];
    char path[100];
    int i, ret, done = 0;
    int j, event_size;
    int offset = 0;
    int wd;

    ret = read(context->fd, event_buf, sizeof(event_buf));
    if (ret >= (int)sizeof(struct inotify_event)) {
        event = (struct inotify_event *)event_buf;
        while (offset < ret) {
            event = (struct inotify_event*)&event_buf[offset];
            done = 0;
            wd = event->wd;
            if (wd == context->wdd) {
                if ((event->mask & IN_CREATE) && !strcmp(event->name, "bus")) {
@@ -274,6 +276,9 @@ int usb_host_read_event(struct usb_host_context *context)
                    }
                }
            }

            offset += sizeof(struct inotify_event) + event->len;
        }
    }

    return done;