Getting File Create Notifications for Cifs Mount in Linux

Strange file permissions for cifs mounted folder

My be windows machine was rebooted or hibernated and mount.cifs fails to re-read or re-mount it properly.
If you still the same problem - try to remount it and check logs in your windows machine and make sure you set correct power options in windows PC.

Does inotify work in the face of poorly synchronized clocks?

The concern is not justified.

Linux inotify is an user space API that exposes the Linux fsnotify sub-system. This kernel file system is wired into the general file system layer of the kernel (called VFS). It gets the notification of a creation of a new file directly from the file system code by a callback function, and not by comparing the creation or access dates of the files in a directory. As such, it will not be influenced at all by the time stamps on the files, so the clocks on the different client machine would not matter at all.

To be sure you audit the code for the inotify_should_send_event() send event function, that checks whether an event needs to sent for a tracked file or directory (see here: http://lxr.linux.no/linux+v3.0.4/fs/notify/inotify/inotify_fsnotify.c#L144). Note there is no reference whatsoever to time. In the same spirit the main fsnotify function (http://lxr.linux.no/linux+v3.0.4/fs/notify/fsnotify.c#L296) in the kernel does not reference time stamps anywhere, so clocks will not affect this interface at all.

I hope this helps.

Is there a clock difference on my CIFS mount?

That's a reasonable explanation. The solution is to synchronize the clocks using ntp. I'm not aware of any good way to work around the problem.

How to get File Owner attribute from SAMBA (CIFS)?

The JCIFS version 1.3.18 has a patch available to get the owner of a file.

Link to the JCIFS java lib is : https://jcifs.samba.org/src/jcifs-1.3.18.jar

Link to the patch file is :https://jcifs.samba.org/src/patches/GetOwnerSid.patch

You have to get the source of the 1.3.18 version and then generate the JAR after applying the patch. Also, note that this patch does not resolve the SID of the owner. So you may want to add code to resolve the SID.



Related Topics



Leave a reply



Submit