Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Apr 2020 10:16:27 +0200
From:      Matthias Apitz <guru@unixarea.de>
To:        freebsd-questions@freebsd.org
Subject:   find(1) removes as it should a directory, but after this it complains about
Message-ID:  <20200420081627.GA30229@sh4-5.1blu.de>

next in thread | raw e-mail | index | archive | help
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?

	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!



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