How do you find the symbolic links to files.

Jon Brawn jonb at specialix.co.uk
Wed Nov 28 02:50:15 AEST 1990


mjr at hussar.dco.dec.com (Marcus J. Ranum) writes:
>jonb at specialix.co.uk (Jon Brawn) writes:
>>[...] How do I access a symbolic link
>>file to find out that it IS a symbolic link (I mean from within C, I
>>assume stat( char *filename ) is going to stat the pointed too file?)

>	use lstat(2), of course.
Thanks.

>>Does 'find' have a wonderful flag for finding symlinks?
>	read the manual page on find(1).
Hmm. And? SCO Unix doesn't appear to document it - hang on a mo I'll
look at Interactive...
...nope. So, having RTFM, I find nothing useful. The question remains
unanswered.

>>Also, what about old crusties like 'tar' and 'cpio'? What do they do?
>	tar and cpio [assuming on cpio - I don't use it] use lstat(2)
>instead of stat(2), as they should. tar also keeps a table of the inode
>#s of files it has already dumped, and makes a note to make a hard link
>to the file instead of just storing 2 copies.
I know how tar and cpio handle regular files and device nodes. I want to
know about symbolic links.

I would hope that tar would copy the contents of the file. That would be
do much more useful than trying to do a restore, and discovering that what
you thought you had backed up as /usr/data_base/main_data_file was in
actual fact just a sixty four character pathname to an obscure corner of the
file system, and that you had, in fact, lost everything in the last crash...
...but I guess tar will probably just backup the symbolic path name anyway.

>mjr.
>-- 
>	Good software will grow smaller and faster as time goes by and
>the code is improved and features that proved to be less useful are
>weeded out.	[from the programming notebooks of a heretic, 1990]

So, in summary:

I asked (quite nicely) how you played with symbolic links at a fairly
nuts'n'bolts level, and got told to RTFM. Now, TFMs don't mention it
because symbolc links are not in the ``currently popular'' releases.

I tell people to RTFM on a regular basis. I don't (usually)
need to be told to do it myself. When something new comes along, I
like to be able to ask those more priviledged than myself for
enlightenment, so they can look in their manuals and say, 'Theres
this new O/S call that is dead ace, it's just like stat, but
different, you give it a file name, and it gives you the *real* info
on the file'.

So, whats the real truth about find, cpio & tar? how do they behave?
-- 
Jon?
--
jonb at specialix.co.uk
			"Never be sorry for a might have been."



More information about the Comp.unix.internals mailing list