static char *sccsid
= "@(#)itime.c 1.10 (Berkeley) %G%";
struct idates
**idatev
= 0;
struct itime
*ithead
= 0;
register struct itime
*itwalk
;
if ((fd
= open(increm
, FSHLOCK
|FRDONLY
, 0600)) < 0) {
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
;
if ((fd
= open(temp
, FCREATE
|FEXLOCK
|FRDWR
, 0600)) < 0) {
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 assumes that there are no unallocated blocks; hence
* the estimate may be high
/* calc number of TP_BSIZE blocks */
s
= howmany(ip
->di_size
, TP_BSIZE
);
if (ip
->di_size
> sblock
->fs_bsize
* NDADDR
) {
/* calc number of indirect blocks on the dump tape */
s
+= howmany(s
- NDADDR
* sblock
->fs_bsize
/ TP_BSIZE
,
for (i
= 0; i
< msiz
; i
++)
esize
+= howmany(n
* sizeof map
[0], TP_BSIZE
);