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

Commit f75ea8d0 authored by Ziv Hendel's avatar Ziv Hendel Committed by Adam Hampson
Browse files

Properly handle cases of multiple inotify events



Bug: 8469799
Change-Id: Ie10242dd05becd142cc84651d5e5795e4c02270d
Signed-off-by: default avatarIgor Murashkin <iam@google.com>
Signed-off-by: default avatarAdam Hampson <ahampson@google.com>
parent fb39c0d1
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;