--- cci/usr/src/etc/dump/dumpitime.c 2019/07/28 12:24:19 1.1 +++ cci/usr/src/etc/dump/dumpitime.c 2019/07/28 12:24:33 1.1.1.2 @@ -1,4 +1,12 @@ -static char *sccsid = "@(#)dumpitime.c 1.12 (Berkeley) 9/13/83"; +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)dumpitime.c 5.1 (Berkeley) 6/5/85"; +#endif not lint #include "dump.h" #include @@ -204,23 +212,36 @@ int makeidate(ip, buf) /* * This is an estimation of the number of TP_BSIZE blocks in the file. + * It estimates the number of blocks in files with holes by assuming + * that all of the blocks accounted for by di_blocks are data blocks + * (when some of the blocks are usually used for indirect pointers); + * hence the estimate may be high. */ est(ip) struct dinode *ip; { long s, t; + /* + * ip->di_size is the size of the file in bytes. + * ip->di_blocks stores the number of sectors actually in the file. + * If there are more sectors than the size would indicate, this just + * means that there are indirect blocks in the file or unused + * sectors in the last file block; we can safely ignore these + * (s = t below). + * If the file is bigger than the number of sectors would indicate, + * then the file has holes in it. In this case we must use the + * block count to estimate the number of data blocks used, but + * we use the actual size for estimating the number of indirect + * dump blocks (t vs. s in the indirect block calculation). + */ esize++; - /* - * ip->di_size is the size of the file in bytes. - * ip->di_blocks stores the number of sectors actually in the file. - */ - s = howmany(dbtob(ip->di_blocks), TP_BSIZE); - t = howmany(ip->di_size, TP_BSIZE); - if (s > t) - s = t; + s = howmany(dbtob(ip->di_blocks), TP_BSIZE); + t = howmany(ip->di_size, TP_BSIZE); + if ( s > t ) + s = t; if (ip->di_size > sblock->fs_bsize * NDADDR) { - /* calc number of indirect blocks on the dump tape */ + /* calculate the number of indirect blocks on the dump tape */ s += howmany(t - NDADDR * sblock->fs_bsize / TP_BSIZE, TP_NINDIR); }