aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_msdosfs/dir.c
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2019-03-28 18:20:47 +0000
committerXin LI <delphij@FreeBSD.org>2019-03-28 18:20:47 +0000
commit9ace37176e21f3371de7945b81380d9f1f7cd776 (patch)
tree6953a6fac2f9bb02fe8abaa34ea2b0f7563e07a9 /sbin/fsck_msdosfs/dir.c
parent77f552e221f3cb1e85afb4c7a6d3f2fb95063217 (diff)
Distinguish between lseek errors and read errores.
MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=345647
Diffstat (limited to 'sbin/fsck_msdosfs/dir.c')
-rw-r--r--sbin/fsck_msdosfs/dir.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sbin/fsck_msdosfs/dir.c b/sbin/fsck_msdosfs/dir.c
index 38c70144d679..00bd33fc1860 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 <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -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;
}