diff options
author | phk <phk@FreeBSD.org> | 2009-02-02 14:29:15 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2009-02-02 14:29:15 +0000 |
commit | 8b7a45678f332252b0242b72c0807e764a690680 (patch) | |
tree | b2a1129c762f4efa2f09be587e42f394995b19c1 /usr.sbin/fifolog | |
parent | 0239a09bb66985e26ab825606c869e7d98a4857b (diff) | |
download | FreeBSD-src-8b7a45678f332252b0242b72c0807e764a690680.zip FreeBSD-src-8b7a45678f332252b0242b72c0807e764a690680.tar.gz |
Don't overwrite it, if only one sector is written yet.
Discovered by: "Dewayne Geraghty" <dewayne.geraghty@heuristicsystems.com.au>
Diffstat (limited to 'usr.sbin/fifolog')
-rw-r--r-- | usr.sbin/fifolog/lib/fifolog_write_poll.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.sbin/fifolog/lib/fifolog_write_poll.c b/usr.sbin/fifolog/lib/fifolog_write_poll.c index afff022..4fc5204 100644 --- a/usr.sbin/fifolog/lib/fifolog_write_poll.c +++ b/usr.sbin/fifolog/lib/fifolog_write_poll.c @@ -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; |