Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jan 2006 06:10:10 GMT
From:      Eugene Grosbein <eugen@kuzbass.ru>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/92149
Message-ID:  <200601230610.k0N6AAWQ066469@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/92149; it has been noted by GNATS.

From: Eugene Grosbein <eugen@kuzbass.ru>
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200601230610.k0N6AAWQ066469>