From 781d5135a61025caea65ef66b5c6bde2ef950e40 Mon Sep 17 00:00:00 2001 From: batt Date: Mon, 17 Dec 2007 15:49:43 +0000 Subject: [PATCH] Handle seqnum wraparound. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1039 38d2e660-2303-0410-9eaa-f027e97ec537 --- fs/battfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/battfs.c b/fs/battfs.c index 752ec3c6..1b8bf923 100644 --- a/fs/battfs.c +++ b/fs/battfs.c @@ -339,8 +339,9 @@ bool battfs_init(struct BattFsSuper *disk) pgcnt_t new_page, old_page; fill_t old_fill; - #warning fix seq wraparound! - if (hdr.seq > hdr_old.seq) + /* Fancy check to handle seq wraparound */ + #define HALF_SEQ ((1 << (sizeof(seq_t) * CPU_BITS_PER_CHAR)) / 2) + if ((hdr.seq - hdr_old.seq) < HALF_SEQ) { /* Actual header is newer than the previuos one */ old_page = disk->page_array[array_pos]; -- 2.25.1