static char *sccsid
= "@(#)itime.c 1.13 (Berkeley) %G%";
struct idates
**idatev
= 0;
struct itime
*ithead
= 0;
register struct itime
*itwalk
;
fd
= open(increm
, O_RDONLY
);
(void) flock(fd
, LOCK_SH
);
if ((df
= fdopen(fd
, "r")) == NULL
) {
itwalk
=(struct itime
*)calloc(1,sizeof (struct itime
));
if (getrecord(df
, &(itwalk
->it_value
)) < 0)
itwalk
->it_next
= ithead
;
* arrayify the list, leaving enough room for the additional
* record that we may have to add to the idate structure
idatev
= (struct idates
**)calloc(nidates
+ 1,sizeof (struct idates
*));
for (i
= nidates
-1, itwalk
= ithead
; i
>= 0; i
--, itwalk
= itwalk
->it_next
)
idatev
[i
] = &itwalk
->it_value
;
register struct idates
*ip
;
msg("Looking for name %s in increm = %s for delta = %c\n",
* Go find the entry with the same name for a lower increment
if(strncmp(fname
, ip
->id_name
,
sizeof (ip
->id_name
)) != 0)
if (ip
->id_incno
>= incno
)
if (ip
->id_ddate
<= spcl
.c_ddate
)
spcl
.c_ddate
= ip
->id_ddate
;
lastincno
= ip
->id_incno
;
register struct idates
*itwalk
;
fd
= open(temp
, O_RDWR
|O_CREAT
, 0600);
(void) flock(fd
, LOCK_EX
);
if ((df
= fdopen(fd
, "w")) == NULL
) {
if (strncmp(fname
, itwalk
->id_name
,
sizeof (itwalk
->id_name
)) != 0)
if (itwalk
->id_incno
!= incno
)
* construct the new upper bound;
* Enough room has been allocated.
itwalk
= idatev
[nidates
] =
(struct idates
*)calloc(1, sizeof(struct idates
));
strncpy(itwalk
->id_name
, fname
, sizeof (itwalk
->id_name
));
itwalk
->id_incno
= incno
;
itwalk
->id_ddate
= spcl
.c_date
;
if (rename(temp
, increm
) < 0) {
(void) chmod(increm
, 0644);
msg("level %c dump on %s\n", incno
, prdate(spcl
.c_date
));
fprintf(file
, DUMPOUTFMT
,
int getrecord(df
, idatep
)
if ( (fgets(buf
, BUFSIZ
, df
)) != buf
)
if (makeidate(idatep
, buf
) < 0)
msg("Unknown intermediate format in %s, line %d\n",
msg("getrecord: %s %c %s\n",
idatep
->id_name
, idatep
->id_incno
, prdate(idatep
->id_ddate
));
sscanf(buf
, DUMPINFMT
, ip
->id_name
, &ip
->id_incno
, un_buf
);
ip
->id_ddate
= unctime(un_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.
* 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
* 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).
s
= howmany(dbtob(ip
->di_blocks
), TP_BSIZE
);
t
= howmany(ip
->di_size
, TP_BSIZE
);
if (ip
->di_size
> sblock
->fs_bsize
* NDADDR
) {
/* calculate the number of indirect blocks on the dump tape */
s
+= howmany(t
- NDADDR
* sblock
->fs_bsize
/ TP_BSIZE
,
for (i
= 0; i
< msiz
; i
++)
esize
+= howmany(n
* sizeof map
[0], TP_BSIZE
);