Re: rmdir problem with remove("foo/.")

Arvind Sankar (arvinds@mit.edu)
Fri, 26 Mar 1999 17:18:09 -0500


On Fri, Mar 26, 1999 at 10:36:40PM +0100, Guest section DW wrote:
> From: Greg Wolodkin <greg@mathworks.com>
>
> [1.] glibc remove("foo/.") removes foo with 2.2.2, not with 2.0.36
> [2.] Full description:
>
> I ran into this problem on a Debian 2.1 system that had been
> upgraded to the 2.2.2 kernel. I was able to "fix" the problem
> by going back to the 2.0.36 kernel. I saw some related threads
> (adding special cases for "." and ".." in rmdir) but nothing
> exactly like what I'm seeing.
>
> >From the man page for remove(3), directories should remain intact.
> This simple C program proves otherwise with the 2.2.2 kernel.
>
> #include <stdio.h>
> void main (void) { remove("foo/."); }
>
> At first I suspected glibc but traced the remove function there
> back to an rmdir system call.
>
> You are being inconsistent.
> If remove() is documented not to remove directories,
> but it calls rmdir() then that must be a glibc bug.
>
> There is nothing very wrong with rmdir removing "foo/.".
>
> (And we just had a thread about this. Look at the archives.)
>

Indeed. The man page is out of date: The info file for glibc 2.1
says:
- Function: int remove (const char *FILENAME)
This is the ISO C function to remove a file. It works like
`unlink' for files and like `rmdir' for directories. `remove' is
declared in `stdio.h'.

-- arvind

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/