From owner-freebsd-bugs@FreeBSD.ORG Sun Jul 20 06:51:04 2014 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BA2FA1F9 for ; Sun, 20 Jul 2014 06:51:04 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9BC0E2826 for ; Sun, 20 Jul 2014 06:51:04 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.8/8.14.8) with ESMTP id s6K6p4Jl038349 for ; Sun, 20 Jul 2014 06:51:04 GMT (envelope-from bugzilla-noreply@freebsd.org) 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 Date: Sun, 20 Jul 2014 06:51:04 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 11.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: bycn82@gmail.com X-Bugzilla-Status: Needs Triage X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Jul 2014 06:51:04 -0000 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.