From owner-svn-src-all@FreeBSD.ORG Wed Feb 17 20:25:58 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5883510656AE; Wed, 17 Feb 2010 20:25:58 +0000 (UTC) (envelope-from yanefbsd@gmail.com) Received: from mail-px0-f182.google.com (mail-px0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 169368FC21; Wed, 17 Feb 2010 20:25:57 +0000 (UTC) Received: by pxi12 with SMTP id 12so5105351pxi.33 for ; Wed, 17 Feb 2010 12:25:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=g8V05duK29zLGbrB6RmVYN72OVZ4sgspfE0UtXip8aw=; b=dEZkluGqVu1SVKZgkfR7FCI01Jf41TpazNGLX8Ff5tckGP9vWGXNEKPNM5B7L1jlR2 RRbVJBYaOpKrwUC7N/Wxfne2J0EH/2BGpPC4YRkylRnCZM3aWOzVBC9q7A/j4F44h0bj IO8SDW/8wjPgRV4vqRXcevHyZZf1eG6SCGsYA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=HgLSwVZZgps8bFvPWTNinH1wZEdCXrmvqZ5cnCp/aTmRjPPW8qV7B6u3bVGeVDW1eV qA0nnk6iG5RMq0vcyx1UmPc10zUw4q/zDWlsUqcnjfK4IhfrLgHw5otchZsYlj6tay9r YlDPkb6Dh9tM2fh+DJxaOI6dd/pc8v9+Pr+sk= MIME-Version: 1.0 Received: by 10.143.24.10 with SMTP id b10mr1830610wfj.253.1266438356370; Wed, 17 Feb 2010 12:25:56 -0800 (PST) In-Reply-To: <20100218055229.Q1735@besplex.bde.org> References: <201002170911.o1H9BL6m095996@svn.freebsd.org> <20100218044931.S95007@delplex.bde.org> <20100218055229.Q1735@besplex.bde.org> Date: Wed, 17 Feb 2010 12:25:56 -0800 Message-ID: <7d6fde3d1002171225n5b6ebc2eyb85ffbfacb594da9@mail.gmail.com> From: Garrett Cooper To: Bruce Evans Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Feb 2010 20:25:58 -0000 On Wed, Feb 17, 2010 at 11:13 AM, Bruce Evans wrote: > On Thu, 18 Feb 2010, Bruce Evans wrote: > >> On Wed, 17 Feb 2010, Poul-Henning Kamp wrote: >> >>> Log: >>> =A0Mention EISDIR as a possible errno. >> >> It's not a possible error. >> >>> ... > > Related bug: unlink(1) bogusly prints a messages that looks like > strerror(EISDIR). =A0It 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) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0=3D 0 (0x0) > unlink: write(2,0xbfbfe0b0,8) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0=3D 8 (0x8) > z: is a directorywrite(2,0xbfbfe0d0,17) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0=3D 17 (0x11) > > write(2,0x80a6753,1) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =3D 1 (0x1) > exit(0x1) process exit, rval =3D 256 > %%% > > Here I use /bin/unlink since the unlink in $PATH is missing the bug. > > /bin/unlink is a link to /bin/rm. =A0rm(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 =A0 =A0 =A0 =A0 =A0 =A0The unlink utility shall perform the functio= n call: > 36901 =A0 =A0 =A0 =A0 =A0 =A0unlink(file); > 36902 =A0 =A0 =A0 =A0 =A0 =A0A user may need appropriate privilege to inv= oke the unlink > utility. > %%% > > Man page: > %%% > =A0 =A0 When the utility is called as unlink, only one argument, which mu= st not > =A0 =A0 be a directory, may be supplied. =A0No options may be supplied in= this > sim- > =A0 =A0 ple mode of operation, which performs an unlink(2) operation on t= he > =A0 =A0 passed argument. > > STANDARDS > =A0 =A0 The rm command conforms to IEEE Std 1003.2 (``POSIX.2''). > > =A0 =A0 The simplified unlink command conforms to Version 2 of the Single= UNIX > =A0 =A0 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 :-). =A0POSIX 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. =A0It 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). =A0Or 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. 1. Where is EISDIR used in rm(1)? [garrcoop@garrcoop-fbsd /usr/src/sys]$ grep EISDIR ../bin/rm/rm.c [garrcoop@garrcoop-fbsd /usr/src/sys]$ uname -a FreeBSD garrcoop-fbsd.cisco.com 8.0-STABLE FreeBSD 8.0-STABLE #2: Wed Feb 3 16:57:07 PST 2010 garrcoop@garrcoop-fbsd.cisco.com:/usr/obj/usr/src/sys/LAPPY_X86 i386 2. phk's example in a latter email used unlink(2), not unlink(1). Thanks, -Garrett