Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Mar 2014 23:30:01 GMT
From:      Jilles Tjoelker <jilles@stack.nl>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/187264: rm command: rm -r file1 file2 &quot;&quot; does not remove existing files or directories
Message-ID:  <201403042330.s24NU1m2020290@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/187264; it has been noted by GNATS.

From: Jilles Tjoelker <jilles@stack.nl>
To: bug-followup@FreeBSD.org, jlw@xinuos.com
Cc:  
Subject: Re: bin/187264: rm command: rm -r file1 file2 &quot;&quot; does not
 remove existing files or directories
Date: Wed, 5 Mar 2014 00:23:15 +0100

 In PR bin/187264, you wrote:
 > When the gmake/make clean target contains a command of the form
 
 > rm -rf "a.out" "$(DSYM)" main.o main.d
 
 > the command fails to remove any of the existing files if DSYM is null.
 > The '-f' option hides the error associated with the zero length file
 > name, but gives no indication that, in fact, NO files/directories have
 > been removed.
 
 I can reproduce this, not only with rm, but also with ls, cp and find.
 The underlying fts_open(3) fails if any pathname is empty and causes the
 entire command to fail. If a pathname otherwise does not refer to an
 existing file, this correctly does not prevent processing of other
 pathnames.
 
 The below patch makes fts_open(3) treat an empty pathname like any other
 pathname that cannot be lstatted because of [ENOENT]. It is lightly
 tested.
 
 Index: lib/libc/gen/fts.c
 ===================================================================
 --- lib/libc/gen/fts.c	(revision 262358)
 +++ lib/libc/gen/fts.c	(working copy)
 @@ -161,11 +161,7 @@ fts_open(argv, options, compar)
  
  	/* Allocate/initialize root(s). */
  	for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) {
 -		/* Don't allow zero-length paths. */
 -		if ((len = strlen(*argv)) == 0) {
 -			errno = ENOENT;
 -			goto mem3;
 -		}
 +		len = strlen(*argv);
  
  		p = fts_alloc(sp, *argv, len);
  		p->fts_level = FTS_ROOTLEVEL;
 
 -- 
 Jilles Tjoelker



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