Subject: Re: pax problem+fix
To: None <jsb@nil.at>
From: Ben Harris <bjh21@netbsd.org>
List: tech-userlevel
Date: 06/21/2003 20:17:38
In article <20030621112432.GA25245@atnet.at> you write:
>As pax does not treat '.' specially, it checks if
>$(DESTDIR)$(TARGET_DIR)/tutorial/. exists, which is the case, and
>then tries to remove it.
>
>On BSD, rmdir("directory/.") gives an Invalid Argument error.
>(I've actually only tried this on FreeBSD as my NetBSD machine
>is currently broken :( )
>
>On Linux, when the ext2 filesysteme is used (but not with xfs),
>the rmdir command succeeds and causes pax to enter an infinite
>loop where it repeatedly creates and removes the target directory:

This is a bug in Linux.  Attempting to remove "." is guaranteed to fail by
POSIX.  If you upgrade to Linux 2.4, I believe the problem will go away.

>The attached patch (against the version of the pkgsrc-bootstrap-kit, but
>imho it should apply to the /src/bin/pax version as well) fixes the problem
>by checking against 'dir/.' in unlnk_exist() (file_subs.c).

My, rather simpler patch, is at
<http://www.tartarus.org/~ben/netbsd/patches/rmdir.patch>.  I haven't
committed it on the grounds that it seems wrong to have to work around other
OSes' bugs in our source.

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/acorn26           <URL:http://www.netbsd.org/Ports/acorn26/>