1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-02 08:42:48 +00:00

Don't overwrite it, if only one sector is written yet.

Discovered by:	"Dewayne Geraghty" <dewayne.geraghty@heuristicsystems.com.au>
This commit is contained in:
Poul-Henning Kamp 2009-02-02 14:29:15 +00:00
parent 75d7ed1ed6
commit b183b801b5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=188007

View File

@ -152,15 +152,16 @@ fifolog_write_open(struct fifolog_writer *f, const char *fn, unsigned writerate,
es = fifolog_int_findend(f->ff, &o);
if (es != NULL)
return (es);
if (o == 0) {
f->seq = 0;
f->recno = 0;
i = fifolog_int_read(f->ff, o);
if (i)
return ("Read error, looking for seq");
f->seq = be32dec(f->ff->recbuf);
if (f->seq == 0) {
/* Empty fifolog */
f->seq = random();
} else {
i = fifolog_int_read(f->ff, o);
if (i)
return ("Read error, looking for seq");
f->seq = be32dec(f->ff->recbuf) + 1;
f->recno = o + 1;
f->seq++;
}
f->ibufsize = 32768;