F From:	SMTP%"MACRO32%WKUVX1.BITNET@uu7.psi.com"  6-JUL-1993 09:10:44.53 To:	EVERHART CC:	 Subj:	Re: Detecting links   O X-Listname: "VMS Internals, MACRO, & BLISS Discussions" <MACRO32@WKUVX1.BITNET>  Warnings-To: <> - Errors-To: MacroMan%WKUVX1.BITNET@uu7.psi.com * Sender: MacroMan%WKUVX1.BITNET@uu7.psi.com X-Newsgroups: vmsnet.internals Subject: Re: Detecting links0 Message-Id: <1993Jul4.015738.2310@zl2tnm.gen.nz> From: don@zl2tnm.gen.nz + Reply-To: MACRO32%WKUVX1.BITNET@uu7.psi.com  Date: 4 Jul 93 01:57:38 +1200  Organization: The Wolery	 Lines: 33  To: MACRO32@WKUVX1.BITNET  X-Gateway-Source-Info: USENET   N In article <1993Jul2.145343.13033@iitmax.iit.edu>, falke@iitmax.iit.edu (Falke  Bruinsma) writes:E > I'm writing a procedure to delete a complete directory with all its I > subdirectories. However I have found some problems with my procedure. A N > user could possibly create a 'link' with SET FILE/ENTER from their directoryK > to the root directory. My procedure would follow that link and effectivly L > delete the _complete_ disk! A temporarily solution is to check if the fileN > that is to be delete is owned by the user. However if I could somehow detectN > such a link, it would be much nicer. Does anyone know how I can detect these > links in VAXC?  I Each file/directory has a back pointer pointing to the file it is entered E into; this is in the file header, offset FH2$W_BACKLINK.  This should H match the file-ID of the directory you are deleting from; if it doesn't,F don't touch it, issue a warning message.  SET FILE/ENTER doesn't touch< the backlink; it should always point to the its real parent.  D I don't think you can do this from DCL.  One way to do it from a HLLI would be to parse the file name to a full path relative to the MFD (using G $PARSE with the NAM$M_NOCONCEAL bit in NAM$B_NOP), call LIB$FID_TO_NAME H with the file's FID (from the NAM block) and see if the two match, sinceF LIB$FID_TO_NAME works by following the backlinks.  I can't see an easyH way in RMS to get the backlink.  It's not too difficult to just read theG file header directly though -- file headers are just an array of blocks . in INDEXF.SYS; the VBN to read is computed by:  7         MAXFILES / 4096 + CLUSTER * 4 + file-number + 1   B (where MAXFILES and CLUSTER can be obtained by calling $GETDVI andE file-number is the file number component of the FID).  Pretty trivial  really.  8-)  O Don Stokes, CSC Network Manager, Victoria University of Wellington, New Zealand O Ph+64 4 495-5052  Fax+64 4 471-5386  Work:don@vuw.ac.nz  Home:don@zl2tnm.gen.nz 