4

I'm modifying files on a UNIX system and accessing them on a Windows box. The server runs samba and there is some amount of caching done by the client. When I modify the file on the UNIX side, the only reliable way to see the new version of the file is to right click in Windows Explorer and select "refresh".

I'm looking for the Windows API equivalent of right-clicking in Windows Explorer and selecting "refresh". There are other questions on SO about sending a message to Explorer to cause it to refresh, but that's not what I want: I don't care about the contents of the Explorer window and I would prefer to not even need one open to the target directory. I just want to integrate the cache-defeating effect into my program so I avoid seeing stale data.

Ben Jackson
  • 90,079
  • 9
  • 98
  • 150

1 Answers1

4

CIFS includes a notification system for updates. Explorer registers for this, and will reflect any changes that Samba sends it. I'm not aware of any other API mechanism to tell Windows that it needs to do a refresh.

Samba supports Linux inotify, so it should automatically pick up any changes to folders that Explorer is displaying and send Explorer updates.

Are you using a recent-enough version of Samba, and has Samba been built with inotify support? This is obviously Linux only. For another Unix, you could implement equivalent functionality. The relevant code is in smbd/notify_internal.c.

Robie Basak
  • 6,492
  • 2
  • 30
  • 34
  • I'm on FreeBSD and I did not configure FAM_SUPPORT ("File Alteration Monitor"). Looks like I should upgrade samba and try enabling it. – Ben Jackson Nov 01 '10 at 18:27
  • 1
    I upgraded samba, which was the usual trail of tears (curse whoever added `passdb backend` and defaulted it to an incompatible setting). I *almost* got gamin to do something but not quite. I don't hold out much hope that FAM works at all considering I didn't see the required `vfs objects = notify_fam` suggested anywhere. So you may well be right, but I can't verify your solution. – Ben Jackson Nov 02 '10 at 07:55
  • I verified that this works as described with linux+samba, so this is clearly the best solution. – Ben Jackson Nov 04 '10 at 17:11