Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-13 Thread Gerd Hoffmann
Hi, > Maybe I am missing something but what if the watch on dir was > added by qemu _after_ the file (say file1) was copied to it. > Then, the kernel would generate events for file2, file3 and so on but > never a CREATE event for file1. Isn't that a possibility ? Yes. > So, what I mean > by th

Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-12 Thread Bandan Das
Gerd Hoffmann writes: > On Mo, 2015-11-09 at 18:12 -0500, Bandan Das wrote: >> Gerd Hoffmann writes: >> >> > On Di, 2015-11-03 at 19:00 -0500, Bandan Das wrote: >> >> +/* Add a new watch asap so as to not lose events >> >> */ >> > >> > This comment sounds like there is a rac

Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-12 Thread Gerd Hoffmann
On Mo, 2015-11-09 at 18:12 -0500, Bandan Das wrote: > Gerd Hoffmann writes: > > > On Di, 2015-11-03 at 19:00 -0500, Bandan Das wrote: > >> +/* Add a new watch asap so as to not lose events > >> */ > > > > This comment sounds like there is a race ("asap"). There isn't one, > >

Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-09 Thread Bandan Das
Bandan Das writes: > Gerd Hoffmann writes: > >> On Di, 2015-11-03 at 19:00 -0500, Bandan Das wrote: >>> +/* Add a new watch asap so as to not lose events >>> */ >> >> This comment sounds like there is a race ("asap"). There isn't one, >> correct ordering (adding the watch be

Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-09 Thread Bandan Das
Gerd Hoffmann writes: > On Di, 2015-11-03 at 19:00 -0500, Bandan Das wrote: >> +case IN_DELETE: >> +/* >> + * The kernel issues a IN_IGNORED event >> + * when a dir containing a watchpoint is >> + * deleted >> +

Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-09 Thread Bandan Das
Gerd Hoffmann writes: > On Di, 2015-11-03 at 19:00 -0500, Bandan Das wrote: >> +/* Add a new watch asap so as to not lose events >> */ > > This comment sounds like there is a race ("asap"). There isn't one, > correct ordering (adding the watch before reading the directory) is

Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-05 Thread Bandan Das
Gerd Hoffmann writes: >> +#include > > What happens on non-linux systems? > > I guess we need some #ifdefs to not break the build there, or enable mtp > only for CONFIG_LINUX=y instead of CONFIG_POSIX=y. Oh, I had the ifdefs but somehow I confused myself by thinking CONFIG_POSIX is enough not t

Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-05 Thread Gerd Hoffmann
On Di, 2015-11-03 at 19:00 -0500, Bandan Das wrote: > +case IN_DELETE: > +/* > + * The kernel issues a IN_IGNORED event > + * when a dir containing a watchpoint is > + * deleted > + */ Wrong place for the c

Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-05 Thread Gerd Hoffmann
On Di, 2015-11-03 at 19:00 -0500, Bandan Das wrote: > +/* Add a new watch asap so as to not lose events > */ This comment sounds like there is a race ("asap"). There isn't one, correct ordering (adding the watch before reading the directory) is enough to make sure you don't mi

Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-05 Thread Gerd Hoffmann
> +#include What happens on non-linux systems? I guess we need some #ifdefs to not break the build there, or enable mtp only for CONFIG_LINUX=y instead of CONFIG_POSIX=y. > +enum inotify_event_type { > +CREATE = 1, > +DELETE = 2, > +MODIFY = 3, > +}; Patch #3 removes this, I'd sugg

[Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-03 Thread Bandan Das
For now, we use inotify watches to track only a small number of events, namely, add, delete and modify. Note that for delete, the kernel already deactivates the watch for us and we just need to take care of modifying our internal state. Suggested-by: Gerd Hoffman Signed-off-by: Bandan Das --- h