[Info-vax] detecting links made with SET FILE/ENTER
Hein RMS van den Heuvel
heinvandenheuvel at gmail.com
Sat Sep 13 18:25:07 EDT 2014
On Saturday, September 13, 2014 11:03:36 AM UTC-4, Phillip Helbig---undress to reply wrote:
Philip> Is there a QUICK AND EASY way to detect links which have been produced
Philip> via SET FILE/ENTER?
Yes, kinda.
As you probably know, SET FILE/ENTER changes NOTHING to the original file (header).
It only creates a new filename entry in the same, or a different directory on the same volume.
The file header has the original name in there, and a backlink FID to the original directory.
This is how the file system protects you from 'accidentally' deleting the original file when deleting an alias, and how it manages RENAMEs.
This is also how you can test whether the file is the original.
Just compare F$SEARCH output for the file with F$FID output.
If they are NOT the same then an alias was used.
A delete would turn into a REMOVE, a rename only changes the directory entry, not the file header.
$ dir/file/size/nohead/notra ram:[*]
RAM:[A]TEST.TXT;1 (13,4,0) 1
RAM:[A]YYYY.TXT;1 (13,4,0) 1
RAM:[B]TEST.TXT;1 (13,4,0) 1
$ file := RAM:[B]TEST.TXT
$ write sys$output f$fid(f$parse(file,,,"DEVICE"),f$file(file,"FID"))
RAM:[A]TEST.TXT;1
$ write sys$output f$searc(file)
RAM:[B]TEST.TXT;1
$ delete/log RAM:[A]YYYY.TXT;1 !Deleting an alias is 'safe'
%DELETE-I-FILDEL, RAM:[A]YYYY.TXT;1 deleted (1 block)
$ dir/file/size/nohead/notra ram:[*]
RAM:[A]TEST.TXT;1 (13,4,0) 1
RAM:[B]TEST.TXT;1 (13,4,0) 1
$ delete/log RAM:[A]TEST.TXT;1 !Deleting the main file leaves dangling aliasses
%DELETE-I-FILDEL, RAM:[A]TEST.TXT;1 deleted (1 block)
$ dir/file/size/nohead/notra ram:[*]
RAM:[B]TEST.TXT;1 no such file
Useful command if verifying this:
$ pipe dump/head/block=count=0/id=NNN DEV: | search sys$pipe "File name","Back link"
Philip> Since one should DELETE only the last remaining entry, and otherwise
Philip> use SET FILE/REMOVE, it would be nice if there were a quick and easy
Philip> way to detect whether other links exist.
If one just _knows_ that the entry is an alias (eg in build tree, sandbox) then I encourage using SET FILE/REMOVE as it is the minimal amount of work.
If one does NOT know, then just use delete and trust the XQP to do the right thing.
There is now way you can code up a test to do less work then the minimal work the XQP does to figure this out. The XQP has all the context right there.
( Listings: [xqp]delete.lis, routine ALIAS_ENTRY, flag variable PRIMARY )
Johnny> Removing all but one directory entry and then delete the whole file with the last entry is what I'd recommend.
Johnny> Do not really matter which one you keep to last.
It does matter.
If you delete the original file first, it is gone. Period. The alias leads to nowhere.
If you remove the original file first, then the BACK LINK is set to (0,0,0) and now it is a free for all. A delete for any alias will delete the file itself.
Check with DFU : $ mcr dfu search/fid=NNN/full dev:
DUMP/ID is broken for this as its F$FID_TO_NAME fails.
So as per my advice to Phillip, just use delete, and let OpenVMS figure it out.
JFM> does DFU have the capability to scan for file IDs or even
Noop, it processes INDEXF.SYS, not directories.
There is only ever one primary header entry in INDEXF.SYS, but an additional directory entries for each alias.
JFM> Whebn you do SET FILE/ENTER , is it correct to state that INDEXF.SYS
entry for the file ID only gets a count incremented
No. Nothing happens to INDEXF.SYS for SET FILE/ENTER. Only impact is to a directory. (ok... perhaps if version limits are in play... :-)
Phillip>> Is there such a thing as a primary entry, or are all equivalent?
Yes. No. The original is called 'primary' in the XQP sources and gets special treatment.
Cheers,
Hein.
More information about the Info-vax
mailing list