LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] How to copy some files

[ILUG] How to copy some files

Paul Jakma paul at clubi.ie
Sun Jul 21 01:41:44 IST 2002


On Sat, 20 Jul 2002, kevin lyda wrote:

> let's call these super-soft-links.  ln -ss
> 
>     % ln -ss foo bar
>     % ls -i foo
>     111 foo
>     % mv floyd foo
>     % ls -i foo
>     222 foo

isnt this standard behaviour?? mv uses rename() which replaces the
new path name:

[paul at fogarty tmp]$ rm foo bar floyd ; echo foo > foo ; echo floyd > 
floyd ; ln -s foo bar ; ls -i foo bar floyd ; strace -e 
lstat,stat,stat64,lstat64,link,unlink,rename mv floyd foo ; ls -i foo 
bar ; cat bar
rm: cannot remove `foo': No such file or directory
rm: cannot remove `bar': No such file or directory
rm: cannot remove `floyd': No such file or directory
52026333 bar  52026332 floyd  52026331 foo
stat64("foo", {st_mode=S_IFREG|0664, st_size=4, ...}) = 0
lstat64("floyd", {st_mode=S_IFREG|0664, st_size=6, ...}) = 0
lstat64("foo", {st_mode=S_IFREG|0664, st_size=4, ...}) = 0
rename("floyd", "foo")                  = 0
52026333 bar  52026332 foo
floyd

> and now bar no longer points to foo.

yes it does. :)

but your super-links dont is what you're saying i guess. but why? why
would you want a symlink, bar, linking to foo, to stop linking if foo
is changed?

>     % ln -ss foo bar
>     % ls -i foo
>     111 foo
>     % rm foo
>     % touch floyd
>     % ls -i floyd
>     111 floyd

eh?

???

is this an example of inode reuse? :) or do you mean that somehow 
floyd is the new foo, (foo is dead, all hail floyd) and that bar now 
points to floyd?

how do i control this 'symlinks magically link to new files' feature?

> and this all fails to handle nfs mounted file systems or filesystems
> that have dynamic inodes (the fat fs's and reiser lacks inodes i think).

reiser's handles to files are hashes i believe. fat: dont think you 
can make symlinks on it.

> kevin

anyway, links are directory entries that reference the same inode.  
(and i'll bet the restriction on directories is an artificial these
days.. ELOOP exists anyway because of symlinks.)

and symlinks are inodes whose data is a reference in the namespace:

[root at fogarty tmp]# ls /var/tmp/foo
bin  lib  tmp
[root at fogarty tmp]# ls /var/tmp/foo/bin/
cat  ls
[root at fogarty tmp]# pwd
/var/tmp/foo/tmp
[root at fogarty tmp]# echo "i am foo" > foo
[root at fogarty tmp]# ls
foo
[root at fogarty tmp]# ln foo fongle
[root at fogarty tmp]# chroot /var/tmp/foo cat /tmp/fongle /tmp/foo
i am foo
i am foo
[root at fogarty tmp]# rm fongle
rm: remove `fongle'? y
[root at fogarty tmp]# ln -s foo fongle
[root at fogarty tmp]# chroot /var/tmp/foo cat /tmp/fongle /tmp/foo
i am foo
i am foo
[root at fogarty tmp]# rm fongle
rm: remove `fongle'? y
[root at fogarty tmp]# ln -s /var/tmp/foo/tmp/foo fongle
[root at fogarty tmp]# cat foo fongle
i am foo
i am foo
[root at fogarty tmp]# chroot /var/tmp/foo cat /tmp/fongle /tmp/foo
cat: /tmp/fongle: No such file or directory
i am foo

in the last example, the symbolic link doesnt work in the chroot, 
because the namespace is different.

aiui.

regards,
-- 
Paul Jakma	paul at clubi.ie	paul at jakma.org	Key ID: 64A2FF6A
Fortune:
Never try to teach a pig to sing.  It wastes your time and annoys the pig.
		-- Lazarus Long, "Time Enough for Love"





More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell