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

RABIH.ELCHAAR at sgam.com RABIH.ELCHAAR at sgam.com
Mon Jan 21 01:54:44 PST 2008


Hello Everyone,

I've started looking at omake last week, in order to migrate my
Makefiles for the different Ocaml projects into Omake.

I'm a windows user, and have been programming into ocaml for quite a
while.

 

I am also planning to use the lm library, available with omake in order
to perform the following:

 

Monitor a directory A

If a certain set of events occur, copy some files from A to B.

 

This seems quite easy to undertake, using the Lm_notify module,
implementing a FAM interface for windows

 

let t = Lm_notify.create();;

 

Lm_notify.monitor t "A" false;;

 

while(true) do

let event = Lm_notify.next_event t in

....

done

 

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 in advance for your help.

 

Sincerely,

Rabih Chaar

Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses destinataires. 
Toute utilisation ou diffusion non autorisee est interdite. 
Tout message electronique est susceptible d'alteration. 
Societe Generale Asset Management et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie. 
  
Decouvrez l'offre et les services de Societe Generale Asset Management sur le site www.sgam.fr 
  
                                ******** 
  
This message and any attachments (the "message") are confidential and intended solely for the addressees. 
Any unauthorised use or dissemination is prohibited. 
E-mails are susceptible to alteration. 
Neither Societe Generale Asset Management nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. 
 
Find out more about Societe Generale Asset Management's proposal on www.sgam.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.metaprl.org/pipermail/omake/attachments/20080121/47a8bd5e/attachment.html


More information about the Omake mailing list