NetBSD Problem Report #41736

From www@NetBSD.org  Thu Jul 16 00:23:46 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 9DDA263BADF
	for <gnats-bugs@gnats.netbsd.org>; Thu, 16 Jul 2009 00:23:46 +0000 (UTC)
Message-Id: <20090716002346.62ECA63B883@www.NetBSD.org>
Date: Thu, 16 Jul 2009 00:23:46 +0000 (UTC)
From: lloyd@must-have-coffee.gen.nz
Reply-To: lloyd@must-have-coffee.gen.nz
To: gnats-bugs@NetBSD.org
Subject: pax reports an error when copying zero files
X-Send-Pr-Version: www-1.0

>Number:         41736
>Category:       bin
>Synopsis:       pax reports an error when copying zero files
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lukem
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 16 00:25:00 +0000 2009
>Closed-Date:    Sun May 28 17:02:58 +0000 2023
>Last-Modified:  Sun May 28 17:05:00 +0000 2023
>Originator:     Lloyd Parkes
>Release:        5.99.12
>Organization:
Must Have Coffee
>Environment:
NetBSD rhox.must-have-coffee.gen.nz 5.0 NetBSD 5.0 (GENERIC) #0: Wed Jun  3 19:08:54 NZST 2009  lloyd@homarid.must-have-coffee.gen.nz:/vol/scratch/obj5/amd64/sys/arch/amd64/compile/GENERIC amd64
>Description:
If pax is run in copy mode and the list of files to copy is empty, then pax's exit status is 1. It should be 0. 


>How-To-Repeat:
pax -rw . < /dev/null
echo $?

>Fix:

>Release-Note:

>Audit-Trail:
From: Lloyd Parkes <lloyd@must-have-coffee.gen.nz>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/41736: pax reports an error when copying zero files
Date: Thu, 16 Jul 2009 13:24:58 +1200

 The following patch fixes the problem.

 ftree_arg() returns 0 if there are more files to process and -1 if  
 there aren't. The old code in ftree_start() considers a lack of files  
 to be an error. This patch just makes it return (slightly) early  
 instead of signalling an error.

 Index: bin/pax/ftree.c
 ===================================================================
 RCS file: /vol/src/rsync-src/src/bin/pax/ftree.c,v
 retrieving revision 1.40
 diff -u -r1.40 ftree.c
 --- ftree.c     14 Feb 2009 08:10:06 -0000      1.40
 +++ ftree.c     16 Jul 2009 01:18:34 -0000
 @@ -194,7 +194,7 @@
          }

          if (ftree_arg() < 0)
 -               return -1;
 +               return 0;       /* Nothing to do, so stop now. */
          if (tflag && (atdir_start() < 0))
                  return -1;
          return 0;

Responsible-Changed-From-To: bin-bug-people->lukem
Responsible-Changed-By: lukem@NetBSD.org
Responsible-Changed-When: Sun, 28 May 2023 17:02:58 +0000
Responsible-Changed-Why:


State-Changed-From-To: open->closed
State-Changed-By: lukem@NetBSD.org
State-Changed-When: Sun, 28 May 2023 17:02:58 +0000
State-Changed-Why:

Applied your change, as it seems sensible and correct.
I double checked POSIX and didn't seem that we need to exit non-zero
in this case


From: "Luke Mewburn" <lukem@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/41736 CVS commit: src/bin/pax
Date: Sun, 28 May 2023 17:01:46 +0000

 Module Name:	src
 Committed By:	lukem
 Date:		Sun May 28 17:01:46 UTC 2023

 Modified Files:
 	src/bin/pax: ftree.c

 Log Message:
 pax: exit 0 if stdin filelist is used and empty

 If copying a list of files from stdin, exit zero instead of non-zero
 if there are no files supplied.

 AFAICT, POSIX doesn't require a non-zero an error in this situation,
 since there are no files to not match.

 Fix from PR bin/41736 by Lloyd Parkes.


 To generate a diff of this commit:
 cvs rdiff -u -r1.42 -r1.43 src/bin/pax/ftree.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.