From owner-freebsd-bugs@FreeBSD.ORG Mon Jan 23 06:10:11 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E5BE016A41F for ; Mon, 23 Jan 2006 06:10:11 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id B353743D46 for ; Mon, 23 Jan 2006 06:10:11 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k0N6ABLN066470 for ; Mon, 23 Jan 2006 06:10:11 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k0N6AAWQ066469; Mon, 23 Jan 2006 06:10:10 GMT (envelope-from gnats) Date: Mon, 23 Jan 2006 06:10:10 GMT Message-Id: <200601230610.k0N6AAWQ066469@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Eugene Grosbein Cc: Subject: Re: bin/92149 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Eugene Grosbein List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jan 2006 06:10:12 -0000 The following reply was made to PR bin/92149; it has been noted by GNATS. From: Eugene Grosbein To: bug-followup@freebsd.org Cc: Subject: Re: bin/92149 Date: Mon, 23 Jan 2006 13:08:07 +0700 Hi! Sorry, I've sent wrong (buggy) version of patch, here is right one. --- ln.c.orig Sun Jan 22 20:05:44 2006 +++ ln.c Mon Jan 23 12:47:00 2006 @@ -198,9 +198,17 @@ /* * If the file exists, then unlink it forcibly if -f was specified * and interactively if -i was specified. + * + * For the directory, remove it when dealing with symbolic link only. */ if (fflag && exists) { - if (unlink(source)) { + if (S_ISDIR(sb.st_mode)) { + if (sflag && rmdir(source)) { + warn("%s", source); + return (1); + } + } + else if (unlink(source)) { warn("%s", source); return (1); } @@ -216,7 +224,13 @@ return (1); } - if (unlink(source)) { + if (S_ISDIR(sb.st_mode)) { + if (sflag && rmdir(source)) { + warn("%s", source); + return (1); + } + } + else if (unlink(source)) { warn("%s", source); return (1); } --- ln.1.orig Sun Jan 22 20:18:12 2006 +++ ln.1 Mon Jan 23 12:44:28 2006 @@ -69,8 +69,12 @@ The options are as follows: .Bl -tag -width flag .It Fl f -If the target file already exists, -then unlink it so that the link may occur. +If the target file or (empty) directory already exists, +then remove it so that the link may occur. +Note that no attempt to remove the directory is performed +when running without the +.Fl s +option. (The .Fl f option overrides any previous