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ó:
> 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=drwxr-xr-x
> ,inode=4099842,size=512,blksize=32768 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
> 2108: fstatat(AT_FDCWD,"foo",{ mode=drwxr-xr-x
> ,inode=4099842,size=512,blksize=32768 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
> 2108: access("foo",W_OK) = 0 (0x0)
> 2108: open("foo",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,03) = 4 (0x4)
> 2108: rmdir("foo") = 0 (0x0)
> 2108: write(1,"foo\n",4) = 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) = 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, ✉ guru@unixarea.de, http://www.unixarea.de/
> +49-176-38902045
> Public GnuPG key: http://www.unixarea.de/key.pub
> May, 9: Спаси́бо освободители! Thank you very much, 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>
