qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Gerd Hoffmann
Subject: Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring
Date: Fri, 13 Nov 2015 09:08:23 +0100

  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 that comment is that add a watchpoint soon enough but it could be
> possible that by the time the watch is added, a few files might have already
> been copied and will not generate events.

The readdir (in usb_mtp_object_readdir) will find them then.

While looking at the code:  I think there is no need to add the watch
right away.  We only read the directory when the guest actually requests
it.  Watching the directories we actually have scanned due to the guest
requesting it should be enough.

So I think adding the inotify watch in usb_mtp_object_readdir should
work just fine.  And the watch should be added before readdir to make
sure we don't miss anything.

File system events then can happen at three points in time:  (a) before
we add the watch, (b) after we add the watch, and before readdir, and
(c) after readdir.

   (a) we will see these files in the readdir call.
   (b) we will see these files in the readdir call
       *and* receive inotify events for them.
   (c) we will only get events for them.

The (b) events look bogous at first glance (create events for files you
already have in the list, but also delete events for files you don't
have in your list).

cheers,
  Gerd





reply via email to

[Prev in Thread] Current Thread [Next in Thread]