* Re: inotify?
@ 2022-10-06 16:29 Kevin Connor Arpe
2022-10-06 19:58 ` inotify? Ken Brown
0 siblings, 1 reply; 7+ messages in thread
From: Kevin Connor Arpe @ 2022-10-06 16:29 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 2585 bytes --]
Hi,
Sorry, I am a GMail user, so I am unable to reply to the original email
from Eric Blake eblake@redhat.com on Thu May 3 14:03:00 GMT 2018:
https://cygwin.com/pipermail/cygwin/2018-May/237069.html
Eric wrote: <<And patches to make Cygwin support inotify_init() and
friends implemented
on top of the Windows native API are certainly welcome.>>
First, please correct me if Linux-style inotify is already supported in
Cygwin. As I understand, it is not. To be clear, when I say "inotify", I
mean this Linux kernel API:
https://man7.org/linux/man-pages/man7/inotify.7.html
Second, I am interested in exploring this feature as a personal project.
After some research, I found two different solutions on Windows:
1. FindNextChangeNotification() and friends explained here:
https://learn.microsoft.com/en-us/windows/win32/fileio/obtaining-directory-change-notifications
2. (NTFS) Change Journals explained here:
https://learn.microsoft.com/en-us/windows/win32/fileio/change-journals
There is some discussion about both approaches on StackOverflow.com here:
https://stackoverflow.com/questions/3517460/is-there-anything-like-inotify-on-windows
In short, it sounds like #1 (above) is unreliable and can drop/miss file
system events if too fast and/or the kernel notification queue is
full/overloaded.
However, #2 (above) requires journalling to be enabled on an NTFS volume.
And, it sounds like this feature is *only* available on NTFS volumes.
(FAT/32 & friends would need to use #1.)
My thoughts & concerns:
- #1 might be easier to program but if dropped events are a reality,
then ... meh, not such a great feature!
- #2 is restricted to NTFS, but sounds very reliable ("rock solid", one
person said). However, journalling needs to be enabled. I guess the
inotify API can just return an error if journaling is disabled for an NTFS
volume. And, I see two solutions for non-NTFS volumes: inotify API returns
error, or fall-back to #2.
More: It sounds like journaling might be disabled by default.
-
https://stackoverflow.com/questions/27184283/is-the-usn-journal-disabled-by-default
- https://devblogs.microsoft.com/oldnewthing/20130101-00/?p=5673
And enabling probably requires local admin access. Maybe some kind of flag
can choose #1 or #2?
I would appreciate it if people could share their thoughts and advice.
The Linux inotify API is an excellent feature. I have used it a few times
with great success. It would be nice to have this feature on Cygwin.
Kind regards,
Kevin ARPE
Tokyo, Japan
https://github.com/kevinarpe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: inotify?
2022-10-06 16:29 inotify? Kevin Connor Arpe
@ 2022-10-06 19:58 ` Ken Brown
2022-10-23 12:13 ` inotify? Kevin Connor Arpe
0 siblings, 1 reply; 7+ messages in thread
From: Ken Brown @ 2022-10-06 19:58 UTC (permalink / raw)
To: cygwin
On 10/6/2022 12:29 PM, Kevin Connor Arpe wrote:
> Hi,
>
> Sorry, I am a GMail user, so I am unable to reply to the original email
> from Eric Blake eblake@redhat.com on Thu May 3 14:03:00 GMT 2018:
> https://cygwin.com/pipermail/cygwin/2018-May/237069.html
>
> Eric wrote: <<And patches to make Cygwin support inotify_init() and
> friends implemented
> on top of the Windows native API are certainly welcome.>>
>
> First, please correct me if Linux-style inotify is already supported in
> Cygwin. As I understand, it is not.
That's correct.
[...]
> I would appreciate it if people could share their thoughts and advice.
I don't know if this will help, but Emacs has a filenotify feature which, on
Linux, is based on inotify. In the native Windows build of Emacs, filenotify is
implemented in the file src/w32notify.c in the Emacs source tree. Looking at
how this is done might give you some ideas.
> The Linux inotify API is an excellent feature. I have used it a few times
> with great success. It would be nice to have this feature on Cygwin.
Agreed. Good luck.
Ken
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: inotify?
2022-10-06 19:58 ` inotify? Ken Brown
@ 2022-10-23 12:13 ` Kevin Connor Arpe
0 siblings, 0 replies; 7+ messages in thread
From: Kevin Connor Arpe @ 2022-10-23 12:13 UTC (permalink / raw)
To: Ken Brown; +Cc: cygwin
[-- Attachment #1: Type: text/plain, Size: 2476 bytes --]
Ken,
Sorry for my late reply. Your hint to read the Emacs source code was
incredibly helpful.
This line:
https://github.com/jwiegley/emacs-release/blob/master/src/w32notify.c#L255
calls ReadDirectoryChangesW().
Reading the Win32 API docs very closely, I discovered that I can pass a
large(r) buffer to this function. This can greatly reduce the chance of
lost events.
(Oddly, in *all* code samples that I found, all of them used relatively
small buffers. Even the Emacs code uses a tiny 16kb buffer.)
I wrote a test driver for ReadDirectoryChangesW() to better understand
the API.
I did some analysis to map the Linux API to Win32 capabilities. As
expected, there isn't a perfect 1:1 match, but there is significant overlap
-- enough (IMHO) to make inotify useful on Cygwin.
I also started reading the Cygwin source code. It seems possible to impl
inotify functionality by creating a new subclass of fhandler_base, e.g.,
fhandler_inotify.
I will reply to this thread when/if I have questions in the future.
Thanks,
Arpe
On Fri, Oct 7, 2022 at 4:59 AM Ken Brown <kbrown@cornell.edu> wrote:
> On 10/6/2022 12:29 PM, Kevin Connor Arpe wrote:
> > Hi,
> >
> > Sorry, I am a GMail user, so I am unable to reply to the original email
> > from Eric Blake eblake@redhat.com on Thu May 3 14:03:00 GMT 2018:
> > https://cygwin.com/pipermail/cygwin/2018-May/237069.html
> >
> > Eric wrote: <<And patches to make Cygwin support inotify_init() and
> > friends implemented
> > on top of the Windows native API are certainly welcome.>>
> >
> > First, please correct me if Linux-style inotify is already supported in
> > Cygwin. As I understand, it is not.
>
> That's correct.
>
> [...]
>
> > I would appreciate it if people could share their thoughts and advice.
>
> I don't know if this will help, but Emacs has a filenotify feature which,
> on
> Linux, is based on inotify. In the native Windows build of Emacs,
> filenotify is
> implemented in the file src/w32notify.c in the Emacs source tree. Looking
> at
> how this is done might give you some ideas.
>
> > The Linux inotify API is an excellent feature. I have used it a few
> times
> > with great success. It would be nice to have this feature on Cygwin.
>
> Agreed. Good luck.
>
> Ken
>
> --
> Problem reports: https://cygwin.com/problems.html
> FAQ: https://cygwin.com/faq/
> Documentation: https://cygwin.com/docs.html
> Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* inotify?
@ 2018-05-03 9:35 Ulli Horlacher
2018-05-03 10:37 ` inotify? Richard H Lee
0 siblings, 1 reply; 7+ messages in thread
From: Ulli Horlacher @ 2018-05-03 9:35 UTC (permalink / raw)
To: cygwin
I have written a program, which uses inotify(wait) to send new created or
modified files.
Since inotify is a Linux kernel service, my program does not run with
Cygwin.
Is there a similar service "tell me of new files in this directory tree"
in Windows which I can use instead?
--
Ullrich Horlacher Server und Virtualisierung
Rechenzentrum TIK
Universitaet Stuttgart E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a Tel: ++49-711-68565868
70569 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/
REF:<20180503093514.GA31178@rus.uni-stuttgart.de>
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-10-23 12:13 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06 16:29 inotify? Kevin Connor Arpe
2022-10-06 19:58 ` inotify? Ken Brown
2022-10-23 12:13 ` inotify? Kevin Connor Arpe
-- strict thread matches above, loose matches on Subject: below --
2018-05-03 9:35 inotify? Ulli Horlacher
2018-05-03 10:37 ` inotify? Richard H Lee
2018-05-03 14:03 ` inotify? Eric Blake
2018-05-03 21:47 ` inotify? Ulli Horlacher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).