From 7787d904cc8fe54e48eac696ff8b72fba75a28f1 Mon Sep 17 00:00:00 2001 From: delphij Date: Fri, 12 Apr 2019 02:27:03 +0000 Subject: [PATCH] MFC r345647: Distinguish between lseek errors and read errores. --- sbin/fsck_msdosfs/dir.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sbin/fsck_msdosfs/dir.c b/sbin/fsck_msdosfs/dir.c index 38c70144d67..00bd33fc186 100644 --- a/sbin/fsck_msdosfs/dir.c +++ b/sbin/fsck_msdosfs/dir.c @@ -35,6 +35,7 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#include #include #include #include @@ -329,8 +330,11 @@ delete(int f, struct bootblock *boot, struct fatEntry *fat, cl_t startcl, } off = startcl * boot->bpbSecPerClust + boot->ClusterOffset; off *= boot->bpbBytesPerSec; - if (lseek(f, off, SEEK_SET) != off - || read(f, delbuf, clsz) != clsz) { + if (lseek(f, off, SEEK_SET) != off) { + perr("Unable to lseek to %" PRId64, off); + return FSFATAL; + } + if (read(f, delbuf, clsz) != clsz) { perr("Unable to read directory"); return FSFATAL; } @@ -338,8 +342,11 @@ delete(int f, struct bootblock *boot, struct fatEntry *fat, cl_t startcl, *s = SLOT_DELETED; s += 32; } - if (lseek(f, off, SEEK_SET) != off - || write(f, delbuf, clsz) != clsz) { + if (lseek(f, off, SEEK_SET) != off) { + perr("Unable to lseek to %" PRId64, off); + return FSFATAL; + } + if (write(f, delbuf, clsz) != clsz) { perr("Unable to write directory"); return FSFATAL; } -- 2.45.0