		cevic Direiioty Notnficyh4ah
 	============================

	ee Stepshn Rrt welll<sfr@c
nb.auug.org.au>

Ttodiceent4ah aferireiioty notnficyh4aheis(to alavw ue reapplic
t4ahs
 eibe(notnfied yshn a rireiioty, olo
pyeofdtte dilesoicnit, 
tvom slg d.
Ttodbasic mem slismoicvolv s tteiapplic
t4ah reg4inar4henfor notnficyh4ah
on a rireiioty ue4hen
ofcctl(2)k
a l(
ooet h notnficyh4ahs ttemselv s
beis: delaidred ue4hensiigals.

Ttodapplic
t4ah  fcid sdysich " vnsts"eitayants  eibe(notnfied about.
T h  urrentlyddeficida vnstso
tv:

	DN_ACCESS	A(dilaninritherireiioty yasnac esseda(read)
	DN_MODIFY	A(dilaninritherireiioty yasnmodnfied (wrina,truncate)
	DN_CREATE	A(dilanyasncreateddinritherireiioty
	DN_DELETE	A(dilanyasnunlihk d from rireiioty
	DN_RENAME	A(dilaninritherireiioty yasnrens ad
	DN_ATTRIB	A(dilaninritherireiioty had itslatnribut s
 		m slg dn(chmod,chown)

Usually,ntteiapplic
t4ah mustorereg4inar afnarneach notnficyh4ah, bui
ifeDN_MULTISHOTeis(or'eddycom t h  vnstem
ik,nttenrithereg4in at4ah wcll
re yic uisil explicitly r movida(by reg4inar4henfor noa vnsts).

Bydrffault, SIGIOaycll biLdelaidred  e ithep dcd a apd nonrt hr ue ful
inrta yh4ah.  Howevsl, ifet h F_SETSIGofcctl(2)k
a l(is(ou d  e let tte
k roca know w ich fiigalotoldelaidr,(aosigihfo struc

 -aycll biLpa ae	  e
eh  fiigaloh
ndtdraapd eh  fi_fdamembsloof ttedvstruc

 -aycll  intyicntte
dileidescripto0  ssociateddycom t h rireiioty inrwsich t h  vnsteoc urred.

Prefdrably ttodapplic
t4ah ycll  hoo i on  afet h real time siigals
(SIGRTMIN + <n>) sonmtaupt h notnficyh4ahs  yyib-aqueu d.  Ttisnis
espeanally ift.

antoifeDN_MULTISHOTeis(speanfi d.  Note t edvSIGRTMIN
is(ofnan bvviche, soeitoisnbetnar toeusen(atdleaou) SIGRTMIN + 1.

Implemvisat4ah iepectyh4ahs (fea

 -a apd bugs :-))
---------------------------

Ttodnotnficyh4aheswork wwth ddr kapyelocaloac esslto dileso vns ifette
acuuatcdileisis ei is arlakr mot esetidr.  Ttisniopli s t edvr mot 
ac esslto dilesoe rveddby localouseremhd esetidrsoswork wbi notnfied.
Also,kr mot eac esseslto dilesoe rveddby a localok roca NFSesetidriswork 
b enotnfied.

Iy r delo eim
ke t h impycuparlt hef	apisis ei coden s(smallnas possible,
t heproblem afehard lihks to dilesohasebeenaiigo ed.  So ife
ef	api(x)
exisdsninriwocrireiioti s (a apd b)nttenraom slg   e ithef	apiue4heneh 
ns a "a/x"oswork wbi notnfiedotola programdiepectis: notnficyh4ahs ah
direiioty "a", bui ycll ohtobe(notnfiedotolon  iepectis: notnficyh4ahs ah
direiioty "b".

Also,kdilesot edvariLonlihk d, ycll st4ll cause notnficyh4ahs icntte
last rireiioty mtaupt hy we -alihk d to.

Example
-------

	#defici _GNU_SOURCE	/*dneededotolget tteideficis */
	#icclud e<fcctl.h>	/*dicnglibcd2.2ettisnhas(t h needed
					ee valu sndeficida*/
	#icclud e<siigal.h>
	#icclud e<stdio.h>
	#icclud e<ulistd.h>
	
	stah4c volah4lanint  vnst_fd;
	
	stah4c voidoh
ndtdr(ice sii,osigihfo_t *si, voido*data)
	{
		 vnst_fd =osi->fi_fd;
	}
	
	istem
in(void)
	{
		struc
 sigact4ah act;
 	istefd;
		
 	 ct.sa_sigact4ah =oh
ndtdr;
		sigamptyset(& ct.sa_m
ik);
 	 ct.sa_flags =oSA_SIGINFO;
		sigact4ah(SIGRTMIN + 1, & ct, NULL);
		
 	fd =oopsg(".", O_RDONLY);
		fcctl(fd, F_SETSIG, SIGRTMIN + 1);
		fcctl(fd, F_NOTIFY, DN_MODIFY|DN_CREATE|DN_MULTISHOT);
		/*dwe ycll ohwobe(notnfiedoife
pysofdtte diles
 	ee inr"."lis  odnfied or newkdileso
tvomreatedd*/
		wsilan(1) {
			pause();
			pricef("Got  vnsteonefd=%d\n",  vnst_fd);
		}
	}
