[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 3/4] usb-mtp: Add support for inotify based f
From: |
Gerd Hoffmann |
Subject: |
Re: [Qemu-devel] [PATCH v2 3/4] usb-mtp: Add support for inotify based file monitoring |
Date: |
Fri, 13 Nov 2015 13:34:35 +0100 |
Hi,
> + switch (mask) {
> + case IN_CREATE:
> + if (event->mask & IN_ISDIR) {
> + /*
> + * Add the watchpoint first so we
> + * don't miss events in this subdir
> + */
> + name = g_strndup(event->name, event->len);
> + path = g_strdup_printf("%s/%s", parent->path, name);
> +
> + watchfd = usb_mtp_add_watch(s->inotifyfd, path);
> + g_free(path);
> + g_free(name);
> +
> + if (watchfd == -1) {
> + continue;
> + }
> + }
So, to follow up my mail from today in the morning:
I think this is not needed here ...
> usb_mtp_object_readdir(s, o);
> + if (usb_mtp_inotify_mon(s, o)) {
> + fprintf(stderr, "usb-mtp: adding watch for %s failed\n",
> o->path);
> + }
... but here we have to add the watch first, then read the directory.
When reading the directory first we'll miss new files which are added
after readdir() but before add_watch().
cheers,
Gerd