]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
fs: fat: fix seconds in timestamp
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 16 May 2026 18:37:00 +0000 (20:37 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 27 May 2026 23:59:12 +0000 (17:59 -0600)
The FAT time format stores seconds/2 in bits 4:0. The expression
'tm.tm_sec > 1' is a boolean comparison (yields 0 or 1) where a
right-shift 'tm.tm_sec >> 1' was intended.  As a result every
file timestamp written by U-Boot has its seconds field set to
either 0 or 1, depending on whether tm_sec is greater than 1.

Also fix the indentation of the tm_hour line.

Fixes: ba23c378c544 ("fs: fat: fill creation and change date")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
fs/fat/fat_write.c

index c98b530f7477709264084acc3453f572fb768e9b..a1d28b4e305766b8fb8ee097fafab235faf8ad52 100644 (file)
@@ -1175,9 +1175,9 @@ static void dentry_set_time(dir_entry *dentptr)
                date = (tm.tm_mday & 0x1f) |
                       ((tm.tm_mon & 0xf) << 5) |
                       ((tm.tm_year - 1980) << 9);
-               time = (tm.tm_sec > 1) |
+               time = (tm.tm_sec >> 1) |
                       ((tm.tm_min & 0x3f) << 5) |
-               (tm.tm_hour << 11);
+                      (tm.tm_hour << 11);
                dentptr->date = date;
                dentptr->time = time;
                return;