[U-Boot-Users] [PATCH] Use `ln -sf` rather than `rm -f && ln -s`
Wolfgang Denk
wd at denx.de
Mon Apr 14 21:50:50 CEST 2008
In message <200801281557.55976.vapier at gentoo.org> you wrote:
>
> > > - @rm -f $(obj)environment.c
> > > - ln -s $(src)../common/environment.c $(obj)environment.c
> > > + ln -s -f $(src)../common/environment.c $(obj)environment.c
> >
> > Be careful here. Are you 100% sure that all systems in the field will
> > behave exactly as your's is doing?
>
> i really dont understand what you mean. any POSIX compliant system will
> behave exactly as it's supposed to: if the destination exists already, unlink
> it just before creating the link.
I finally fund such a situation again.
# cat /proc/version
Linux version 2.6.22.14-72.fc6 (brewbuilder at ls20-bc1-14.build.redhat.com) (gcc version 4.1.2 20070626 (Red Hat 4.1.2-13)) #1 SMP Wed Nov 21 14:10:25 EST 2007
# cat /etc/issue
Fedora Core release 6 (Zod)
Kernel \r on an \m
# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
# cd /opt
# ls -ld eldk eldk-4.2-2008-03-27 eldk-4.2-2008-04-01
lrwxrwxrwx 1 root root 19 Apr 4 04:01 eldk -> eldk-4.2-2008-03-27
drwxr-xr-x 14 root root 4096 Apr 8 23:37 eldk-4.2-2008-03-27
drwxr-xr-x 14 root root 4096 Apr 3 13:38 eldk-4.2-2008-04-01
Now we try:
# ln -sf eldk-4.2-2008-04-01 eldk
# echo $?
0
And what do you think we got?
# ls -ld eldk eldk-4.2-2008-03-27 eldk-4.2-2008-04-01
lrwxrwxrwx 1 root root 19 Apr 4 04:01 eldk -> eldk-4.2-2008-03-27
drwxr-xr-x 14 root root 4096 Apr 14 21:27 eldk-4.2-2008-03-27
drwxr-xr-x 14 root root 4096 Apr 3 13:38 eldk-4.2-2008-04-01
This is what I mean when I say that "rm -f foo ; ln -s bar foo" is
*NOT* exactly equivalent to "ln -sf bar foo". The former will always
work, the latter won't.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Wagner's music is better than it sounds." - Mark Twain
More information about the U-Boot
mailing list