Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Apr 2020 10:26:20 +0200
From:      =?UTF-8?Q?Fernando_Apestegu=C3=ADa?= <fernando.apesteguia@gmail.com>
To:        Matthias Apitz <guru@unixarea.de>, User Questions <freebsd-questions@freebsd.org>
Subject:   Re: find(1) removes as it should a directory, but after this it complains about
Message-ID:  <CAGwOe2Z5hnkf4B0cJeRpvWqfOxnaKBz6dv%2BKne8MnedQ4otuOg@mail.gmail.com>
In-Reply-To: <20200420081627.GA30229@sh4-5.1blu.de>
References:  <20200420081627.GA30229@sh4-5.1blu.de>

next in thread | previous in thread | raw e-mail | index | archive | help
El lun., 20 abr. 2020 10:16, Matthias Apitz <guru@unixarea.de> escribi=C3=
=B3:

> Hello,
>
> I've stumbled over something with find(1) which I would call a bug:
>
> $ mkdir foo
> $ find foo -type d -execdir rm -rv {} \;
> foo
> find: foo: No such file or directory
> $ ls -ld foo
> ls: foo: No such file or directory
>
> I truss'ed the find(1) and it starts as it should a child process like
> 'rm -rv foo', but when this ends correctly, find tries to open again the
> dir foo:
>
> $ truss -f -o find.tr find foo -type d -execdir rm -rv {} \;
> foo
> find: foo: No such file or directory
> $ grep foo find.tr
>  2107: fstatat(AT_FDCWD,"foo",{ mode=3Ddrwxr-xr-x
> ,inode=3D4099842,size=3D512,blksize=3D32768 },AT_SYMLINK_NOFOLLOW) =3D 0 =
(0x0)
>  2108: fstatat(AT_FDCWD,"foo",{ mode=3Ddrwxr-xr-x
> ,inode=3D4099842,size=3D512,blksize=3D32768 },AT_SYMLINK_NOFOLLOW) =3D 0 =
(0x0)
>  2108: access("foo",W_OK)                        =3D 0 (0x0)
>  2108: open("foo",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,03) =3D 4 (0x=
4)
>  2108: rmdir("foo")                              =3D 0 (0x0)
>  2108: write(1,"foo\n",4)                        =3D 4 (0x4)
>  2107: open("foo",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,03) ERR#2 'No
> such file or directory'
>  2107: write(2,"foo: No such file or directory",30) =3D 30 (0x1e)
>
> Is this by intention?
>

Not sure it is, but GNU find (as of findutils 4.5.12) has the same behavior=
.

As workaround, would -delete work fo you?

find foo -type d -delete

Cheers.


>         matthias
>
>
> --
> Matthias Apitz, =E2=9C=89 guru@unixarea.de, http://www.unixarea.de/
> +49-176-38902045
> Public GnuPG key: http://www.unixarea.de/key.pub
> May, 9: =D0=A1=D0=BF=D0=B0=D1=81=D0=B8=CC=81=D0=B1=D0=BE =D0=BE=D1=81=D0=
=B2=D0=BE=D0=B1=D0=BE=D0=B4=D0=B8=D1=82=D0=B5=D0=BB=D0=B8! Thank you very m=
uch, Russian liberators!
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "
> freebsd-questions-unsubscribe@freebsd.org"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGwOe2Z5hnkf4B0cJeRpvWqfOxnaKBz6dv%2BKne8MnedQ4otuOg>