[comp.os.vms] Detecting file creation

scjones@sdrc.UUCP (Larry Jones) (05/03/88)

I need to create a program which will process files which get created in a
particular directory.  Each file is deleted after it is processed, so I don't
have to worry about processing a file more than once.  So far the only thing
we have been able to come up with is to continualy search the directory
looking for files to process, but that is quite wasteful of system resources.
What would be better is to have a way of knowing that a new file has been
created in the magic directory, but there doesn't seem to be any way to do
that.  The files are created by lots of different mechanisms, so we can't
have the creator signal the server.  Anyone have any ideas?

----
Larry Jones                         UUCP: ...!sdrc!scjones
SDRC                                AT&T: (513) 576-2070
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150
"When all else fails, read the directions."

jeh@crash.cts.com (Jamie Hanrahan) (05/09/88)

(Larry Jones wants to be notified when someone creates a file in a 
particular directory.)

I don't have The Answer, but I might have a Clue.  When the XQP wants to
create a file it takes out a lock so that it can write on the directory
in question.  This lock has a name which is derived in a reproducible way. 
It seems to me that if you take out a lock on the directory you should
be able to coerce the lock manager into telling you when someone else 
(the XQP) wants the lock.  You then release it, wait a reasonable time, 
and check the directory for a file to work on.  

This is definitely in the category of "Partly Baked Ideas"; I wouldn't
burden the net with it if I'd seen a more thoroughly cooked response.  
Perhaps someone else can pick it up from here and fill in the details.  
Or, I could ask some of the Files-11 experts at DECUS next week.  Yeah,
that's the ticket!  

Good luck...

	--- Jamie Hanrahan

korry@uw-nsr.UUCP (Korry A. Douglas) (05/12/88)

In article <2944@crash.cts.com> jeh@crash.CTS.COM (Jamie Hanrahan) writes:
>
>(Larry Jones wants to be notified when someone creates a file in a 
>particular directory.)
>
>I don't have The Answer, but I might have a Clue.  When the XQP wants to
>create a file it takes out a lock so that it can write on the directory
>in question.  This lock has a name which is derived in a reproducible way. 
>It seems to me that if you take out a lock on the directory you should
>be able to coerce the lock manager into telling you when someone else 
>(the XQP) wants the lock.  You then release it, wait a reasonable time, 
>and check the directory for a file to work on.  
>

The VMS Security Services Package may help here. ( Not sure, never tried it )
Section 3.4.1.1 of the VMS System Services Manual mentions an Alarm ACE (Access
Control List).  Supposedly, this ACE will send a security alarm to the console
terminal whenever the security is "violated."  "Violated" can be described as
READ, WRITE, EXECUTE, DELETE, or CONTROL.  I would bet that if you assigned an 
Alarm ACE to the directory you want to watch (say LARRY.DIR) that you would get
a message on the console whenever anyone "violates" the security.  Note that the
Alarm ACE will not prevent the access, just note it.

I believe that there is also a DCL command that will make your terminal a
console terminal, but I don't have the full VMS Doc. set at home (don't have
the room!)

					Korry Douglas