bin/92149: [patch] ln -f -s does not remove existing directory

Gleb Smirnoff glebius at FreeBSD.org
Wed Jan 25 04:10:15 PST 2006


The following reply was made to PR bin/92149; it has been noted by GNATS.

From: Gleb Smirnoff <glebius at FreeBSD.org>
To: Eugene Grosbein <eugen at grosbein.pp.ru>
Cc: freebsd-gnats-submit at FreeBSD.org
Subject: Re: bin/92149: [patch] ln -f -s does not remove existing directory
Date: Wed, 25 Jan 2006 15:06:49 +0300

 On Mon, Jan 23, 2006 at 11:40:06AM +0000, Eugene Grosbein wrote:
 E>  On Mon, Jan 23, 2006 at 11:53:36AM +0300, Gleb Smirnoff wrote:
 E>  
 E>  > E> 	"ln -f -s" may be used to create a symlink to the file and
 E>  > E> 	the target file will be unlinked if it exists.
 E>  > E> 
 E>  > E> 	However, ln will fail with 'Operation not permitted' message
 E>  > E> 	when target is a directory because unlink(2) does not remove
 E>  > E> 	empty directories.
 E>  > 
 E>  > I think that the current behavior is standard, while suggested behavior
 E>  > is going to violate SUSv3. At least I understand the standard this way:
 E>  > 
 E>  >   If the destination path exists:
 E>  > 
 E>  >    1.	If the -f option is not specified, ln shall write a diagnostic message
 E>  > 	to standard error, do nothing more with the current source_file, and go
 E>  > 	on to any remaining source_files.
 E>  >    2.	Actions shall be performed equivalent to the unlink() function defined in
 E>  > 	the System Interfaces volume of IEEE Std 1003.1-2001, called using
 E>  > 	destination as the path argument. If this fails for any reason, ln shall
 E>  > 	write a diagnostic message to standard error, do nothing more with the
 E>  > 	current source_file, and go on to any remaining source_files.
 E>  > 
 E>  >  http://www.opengroup.org/onlinepubs/000095399/utilities/ln.html
 E>  
 E>  Then I'd like to introduce new command line option enabling desired
 E>  behavour. Should I correct the patch?
 
 Yes, I think this will be acceptable.
 
 -- 
 Totus tuus, Glebius.
 GLEBIUS-RIPN GLEB-RIPE


More information about the freebsd-bugs mailing list