Problem: Watching Directories from WinNT+

Steve Hardy steve at connectux.com
Fri Jul 25 13:54:09 GMT 2003


Hi there,

ReadDirectoryChangesW simply doesnt work with samba. Also, the 2.4 kernel
lacks support for actually telling WHAT changed in a directory (it ca only
tell you SOMETHING changed). We are about to release a plugin for Outlook
that makes it possible to share mailboxes and shared folders that makes
use of a file-notification system. Because we also use samba a lot the way
we do this is:

- Only use FindFirstChangeNotification, etc.
- If you want to know WHAT changed, you'll have to check mod. times
yourself (which can be done quite efficiently actually) on the client side
- Sometimes samba gives an error (not sure which one) which will be OK
after a few seconds when you do the FindFirstChangeNotification, so just
sleep(2) on an error and try again.

We now have a wrapper class that emulates ReadDirectoryChangesW when using
samba servers. Unfortunately this is closed source so I can't give it to
you.

grtz,
  Steve

On Wed, 23 Jul 2003, Claus Faber wrote:

> Hi there,
> 
> I'm trying to watch the changes in a directory from WinNT (XP as a matter of
> fact). It works fine watching directories on a remote WinNT computer but
> doesn't with a remote Samba Server:
> 
> When a change in the watched directory occurs, ReadDirectoryChangesW()
> returns with error 59 (=ERROR_UNEXP_NET_ERR). If a try the same approach
> with async communication ReadDirectoryChangesW() works fine but
> GetOverlappedResult() returns with the same error message. Looks like that
> Samba isn't sending a proper return packet.
> 
> I really do appreciate any feedback on this problem,
> 
> Thanks in advance,
> 
> Claus
> 
> 
> Here's the code running on my WinNT machine:
> 
>  if(!(hFile=CreateFile(
>        "\\\\Mephisto\\test",
>        FILE_LIST_DIRECTORY,
>        FILE_SHARE_READ
>       | FILE_SHARE_WRITE
>       | FILE_SHARE_DELETE,
>        0,
>        OPEN_EXISTING,
>        FILE_FLAG_BACKUP_SEMANTICS,
>        NULL      ))){
>    // failed
>    dwErr = ::GetLastError();
>  }else{
>   while(1){
>    if(!ReadDirectoryChangesW( hFile,
>           byBuffer,
>          BUFSIZE,
>          FALSE,
>          FILE_NOTIFY_CHANGE_FILE_NAME,
>          &dwNbBytes,
>          0,          0
>          )){
>     // error
>     dwErr=::GetLastError();
>     CloseHandle(hFile);
>     hFile=0;
>     break;
>    }else{
>     dwErr=0;
>    }
>   } // wend
>  }
> 
> 
> 
> 
> 




More information about the samba-technical mailing list