longjmp(jmpenv, SJ_SUCCEED);
}
-/* ulseek, uread, ...: Check return value for errors. */
+/* ulseek, uwrite, ...: Check return value for errors. */
static off_t
ulseek(int const fd, off_t const offset, int const whence)
return file_ptr - file_map;
}
-static size_t
-uread(int const fd, void *const buf, size_t const count)
-{
- size_t const n = read(fd, buf, count);
- if (n != count) {
- perror("read");
- fail_file();
- }
- return n;
-}
-
static size_t
uwrite(int const fd, void const *const buf, size_t const count)
{
if (file_map == MAP_FAILED) {
mmap_failed = 1;
file_map = umalloc(sb.st_size);
- uread(fd_map, file_map, sb.st_size);
+ if (read(fd_map, file_map, sb.st_size) != sb.st_size) {
+ perror(fname);
+ fail_file();
+ }
}
close(fd_map);