From adrian@FreeBSD.org Thu Apr 29 12:41:17 1999
Return-Path: <adrian@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21])
	by hub.freebsd.org (Postfix) with ESMTP id 56B69153B4
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 29 Apr 1999 12:41:15 -0700 (PDT)
	(envelope-from adrian@FreeBSD.org)
Received: (from adrian@localhost)
	by freefall.freebsd.org (8.9.3/8.9.2) id MAA14341;
	Thu, 29 Apr 1999 12:41:16 -0700 (PDT)
	(envelope-from adrian@FreeBSD.org)
Message-Id: <199904291941.MAA14341@freefall.freebsd.org>
Date: Thu, 29 Apr 1999 12:41:16 -0700 (PDT)
From: <adrian@FreeBSD.org>
Reply-To: adrian@FreeBSD.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: tar reports incorrect total bytes written on >2 gig tars.
X-Send-Pr-Version: 3.2

>Number:         11389
>Category:       gnu
>Synopsis:       tar reports incorrect total bytes written on >2 gig tars.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 29 12:50:00 PDT 1999
>Closed-Date:    Thu Apr 29 13:00:53 PDT 1999
>Last-Modified:  Thu Apr 29 13:01:16 PDT 1999
>Originator:     Adrian Chadd
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:

-current box build as of yesterday.


>Description:

Tar uses a int to store the bytes written count. This wraps at 2gig on the
i386 platform.

>How-To-Repeat:

Create a tar with --totals with a size over 2 gig, and watch what is reported
by tar at the end.

>Fix:

Change the counter to a u_quad_t using the following diff.

diff -u -r -P /usr/src/gnu/usr.bin/tar/tar.c tar/tar.c
--- /usr/src/gnu/usr.bin/tar/tar.c	Mon Jul 27 20:40:08 1998
+++ tar/tar.c	Tue Apr  6 20:02:47 1999
@@ -231,7 +231,7 @@
     case CMD_CREATE:
       create_archive ();
       if (f_totals)
-	fprintf (stderr, "Total bytes written: %d\n", tot_written);
+	fprintf (stderr, "Total bytes written: %qu\n", tot_written);
       break;
     case CMD_EXTRACT:
       if (f_volhdr)
diff -u -r -P /usr/src/gnu/usr.bin/tar/tar.h tar/tar.h
--- /usr/src/gnu/usr.bin/tar/tar.h	Mon Jul 27 20:40:09 1998
+++ tar/tar.h	Tue Apr  6 20:04:31 1999
@@ -22,6 +22,12 @@
 #include <sys/mknod.h>
 #endif
 
+/* 
+ * We need to include <sys/types.h> for the u_quad_t definition
+ */
+
+#include <sys/types.h>
+
 /*
  * Kludge for handling systems that can't cope with multiple
  * external definitions of a variable.  In ONE routine (tar.c),
@@ -168,7 +174,7 @@
 TAR_EXTERN char *tar;		/* Name of this program */
 TAR_EXTERN struct sp_array *sparsearray;	/* Pointer to the start of the scratch space */
 TAR_EXTERN int sp_array_size;	/* Initial size of the sparsearray */
-TAR_EXTERN int tot_written;	/* Total written to output */
+TAR_EXTERN u_quad_t tot_written;	/* Total written to output */
 TAR_EXTERN struct re_pattern_buffer
  *label_pattern;		/* compiled regex for extract label */
 TAR_EXTERN char **ar_files;	/* list of tape drive names */

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: peter 
State-Changed-When: Thu Apr 29 13:00:53 PDT 1999 
State-Changed-Why:  
Suggested changes applied 
>Unformatted:
