rmdir removes plain files over NFS

Tony Robinson (ajr@softsound.com)
26 Jan 1997 08:54:02 +0000


The rmdir() call should return "Not a directory" when asked to remove a
plain file. Over NFS it deletes it.

Example:

beard$: touch /tmp/tmpFile
beard$: rmdirBug /tmp/tmpFile
rmdir returned: -1
rmdirBug: Not a directory

beard$ touch /amd/spud/export/home/spud5/ajr/tmpFile
beard$ rmdirBug /amd/spud/export/home/spud5/ajr/tmpFile
rmdir returned: 0

strace confirms that rmdir() is returnign 0:

beard ajr: strace rmdirBug /amd/spud/export/home/spud5/ajr/tmpFile
...
getegid() = 16000
rmdir("/amd/spud/export/home/spud5/ajr/tmpFile") = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(4, 193), ...}) = 0

/amd/spud/export/home/spud5/ajr is my amd automounted home directory:

beard$ mount
/dev/hda3 on / type ext2 (rw)
/proc on /proc type proc (rw)
...
beard:(pid123) on /home type auto
(intr,rw,port=1023,timeo=8,retrans=110,indirect,map=/usr/local/etc/amd.home)
...
spud:/export/home/spud5 on /amd/spud/export/home/spud5 type nfs (rw)

The source to rmdirBug is simply:

beard: cat rmdirBug.c
# include <stdio.h>

int main(int argc, char **argv) {
int retVal;

/* should set errno to ENOTDIR for files */
retVal = rmdir(argv[1]);

printf("rmdir returned: %d\n", retVal);

if(retVal != 0)
perror(argv[0]);

exit(0);
}

which was written as I originally thought the problem was in /bin/rmdir.

The machine beard, used in the example above is a dual processor Pentium
Pro recently installed with Debian 1.2.4. It is running kernel version
2.0.28.

I first noticed the problem about a month ago on a Pentium running
2.0.27 and various versions of Debian. This bug has been run though the
various Debian bug lists (Bug#5945) before being reported here.

Tony Robinson

--
http://www.softsound.demon.co.uk/
email ajr@softsound.com
Fax   +44-1223-740026