* Copyright (c) 1980 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)itime.c 5.10 (Berkeley) %G%";
#include <ufs/ufs/dinode.h>
#include <protocols/dumprestore.h>
struct dumpdates
**ddatev
= 0;
struct dumptime
*dthead
= 0;
static void dumprecout();
if ((df
= fopen(dumpdates
, "r")) == NULL
) {
quit("cannot read %s: %s\n", dumpdates
,
* Dumpdates does not exist, make an empty one.
msg("WARNING: no file `%s', making an empty one\n", dumpdates
);
if ((df
= fopen(dumpdates
, "w")) == NULL
) {
quit("cannot create %s: %s\n", dumpdates
,
if ((df
= fopen(dumpdates
, "r")) == NULL
) {
quit("cannot read %s even after creating it: %s\n",
dumpdates
, strerror(errno
));
(void) flock(fileno(df
), LOCK_SH
);
register struct dumptime
*dtwalk
;
dtwalk
= (struct dumptime
*)calloc(1, sizeof (struct dumptime
));
if (getrecord(df
, &(dtwalk
->dt_value
)) < 0)
dtwalk
->dt_next
= dthead
;
* arrayify the list, leaving enough room for the additional
* record that we may have to add to the ddate structure
ddatev
= (struct dumpdates
**)
calloc(nddates
+ 1, sizeof (struct dumpdates
*));
for (i
= nddates
- 1; i
>= 0; i
--, dtwalk
= dtwalk
->dt_next
)
ddatev
[i
] = &dtwalk
->dt_value
;
register struct dumpdates
*ddp
;
msg("Looking for name %s in dumpdates = %s for level = %c\n",
fname
, dumpdates
, level
);
* Go find the entry with the same name for a lower increment
if (strncmp(fname
, ddp
->dd_name
, sizeof (ddp
->dd_name
)) != 0)
if (ddp
->dd_level
>= level
)
if (ddp
->dd_ddate
<= spcl
.c_ddate
)
spcl
.c_ddate
= ddp
->dd_ddate
;
lastlevel
= ddp
->dd_level
;
register struct dumpdates
*dtwalk
;
if ((df
= fopen(dumpdates
, "r+")) == NULL
)
quit("cannot rewrite %s: %s\n", dumpdates
, strerror(errno
));
(void) flock(fd
, LOCK_EX
);
if (fseek(df
, 0L, 0) < 0)
quit("fseek: %s\n", strerror(errno
));
if (strncmp(fname
, dtwalk
->dd_name
,
sizeof (dtwalk
->dd_name
)) != 0)
if (dtwalk
->dd_level
!= level
)
* construct the new upper bound;
* Enough room has been allocated.
dtwalk
= ddatev
[nddates
] =
(struct dumpdates
*)calloc(1, sizeof(struct dumpdates
));
(void) strncpy(dtwalk
->dd_name
, fname
, sizeof (dtwalk
->dd_name
));
dtwalk
->dd_level
= level
;
dtwalk
->dd_ddate
= spcl
.c_date
;
quit("%s: %s\n", dumpdates
, strerror(errno
));
if (ftruncate(fd
, ftell(df
)))
quit("ftruncate (%s): %s\n", dumpdates
, strerror(errno
));
msg("level %c dump on %s", level
,
spcl
.c_date
== 0 ? "the epoch\n" : ctime(&spcl
.c_date
));
if (fprintf(file
, DUMPOUTFMT
,
ctime(&what
->dd_ddate
)) < 0)
quit("%s: %s\n", dumpdates
, strerror(errno
));
struct dumpdates
*ddatep
;
if ( (fgets(buf
, BUFSIZ
, df
)) != buf
)
if (makedumpdate(ddatep
, buf
) < 0)
msg("Unknown intermediate format in %s, line %d\n",
msg("getrecord: %s %c %s", ddatep
->dd_name
, ddatep
->dd_level
,
ddatep
->dd_ddate
== 0 ? "the epoch\n" : ctime(&ddatep
->dd_ddate
));
sscanf(buf
, DUMPINFMT
, ddp
->dd_name
, &ddp
->dd_level
, un_buf
);
ddp
->dd_ddate
= unctime(un_buf
);