static char *sccsid
= "@(#)itime.c 1.5 (Berkeley) %G%";
struct idates
**idatev
= 0;
struct itime
*ithead
= 0;
register struct itime
*itwalk
;
if ( (df
= fopen(increm
, "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
;
register struct idates
*itwalk
;
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 ( (df
= fopen(increm
, "w")) == NULL
){
msg("Cannot open %s\n", increm
);
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
));
* Convert from old format to new format
* Convert from /etc/ddate to /etc/dumpdates format
if( (newfile
= fopen(NINCREM
, "w")) == NULL
){
msg("%s: Can not open %s to update.\n", processname
, NINCREM
);
if ( (oldfile
= fopen(OINCREM
, "r")) != NULL
){
if (fread(&idate
, sizeof(idate
), 1, oldfile
) != 1)
* The old format ddate did not have
* the full special path name on it;
* we add the prefix /dev/ to the
* special name, although this may not be
* always the right thing to do.
strcpy(idatecopy
.id_name
, "/dev/");
strncat(idatecopy
.id_name
, idate
.id_name
,
sizeof(idate
.id_name
) - sizeof ("/dev/"));
recout(newfile
, &idatecopy
);
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
= fragroundup(sblock
, 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
* BLKING(sblock
) * sblock
->fs_frag
,
for (i
= 0; i
< msiz
; i
++)
esize
+= howmany(n
* sizeof map
[0], TP_BSIZE
);