From: SMTP%"MACRO32%WKUVX1.BITNET@uu7.psi.com" 6-JUL-1993 09:10:44.53 To: EVERHART CC: Subj: Re: Detecting links X-Listname: "VMS Internals, MACRO, & BLISS Discussions" Warnings-To: <> Errors-To: MacroMan%WKUVX1.BITNET@uu7.psi.com Sender: MacroMan%WKUVX1.BITNET@uu7.psi.com X-Newsgroups: vmsnet.internals Subject: Re: Detecting links 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 In article <1993Jul2.145343.13033@iitmax.iit.edu>, falke@iitmax.iit.edu (Falke Bruinsma) writes: > I'm writing a procedure to delete a complete directory with all its > subdirectories. However I have found some problems with my procedure. A > user could possibly create a 'link' with SET FILE/ENTER from their directory > to the root directory. My procedure would follow that link and effectivly > delete the _complete_ disk! A temporarily solution is to check if the file > that is to be delete is owned by the user. However if I could somehow detect > such a link, it would be much nicer. Does anyone know how I can detect these > links in VAXC? Each file/directory has a back pointer pointing to the file it is entered into; this is in the file header, offset FH2$W_BACKLINK. This should match the file-ID of the directory you are deleting from; if it doesn't, 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. I don't think you can do this from DCL. One way to do it from a HLL would be to parse the file name to a full path relative to the MFD (using $PARSE with the NAM$M_NOCONCEAL bit in NAM$B_NOP), call LIB$FID_TO_NAME with the file's FID (from the NAM block) and see if the two match, since LIB$FID_TO_NAME works by following the backlinks. I can't see an easy way in RMS to get the backlink. It's not too difficult to just read the file header directly though -- file headers are just an array of blocks in INDEXF.SYS; the VBN to read is computed by: MAXFILES / 4096 + CLUSTER * 4 + file-number + 1 (where MAXFILES and CLUSTER can be obtained by calling $GETDVI and file-number is the file number component of the FID). Pretty trivial really. 8-) Don Stokes, CSC Network Manager, Victoria University of Wellington, New Zealand Ph+64 4 495-5052 Fax+64 4 471-5386 Work:don@vuw.ac.nz Home:don@zl2tnm.gen.nz