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

Gleb Smirnoff glebius at FreeBSD.org
Mon Jan 23 01:00:23 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: Mon, 23 Jan 2006 11:53:36 +0300

 E> >Description:
 E> 
 E> 	"ln -f -s" may be used to create a symlink to the file and
 E> 	the target file will be unlinked if it exists.
 E> 
 E> 	However, ln will fail with 'Operation not permitted' message
 E> 	when target is a directory because unlink(2) does not remove
 E> 	empty directories.
 
 I think that the current behavior is standard, while suggested behavior
 is going to violate SUSv3. At least I understand the standard this way:
 
   If the destination path exists:
 
    1.	If the -f option is not specified, ln shall write a diagnostic message
 	to standard error, do nothing more with the current source_file, and go
 	on to any remaining source_files.
    2.	Actions shall be performed equivalent to the unlink() function defined in
 	the System Interfaces volume of IEEE Std 1003.1-2001, called using
 	destination as the path argument. If this fails for any reason, ln shall
 	write a diagnostic message to standard error, do nothing more with the
 	current source_file, and go on to any remaining source_files.
 
  http://www.opengroup.org/onlinepubs/000095399/utilities/ln.html
 
 -- 
 Totus tuus, Glebius.
 GLEBIUS-RIPN GLEB-RIPE


More information about the freebsd-bugs mailing list