[Omake] Lm_notify windows port, unable to perform certain operations on monitored directory

Jason Hickey jyh at cs.caltech.edu
Sat Feb 2 14:25:54 PST 2008


Rabih, this is wonderful, thank you!  I had always wondered why  
renaming fails when file monitoring is turned on--it seems like a poor  
design decision in Win32.  Basically, it is a DOS attack: that "mv"  
does not work when *any* process is monitoring the filesystem.

This will also help fix some workarounds in OMake, thanks!

Jason

On Feb 2, 2008, at 2:00 PM, Aleksey Nogin wrote:

> On 21.01.2008 01:54, RABIH.ELCHAAR at sgam.com wrote:
>
>> The problem that arises is the following:
>> When monitoring directory A, under Windows, some operations are  
>> rendered infeasible, like renaming a file, or injecting some code  
>> (during compilation process).
>> After some investigations, I cornered the problem to the  
>> fam_win32.c file, at line 367 in the CreateFile function
>>    /* Get a handle to the directory for synchronous operation */
>>    dir_handle = CreateFile(name,
>>                            GENERIC_READ,
>>                            FILE_SHARE_READ | FILE_SHARE_DELETE,
>>                            NULL,
>>                            OPEN_EXISTING,
>>                            FILE_FLAG_BACKUP_SEMANTICS |  
>> FILE_FLAG_OVERLAPPED,
>>                            NULL);
>> According to the MSDN documentation, the third argument, the  
>> dwShareMode, in order to respond to my needs should include also  
>> the FILE_SHARE_WRITE.
>> When changing the code to
>>    dir_handle = CreateFile(name,
>>                            GENERIC_READ,
>>                            FILE_SHARE_READ | FILE_SHARE_DELETE |   
>> FILE_SHARE_WRITE,
>>                            NULL,
>>                            OPEN_EXISTING,
>>                            FILE_FLAG_BACKUP_SEMANTICS |  
>> FILE_FLAG_OVERLAPPED,
>>                            NULL);
>> Other processes are able to perform renaming and code injection  
>> (mainly in my case, embedding manifests).
>> Is there a reason to justify that the FILE_SHARE_WRITE flag is not  
>> passed?
> Thanks a lot for reporting this.
>
> I talked to Jason (who is the author of this code) and he does not  
> remember why the FILE_SHARE_WRITE was omitted. I am planning to try  
> adding it back and checking if that creates any problems.
>
> Aleksey
> _______________________________________________
> Omake mailing list
> Omake at metaprl.org
> https://lists.metaprl.org/mailman/listinfo/omake

--
Jason Hickey                  http://www.cs.caltech.edu/~jyh
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257





More information about the Omake mailing list