From owner-svn-src-head@FreeBSD.ORG Wed Feb 17 19:13:50 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15242106568D; Wed, 17 Feb 2010 19:13:49 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail06.syd.optusnet.com.au (mail06.syd.optusnet.com.au [211.29.132.187]) by mx1.freebsd.org (Postfix) with ESMTP id 8A5228FC26; Wed, 17 Feb 2010 19:13:49 +0000 (UTC) Received: from besplex.bde.org (c122-106-163-215.carlnfd1.nsw.optusnet.com.au [122.106.163.215]) by mail06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o1HJDjc0021896 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 18 Feb 2010 06:13:47 +1100 Date: Thu, 18 Feb 2010 06:13:45 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Bruce Evans In-Reply-To: <20100218044931.S95007@delplex.bde.org> Message-ID: <20100218055229.Q1735@besplex.bde.org> References: <201002170911.o1H9BL6m095996@svn.freebsd.org> <20100218044931.S95007@delplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Poul-Henning Kamp Subject: Re: svn commit: r203990 - head/lib/libc/sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 19:13:50 -0000 On Thu, 18 Feb 2010, Bruce Evans wrote: > On Wed, 17 Feb 2010, Poul-Henning Kamp wrote: > >> Log: >> Mention EISDIR as a possible errno. > > It's not a possible error. > >> ... Related bug: unlink(1) bogusly prints a messages that looks like strerror(EISDIR). It doesn't even try unlink(2) on directories, but prints this message from a private string. %%% Script started on Thu Feb 18 05:49:45 2010 ttyp0:bde@besplex:/tmp/z> mkdir z ttyp0:bde@besplex:/tmp/z> /bin/unlink z unlink: z: is a directory ttyp0:bde@besplex:/tmp/z> truss /bin/unlink z lstat("z",0xbfbfe840) = 0 (0x0) unlink: write(2,0xbfbfe0b0,8) = 8 (0x8) z: is a directorywrite(2,0xbfbfe0d0,17) = 17 (0x11) write(2,0x80a6753,1) = 1 (0x1) exit(0x1) process exit, rval = 256 %%% Here I use /bin/unlink since the unlink in $PATH is missing the bug. /bin/unlink is a link to /bin/rm. rm(1) takes a -d flag which should do the right thing for unlink, but this flag is neither settable nor forced for unlink(1). The above behaviour of unlink(1) is not permitted by POSIX or unlink(1)'s man page: POSIX (old draft, no change in current version): %%% 36900 The unlink utility shall perform the function call: 36901 unlink(file); 36902 A user may need appropriate privilege to invoke the unlink utility. %%% Man page: %%% When the utility is called as unlink, only one argument, which must not be a directory, may be supplied. No options may be supplied in this sim- ple mode of operation, which performs an unlink(2) operation on the passed argument. STANDARDS The rm command conforms to IEEE Std 1003.2 (``POSIX.2''). The simplified unlink command conforms to Version 2 of the Single UNIX Specification (``SUSv2''). %%% Oops, the man page actually says that the arg must not be a directory. POSIX doesn't make this restriction, except by possibly requiring appropriate privilege, which can be interpreted as "more privilege than exists" if the file is a directory so as to make FreeBSD conform (except the error must involve unlink(1) not being invokable in this case :-). POSIX doesn't specify the form of the diagnostic message for any case. Anyway, unlink(1) shouldn't fall into rm(1)'s error handling to to print its diagnostic. It should use a special message (matching its man page) for directories, or just try unlink(2). rm(1)'s current special message should say something about directory removal requiring -d, and not look like strerror(EISDIR). Or since directory removal is prohibited by the kernel, the -d option can never work, so it should have been removed ~10 years ago when the kernel was changed to prohibit it. Bruce