-  "$FreeBSD: /repoman/r/ncvs/src/sbin/growfs/debug.c,v 1.9 2004/04/03 17:40:19 le Exp $";
+  "$FreeBSD: /repoman/r/ncvs/src/sbin/growfs/debug.c,v 1.10 2006/10/31 22:02:24 pjd Exp $";
 #endif /* not lint */
 
 /* ********************************************************** INCLUDES ***** */
@@ -281,6 +281,8 @@
  */
 	fprintf(dbg_log, "maxbsize          int32_t          0x%08x\n",
 	    sb->fs_maxbsize);
+	fprintf(dbg_log, "unrefs            int64_t          0x%08x\n",
+	    sb->fs_unrefs);
 	fprintf(dbg_log, "sblockloc         int64_t          0x%08x%08x\n",
 		((unsigned int *)&(sb->fs_sblockloc))[1],
 		((unsigned int *)&(sb->fs_sblockloc))[0]);
@@ -399,6 +401,7 @@
 	    cgr->cg_nclusterblks);
 	fprintf(dbg_log, "niblk         int32_t    0x%08x\n", cgr->cg_niblk);
 	fprintf(dbg_log, "initediblk    int32_t    0x%08x\n", cgr->cg_initediblk);
+	fprintf(dbg_log, "unrefs        int32_t    0x%08x\n", cgr->cg_unrefs);
 	fprintf(dbg_log, "time          ufs_time_t %10u\n", 
 		(unsigned int)cgr->cg_initediblk);
 
diff -u growfs/debug.h growfs.edit/debug.h
--- growfs/debug.h	Tue Jul  6 13:48:34 2004
+++ growfs.edit/debug.h	Tue Jul  6 13:48:34 2004
@@ -36,7 +36,7 @@
  * SUCH DAMAGE.
  *
  * $TSHeader: src/sbin/growfs/debug.h,v 1.2 2000/11/16 18:43:50 tom Exp $
- * $FreeBSD: src/sbin/growfs/debug.h,v 1.3 2004/07/06 17:48:34 stefanf Exp $
+ * $FreeBSD: /repoman/r/ncvs/src/sbin/growfs/debug.h,v 1.3 2004/07/06 17:48:34 stefanf Exp $
  *
  */
 
diff -u growfs/growfs.c growfs.edit/growfs.c
--- growfs/growfs.c	Sun Jan 16 09:37:30 2005
+++ growfs.edit/growfs.c	Fri May 25 07:25:32 2007
@@ -47,7 +47,7 @@
 #endif /* not lint */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sbin/growfs/growfs.c,v 1.24 2005/01/16 14:37:30 charnier Exp $");
+__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sbin/growfs/growfs.c,v 1.25 2006/07/17 20:48:36 stefanf Exp $");
 
 /* ********************************************************** INCLUDES ***** */
 #include <sys/param.h>
@@ -87,7 +87,7 @@
 /*
  * Possible superblock locations ordered from most to least likely.
  */
-static int sblock_try[] = SBLOCKSEARCH;
+static intmax_t sblock_try[] = SBLOCKSEARCH;
 static ufs2_daddr_t sblockloc;
 
 static union {
@@ -156,7 +156,7 @@
 static void	updrefs(int, ino_t, struct gfs_bpp *, int, int, unsigned int);
 static void	indirchk(ufs_lbn_t, ufs_lbn_t, ufs2_daddr_t, ufs_lbn_t,
 		    struct gfs_bpp *, int, int, unsigned int);
-static void	get_dev_size(int, int *);
+static void   get_dev_size(int, u_int64_t *);
 
 /* ************************************************************ growfs ***** */
 /*
@@ -259,8 +259,8 @@
 	 */
 	for (cylno = osblock.fs_ncg; cylno < sblock.fs_ncg; cylno++) {
 		initcg(cylno, utime, fso, Nflag);
-		j = sprintf(tmpbuf, " %d%s",
-		    (int)fsbtodb(&sblock, cgsblock(&sblock, cylno)),
+		j = sprintf(tmpbuf, " %jd%s",
+		    (intmax_t)fsbtodb(&sblock, cgsblock(&sblock, cylno)),
 		    cylno < (sblock.fs_ncg-1) ? "," : "" );
 		if (i + j >= width) {
 			printf("\n");
@@ -631,7 +631,6 @@
 
 	DBG_ENTER;
 
-	f = field;
 	for (f = field; f->old != 0; f++) {
 		src = *block;
 		if (fragstoblks(&sblock, src) != f->old)
@@ -1925,7 +1924,7 @@
  * e.g. from vinum volumes.
  */
 static void
-get_dev_size(int fd, int *size)
+get_dev_size(int fd, u_int64_t *size)
 {
    int sectorsize;
    off_t mediasize;
@@ -1970,7 +1969,7 @@
 	DBG_FUNC("main")
 	char	*device, *special, *cp;
 	int	ch;
-	unsigned int	size=0;
+	u_int64_t	size=0;
 	size_t	len;
 	unsigned int	Nflag=0;
 	int	ExpertFlag=0;
@@ -1978,7 +1977,7 @@
 	struct disklabel	*lp;
 	struct partition	*pp;
 	int	i,fsi,fso;
-    u_int32_t p_size;
+     u_int64_t p_size;
 	char	reply[5];
 #ifdef FSMAXSNAP
 	int	j;
@@ -2129,7 +2128,7 @@
 	sblock.fs_size = dbtofsb(&osblock, p_size);
 	if (size != 0) {
 		if (size > p_size){
-			errx(1, "there is not enough space (%d < %d)",
+		errx(1, "there is not enough space (%lX < %lX)",
 			    p_size, size);
 		}
 		sblock.fs_size = dbtofsb(&osblock, size);
@@ -2217,7 +2216,7 @@
 			sblock.fs_old_ncyl = sblock.fs_ncg * sblock.fs_old_cpg;
 		printf("Warning: %jd sector(s) cannot be allocated.\n",
 		    (intmax_t)fsbtodb(&sblock, sblock.fs_size % sblock.fs_fpg));
-		sblock.fs_size = sblock.fs_ncg * sblock.fs_fpg;
+		    sblock.fs_size = ((int64_t)sblock.fs_ncg) * sblock.fs_fpg;
 	}
 
 	/*
@@ -2228,7 +2227,8 @@
 	    fragroundup(&sblock, sblock.fs_ncg * sizeof(struct csum));
 
 	if(osblock.fs_size >= sblock.fs_size) {
-		errx(1, "not enough new space");
+        errx(1, "not enough new space (II) (%jd->%jd)",
+           (intmax_t)osblock.fs_size, (intmax_t)sblock.fs_size);
 	}
 
 	DBG_PRINT0("sblock calculated\n");
