Operating System - HP-UX
1748201 Members
3166 Online
108759 Solutions
New Discussion юеВ

Re: hard link (find file , which it points to )

 
SOLVED
Go to solution
Billa-User
Regular Advisor

Re: hard link (find file , which it points to )

> bdf .

does a command or function exits like "get filesystem " ?

a combination of "pwd -P" and "bdf ." ?

i think it is better to user "df ." , why?
when i have longer lvol's oder filesystem's, it isn't easy to parse :

df .
/testfs/filesys1 (/dev/vgtestfs1/filesys1): 12205184 blocks 191869 i-nodes

bdf .
Filesystem kbytes used avail %used Mounted on
/dev/vgtestfs1/filesys1
18874368 12734552 6102592 68% /testfs/filesys1

regards
Billa-User
Regular Advisor

Re: hard link (find file , which it points to )

hello,

i created a short script (in attachment).
it is a mix of shell and perl.

i use perl to detect :

- nlink number of (hard) links
- inode number

how can i detect the version of filesystem

- i use /sbin/vxupgrade ?

regards
James R. Ferguson
Acclaimed Contributor

Re: hard link (find file , which it points to )

Hi (again):

A couple of comments:

If you to see if a directory is a mountpoint, test [stat()]for the directory to have an inode number of <2>. All mountpoints have inode=2.

I suggested using :

# perl -MCwd=realpath -le 'print realpath q(.)'

...to be able to define (at the top level) the mountpoint in which you are looking.

As for detecting the VxFS filesystem version, you can use the device associated with the filesystem in question :

# fstyp -v /dev/vgNN/lvolN

...or you can use 'vxupgrade':

# vxupgrade /mymountpoint

Regards!

...JRF...
Billa-User
Regular Advisor

Re: hard link (find file , which it points to )

please correct if i don't understand command:

# perl -MCwd=realpath -le 'print realpath q(.)'

should i get the mountpoint in which i am ?

we have at one server following mountpoint's:

/testfs
/testfs/filesys1
/testfs/filesys2

when i change to example:
cd /testfs/filesys1/dir1/dir2

then i get with :
perl -MCwd=realpath -le 'print realpath q(.)'

/testfs/filesys1/dir1/dir2 .

should i get /testfs/filesys1 ?

on other server i have a filesystem like:
/demo

i change to /demo/dir1/dir2
then i get with :
perl -MCwd=realpath -le 'print realpath q(.)'

/demo/dir1/dir2

perl -MCwd=realpath -le 'print realpath q(.)'

is it only for link's ?
James R. Ferguson
Acclaimed Contributor

Re: hard link (find file , which it points to )

Hi (again):

> please correct if i don't understand command:

I'm sorry, I don't mean to be oblique. My thinking is that if you have the full, real path of your file, then you can walk-backwards through the (sub)paths using a stat() to find at what point you are inode=2 which is the mountpoint.

Knowing the mountpoint then allows you to use a find() by inode. Listing all files in a filesystem with the same inode gives you what you want.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: hard link (find file , which it points to )

>does a command or function exits like "get filesystem"?

No need when you can roll your own.

How often are you going to track down these hardlink families that you think you need a script?

>I think it is better to user "df ."

My fingers just always type bdf. :-)
Billa-User
Regular Advisor

Re: hard link (find file , which it points to )

> How often are you going to track down these hardlink families that you think you need a script?

in my company we have a self-developed application , with use hard link's. i had to check if the hard link's point to the right source. how many hard link's : about 6.000

with the script i would know very fast , where the hard link "point to"

i checked the hard link's with those little script and it work's with your input perfect.

thanks

regards
Billa-User
Regular Advisor

Re: hard link (find file , which it points to )


final version of script:
get_file_of_hard_link.sh
Dennis Handly
Acclaimed Contributor

Re: hard link (find file , which it points to )

>how many hard links: about 6.000

If you have 6 thousand links to check, you may want to do more than one at a time.