From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxDYy-0006yv-Nx for qemu-devel@nongnu.org; Fri, 13 Nov 2015 07:34:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxDYt-0005U9-L8 for qemu-devel@nongnu.org; Fri, 13 Nov 2015 07:34:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47130) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxDYt-0005Tv-GQ for qemu-devel@nongnu.org; Fri, 13 Nov 2015 07:34:39 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 5FE09C0032ED for ; Fri, 13 Nov 2015 12:34:38 +0000 (UTC) Message-ID: <1447418075.1400.110.camel@redhat.com> From: Gerd Hoffmann Date: Fri, 13 Nov 2015 13:34:35 +0100 In-Reply-To: <1447196299-16091-4-git-send-email-bsd@redhat.com> References: <1447196299-16091-1-git-send-email-bsd@redhat.com> <1447196299-16091-4-git-send-email-bsd@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 3/4] usb-mtp: Add support for inotify based file monitoring List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bandan Das Cc: qemu-devel@nongnu.org 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