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

how can I find the file which the hard link file link to?

SOLVED
Go to solution
Lionel Liu
Advisor

how can I find the file which the hard link file link to?

Hello

if I do following

$ CREATE FOO.A
$ SET FILE FOO.A/ENTER=FOO.B

which command can find out that FOO.B link to
FOO.A FILE?

Thanks in advance
Lionel
7 REPLIES
Jess Goodman
Esteemed Contributor
Solution

Re: how can I find the file which the hard link file link to?

You can look in the file header:

$ DUMP/HEADER/BLOCK=COUNT=0 FOO.B
I have one, but it's personal.
Steven Schweda
Honored Contributor

Re: how can I find the file which the hard link file link to?

alp $ copy nl: FOO.A
alp $ SET FILE FOO.A/ENTER=FOO.B

alp $ dire /file_id foo.*

Directory ALP$DKA0:[SMS]

FOO.A;1 (165974,3853,0)
FOO.B;1 (165974,3853,0)

alp $ define /user DFU$NOSMG do_not_want_it
alp $ dfu search /fid = 165974 sys$disk

Disk and File Utilities for OpenVMS V3.2
%DFU-I-SEARCH, Start search on SYS$DISK: (ALP$DKA0:)

ALP$DKA0:[SMS]FOO.A;1 0/0

%DFU-I-EOF, End of file INDEXF.SYS, Primary headers : 1

%DFU-S-FND , Files found : 1, Size : 0/0
Lionel Liu
Advisor

Re: how can I find the file which the hard link file link to?

Thanks very much Jess and steven
Lionel
Dave Gudewicz
Valued Contributor

Re: how can I find the file which the hard link file link to?

Lionel,

In case you're wondering what DFU is, you can learn and download it from here:

http://www.digiater.nl/dfu



Hein van den Heuvel
Honored Contributor

Re: how can I find the file which the hard link file link to?

When you create an 'alias' for a file, then you are creating a record in a directory with a new name fro an existing file id.

That file id identifies a unique file header, which effectively is the file itself. That header has one, and only one, directory backlink (id) which points to where the file was created, ot last renamed into.

The DFU command Steven showed is, IMnsHO, only confusing. It does NOT do what you want.
DFU will scan the headers, looking for the file-id, and then follow the backlink and thus find only 1 occurance, which may or might not be what one might think of as the master.

It's not really the master, all directory entries are the same, but OpenVMS will ATTEMPT to not destroy that master when deleting the alias. Delete the master, and unlike hardlink, the alias will point to nowhere (FNF)

The only way to find all 'links' would be a DIRExx/FILE [000000...] or F$SEARCH equivalent and parse the output looking for matching file id. Tedious, possibly slow, but do-able.

For example:

$ dir/file tmp.tmp
Directory LDA9:[000000]
TMP.TMP;1 (14,1,0)
Total of 1 file

$ perl -e "print grep(/\(14,1,0/,qx(dire/file/nohead/nogra/notrai/wid=fil=50 [000000...]*.*;*))"
LDA9:[000000]TMP.TMP;1 (14,1,0)
LDA9:[B]TMP.TMP;1 (14,1,0)
LDA9:[C]TMP.TMP;1 (14,1,0)

The file creation scenario for that is below.

Enjoy!
Hein.

$ ld connec sys$login:lda9.disk lda9:
$ init lda9: lda9
$ moun lda9: lda9
%MOUNT-I-MOUNTED, LDA9 mounted on...
$ set def lda9:[000000]
$ cre/dir [a]
$ cre/dir [b]
$ cre/dir [c]
$ cre tmp.tmp
test
$ set file/entr=[b] tmp.tmp/log
$ set file/ente=[b] tmp.tmp/log
%SET-I-ENTERED, LDA9:[000000]TMP.TMP;1 entered as LDA9:[B]TMP.TMP;
$ set file/ente=[c] tmp.tmp/log
%SET-I-ENTERED, LDA9:[000000]TMP.TMP;1 entered as LDA9:[C]TMP.TMP;
$ copy tmp.tmp [a]a
$ copy tmp.tmp [a]b
$ copy tmp.tmp [b]p
$ copy tmp.tmp [b]q
$ copy tmp.tmp [c]q

$ dire/file/nohead/nogra/notra/wid=fil=50 [000000...]*.*;*
LDA9:[000000]000000.DIR;1 (4,4,0)
LDA9:[000000]A.DIR;1 (11,1,0)
LDA9:[000000]B.DIR;1 (12,1,0)
LDA9:[000000]BACKUP.SYS;1 (8,8,0)
LDA9:[000000]BADBLK.SYS;1 (3,3,0)
LDA9:[000000]BADLOG.SYS;1 (9,9,0)
LDA9:[000000]BITMAP.SYS;1 (2,2,0)
LDA9:[000000]C.DIR;1 (13,1,0)
LDA9:[000000]CONTIN.SYS;1 (7,7,0)
LDA9:[000000]CORIMG.SYS;1 (5,5,0)
LDA9:[000000]INDEXF.SYS;1 (1,1,0)
LDA9:[000000]SECURITY.SYS;1 (10,10,0)
LDA9:[000000]TMP.TMP;1 (14,1,0)
LDA9:[000000]VOLSET.SYS;1 (6,6,0)
LDA9:[000000]X.TMP;3 (22,1,0)
LDA9:[000000]X.TMP;2 (21,1,0)
LDA9:[000000]X.TMP;1 (20,1,0)
LDA9:[A]A.TMP;1 (15,1,0)
LDA9:[A]B.TMP;1 (16,1,0)
LDA9:[B]P.TMP;1 (17,1,0)
LDA9:[B]Q.TMP;1 (18,1,0)
LDA9:[B]TMP.TMP;1 (14,1,0)
LDA9:[C]Q.TMP;1 (19,1,0)
LDA9:[C]TMP.TMP;1 (14,1,0)






Jon Pinkley
Honored Contributor

Re: how can I find the file which the hard link file link to?

Lionel,

The correct DFU command is: dfu directory/alias

$ cre/dir disk$demo1g:[a]/own=system
$ cre/dir disk$demo1g:[b]/own=system
$ cre disk$demo1g:[a]z.dat
Exit
$ set file/ent=disk$demo1g:[a]a.dat disk$demo1g:[a]z.dat
$ set file/ent=disk$demo1g:[b]c.dat disk$demo1g:[a]a.dat
$ dfu directory/alias disk$demo1g

Disk and File Utilities for OpenVMS V3.2
%DFU-I-INDSCAN, Making directory table for DISK$DEMO1G: ($1$DGA7325:)
%DFU-I-DIRSCAN, Scanning 7 directories...
$1$DGA7325:[A]A.DAT;1 is alias for $1$DGA7325:[A]Z.DAT;1
$1$DGA7325:[B]C.DAT;1 is alias for $1$DGA7325:[A]Z.DAT;1

%DFU-S-DONE, Directories scanned : 7
$

More extensive details in attachment.
it depends
mike wagner_4
Occasional Advisor

Re: how can I find the file which the hard link file link to?

> It's not really the master, all directory
> entries are the same, but OpenVMS
> will ATTEMPT to not destroy that master
> when deleting the alias. Delete the
> master, and unlike hardlink, the alias will
> point to nowhere (FNF)

... and then there is ODS5 with hardlinks, came with the COE version of 7.2: no master,
so you can't easily create a pointer to nowhere.

> The only way to find all 'links' would be
> a DIRExx/FILE [000000...] or
> F$SEARCH equivalent and parse the output
> looking for matching file id.
> Tedious, possibly slow, but do-able.

It's somehow faster on ODS5 with hardlinks: check if the link count is greater than
1 and you have a file ID worth to compare.

mw