Getting File Create Notifications for CIFS Mount in Linux

后端 未结 5 2254
粉色の甜心
粉色の甜心 2021-01-04 02:01

I have a windows share mounted via CIFS on an ubuntu server. I need to a way to know when a new file has been added to the Windows share. I tried this inotify program:

相关标签:
5条回答
  • 2021-01-04 02:14

    It can be done.. sort of

    If you set up an webdav server and include the share as webdav location, you can monitor the location on you samba server while accessing it through webdav from your windows machine.

    The big problem with this is that file permissions are a b*tch... as usual with apache2 webdav since its missing pass-through authentication

    0 讨论(0)
  • 2021-01-04 02:21

    I have also been working on this and ran into the same issue - it seems (after a little trawling on google) that, unfortunately, it is not possible to use inotify on CIFS mounted partitions - The following was in a redhat forum post from a couple of years ago:

    "Currently, no this isn't possible with CIFS. The VFS hooks to allow a filesystem to set up extra notfications were removed recently. The only "user" of them was CIFS and it never worked properly anyway. The kernel interface for this had serious problems too.

    I think Steve has plans to reimplement it, but it's a major project that means adding new functionality to the VFS layer of the kernel."

    While this was a couple of years ago, it seems we are no closer to having this facility available - shame, I could have really used it too!

    0 讨论(0)
  • 2021-01-04 02:22

    I too ran into this and reached the same conclusion as Stephen Sullivan (CIFS + inotify = no go).

    However, since my workflow happened to depend on both remote mounts and auto-compile tools that rely on inotify, I ended up building a (fairly desperate & hacky) solution which basically just uses polling to watch for changes and then touches the same files again on the mounted side, which does seem to fire off inotify events. It is not my proudest moment.

    Having said that, it does work, so, enjoy: http://github.com/rubyruy/watchntouch

    0 讨论(0)
  • 2021-01-04 02:23

    For Windows hosts running Linux docker containers there is a detailed article on t his issue with a provided solution that works "docker-windows-volume-watcher": http://blog.subjectify.us/miscellaneous/2017/04/24/docker-for-windows-watch-bindings.html

    Looks like support is not coming any time soon from Linux implementation of CIFS inotify.

    0 讨论(0)
  • 2021-01-04 02:27

    Old topic, still important! My answer to this is: "it depends!". From my empirical tests at this time, the behavior is quite clear. If the Linux host initiates the filesystem event [upon a CIFS mount], then inotify will see it just fine. If the Windows machine which hosts the CIFS mount initiates the filesystem event, then inotify [on the Linux machine] will not see it at all.

    If your goal is for the Linux host to get notification that the Windows host created or wrote to a file, then you are out of luck. Since this is probably the most desired use of this mechanism, it does make this subtle "it depends" answer not so terribly useful!

    0 讨论(0)
提交回复
热议问题