Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Lexical to determine if a file is an alias?

SOLVED
Go to solution
MarkOfAus
Valued Contributor

Lexical to determine if a file is an alias?

Greetings,
Is there a lexical to determine if a file is an alias? Some other method, perhaps?
Regards,
Mark.
8 REPLIES
Robert Brooks_1
Honored Contributor

Re: Lexical to determine if a file is an alias?

Why do you care?

-- Rob
Hein van den Heuvel
Honored Contributor

Re: Lexical to determine if a file is an alias?

[Argh, prior post was the a paste of the pre-spell-check buffer. Tying again]

Please help us understand what problem you are trying to solve.

There is no such thing as an 'alias' in OpenVMS.

There are, since relatively recently, SYMLINKs.. but I don't think you are talking about that.

There is, since day one, the ability to ENTER a file under a different name (alias?) in the same, or in a different directory.

The file header for a file has a 'back-link' to the 'original' directory.

You can use F$FILE("z.z","DID") to request the current Directory File ID.
If you had a file [a]z.z and entered it as [b]z.z, then you could $DUMP/HEAD/BLOC=COUN=0 to figure out the back link. If the back is the same as the DID then you could all the file 'original' and if they differ you could call the file 'alias', but that's just a mind game.
It's the same file, and the true situation may be as described,
or it could be the ending position of a convoluted procedure were that so called alias was in fact the original.

Still, it is as good a definition as any to say that an alias file has a back link different from the directory used to find it, and for an original those are the same.

But what about the $SET FILE/ENTER=A.A Z.Z case?
They both have the same did, both equal to the back link (probably :-).
Which one is the alias?

TO make it harder, there is no lexical to get the back link.
You'd have to parse dump/head,
or open [000000]INDEXF.SYS and read the header.

Also, other than using F$FILE(,"DID") it is tricky to consistently get the directory file id.
Here is an (not-fool-proof, linear) DCL approach:

$ full = f$elem(0,"]",f$parse("login.com"))
$ root = f$elem(0,"]",f$parse("[.-]","login.com"))
$ dir = full - root - "."
$ did = f$file(root + "]" + dir + ".dir", "fid")

Enjoy,
Hein.
MarkOfAus
Valued Contributor

Re: Lexical to determine if a file is an alias?

Hein,

> Please help us understand what problem you are trying to solve.

A previous package (now being replaced) reportedly created lots of directory aliases (yes, using set file/enter or programmatical equivalent) on a rather large disk array. I want to clear out some of this rubbish as space is premium, but as I understand it, using delete on them is a no-no.

Some of these directories are in the same directories. To quote help:
"If you use aliases, you must also be careful when you use
the DELETE and SET FILE /REMOVE commands, or you may end up
with either an inaccessable file that has no name or a name
that does not refer to a file. Follow these guidelines to
avoid these problems:"

Some of the data is to be preserved.

If it is too much trouble I will just steal space from somewhere else & leave all this debacle to when I can just wipe the entire disks.



Regards,Mark.
Jon Pinkley
Honored Contributor
Solution

Re: Lexical to determine if a file is an alias?

Mark,

If you have a 64bit version of VMS .ge. V7.3-2, grab DFU 3.2 if you don't have it.

http://www.digiater.nl/dfu.html

If you have a VAX you will be stuck with DFU 2.7A although I don't know where to download that.

Example of use on a V7.3-2 system disk.

$ dfu directory/alias sys$sysdevice

Disk and File Utilities for OpenVMS V3.2
%DFU-I-INDSCAN, Making directory table for SYS$SYSDEVICE: (DSA1407:)
%DFU-I-DIRSCAN, Scanning 635 directories...
DSA1407:[SYS0]SYSCOMMON.DIR;1 is alias for DSA1407:[000000]VMS$COMMON.DIR;1
DSA1407:[SYS1]SYSCOMMON.DIR;1 is alias for DSA1407:[000000]VMS$COMMON.DIR;1
DSA1407:[SYS23]SYSCOMMON.DIR;1 is alias for DSA1407:[000000]VMS$COMMON.DIR;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.ASIA]INDIAN.DIR;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]INDIAN.DIR;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.ASIA]IRAN.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]IRAN.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.ASIA]ISRAEL.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]ISRAEL.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.ASIA]JAPAN.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]JAPAN.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.ASIA]PRC.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]PRC.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.ASIA]ROC.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]ROC.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.ASIA]ROK.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]ROK.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.ASIA]TURKEY.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]TURKEY.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.ATLANTIC]ICELAND.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]ICELAND.;1
DSA1407:[SYS24]SYSCOMMON.DIR;1 is alias for DSA1407:[000000]VMS$COMMON.DIR;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.AFRICA]EGYPT.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]EGYPT.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.AFRICA]LIBYA.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]LIBYA.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.AMERICA]BRAZIL.DIR;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]BRAZIL.DIR;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.AMERICA]CANADA.DIR;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]CANADA.DIR;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.AMERICA]CUBA.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]CUBA.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.AMERICA]MEXICO.DIR;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]MEXICO.DIR;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.AMERICA]US.DIR;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]US.DIR;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.PACIFIC]AUSTRALIA.DIR;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]AUSTRALIA.DIR;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.PACIFIC]NZ.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]NZ.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.EUROPE]POLAND.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]POLAND.;1
DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM.EUROPE]PORTUGAL.;1 is alias for DSA1407:[VMS$COMMON.SYS$ZONEINFO.SYSTEM]PORTUGAL.;1

%DFU-S-DONE, Directories scanned : 635
$
it depends
Jon Pinkley
Honored Contributor

Re: Lexical to determine if a file is an alias?

Mark,

RE:"A previous package (now being replaced) reportedly created lots of directory aliases (yes, using set file/enter or programmatical equivalent) on a rather large disk array. I want to clear out some of this rubbish as space is premium, but as I understand it, using delete on them is a no-no."

If all you are deleting is the aliases, that won't free up much space. They are just entries in directories.

If you want to delete the aliases, so you can then clean up the "previous package" without fear of deleting files you didn't intend to, then that's another matter.

DFU is the tool I would use. It is fast and works.

Jon
it depends
MarkOfAus
Valued Contributor

Re: Lexical to determine if a file is an alias?

Jon,

Thank you, thank you, thank you! :-)

>>If all you are deleting is the aliases, that won't free up much space. They are just entries in directories.<<

Yes, you are correct. I want to DELETE the "true" files and SET FILE/REMOVE the "alias" files. I don't want to DELETE an alias and then encounter what HELP describes as "an inaccessable (sic) file".

>>If you want to delete the aliases, so you can then clean up the "previous package" without fear of deleting files you didn't intend to, then that's another matter.<<

Yes, that is the issue. Literally hundreds of files, aliased to be "backward compatible" but in truth causing nothing but headaches, but that is another topic.

>>DFU is the tool I would use. It is fast and works.<<

Yes, DFU is the answer. You've saved me a lot of time.

Regards
Mark.
MarkOfAus
Valued Contributor

Re: Lexical to determine if a file is an alias?

See above
Hein van den Heuvel
Honored Contributor

Re: Lexical to determine if a file is an alias?

If finding space is the real issue then my tool of choice is DFU and specifically:
MCR DFU SEARC/SIZE=MINI=1000000

(where 1000000 represents 1% of the disk for a first cute, then 0.5% or 0.1%)

As Jon writes, deleting an alias entry is not productive, as that is just a few bytes in a directory file.

I just realize that there IS a lexical that picks up the backlink: Use F$FID_TO_NAME

$ fid=f$file("[.tmp]x.x","FID")
$ dev=f$pars("","","","DEVICE")
$ write sys$output f$fid(dev,fid)
DISK$USER:[HEIN]LOGIN.COM;27

So if you compare the file name, with what comes back from F$FID then you'll be as close as you can get to know whether it is an alias,

If there is a file you want to be gone, then just delete it. The worst that can happen is that is was an alias and that the file itself is not really gone. So keep on deleting until it is gone.
Hint: Use DIR/FILE when working with aliases.

Hein