Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Feb 2010 12:25:56 -0800
From:      Garrett Cooper <yanefbsd@gmail.com>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Poul-Henning Kamp <phk@freebsd.org>
Subject:   Re: svn commit: r203990 - head/lib/libc/sys
Message-ID:  <7d6fde3d1002171225n5b6ebc2eyb85ffbfacb594da9@mail.gmail.com>
In-Reply-To: <20100218055229.Q1735@besplex.bde.org>
References:  <201002170911.o1H9BL6m095996@svn.freebsd.org> <20100218044931.S95007@delplex.bde.org> <20100218055229.Q1735@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Feb 17, 2010 at 11:13 AM, Bruce Evans <brde@optusnet.com.au> 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



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