Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Jul 2014 06:51:04 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 191974] |ln -sF| never calls rmdir(2) on target_file == target_dir, only target_dir/basename
Message-ID:  <bug-191974-8-yCRo7ZduS8@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-191974-8@https.bugs.freebsd.org/bugzilla/>
References:  <bug-191974-8@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191974

bycn82@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bycn82@gmail.com

--- Comment #1 from bycn82@gmail.com ---
I checked the source code of the ln, I agree with him, something wrong there! 

the main logic are here.
    switch(argc) {
    case 0:
        usage();
        /* NOTREACHED */
    case 1:                /* ln source */
        exit(linkit(argv[0], ".", 1));
    case 2:                /* ln source target */
        exit(linkit(argv[0], argv[1], 0));
    default:
        ;
    }
        /* ln source1 source2 directory */


I did the below test with my explanation.

root@FBHead:~ # uname -a
FreeBSD FBHead 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r268881: Sun Jul 20
01:32:21 UTC 2014     root@FBHead:/usr/obj/usr/src/sys/GENERIC  amd64

Test1
root@FBHead:~ # ln -s -F
usage: ln [-s [-F] | -L | -P] [-f | -i] [-hnv] source_file [target_file]
       ln [-s [-F] | -L | -P] [-f | -i] [-hnv] source_file ... target_dir
       link source_file target_file
the argc==0, so show the usage.

Test2
root@FBHead:~ # ln -s -F foo
root@FBHead:~ # ls -al foo
lrwxr-xr-x  1 root  wheel  3 Jul 20 04:42 foo -> foo

according to the logic, the argc==1, so it will call linkit(argv[0], ".", 1) so
the result will be foo->foo, it will be useless, because it will delete the
current foo and create the new foo soft link with link to itself!!!

Test3
root@FBHead:~ # rm foo
root@FBHead:~ # touch foo
root@FBHead:~ # mkdir bar
root@FBHead:~ # ln -s -F foo bar
root@FBHead:~ # ls -al bar/foo 
lrwxr-xr-x  1 root  wheel  3 Jul 20 04:47 bar/foo -> foo
here the argc==2, so it will call linkit(argv[0], argv[1], 0)
and the 3rd parameter "0" means the argv[1] is not a directory!!
anyway, the result is not correct, 

Test4
root@FBHead:~ # ln -s -F foo1 foo2 bar
in this case, the argc is not 0 1 2 , so it will be go to default: and
continue, actually it will just loop the parameters and call linkit, the result
will be same as previous one.

all this are not make sense!!! the -F in the man page also bullshit! I think
all this features are the same on other systems for example Linux or other BSD
systems. because the code are not new created. already there for long long !!!

anyway, I dont recommend to make changes in the source code immediately, but
update the document first. make it clear about how it works. what do you guys
think ?

-- 
You are receiving this mail because:
You are the assignee for the bug.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-191974-8-yCRo7ZduS8>