summaryrefslogtreecommitdiff
path: root/util/nvmutil/lib/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/nvmutil/lib/io.c')
-rw-r--r--util/nvmutil/lib/io.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/util/nvmutil/lib/io.c b/util/nvmutil/lib/io.c
index 1a234b8f..06fd038f 100644
--- a/util/nvmutil/lib/io.c
+++ b/util/nvmutil/lib/io.c
@@ -5,21 +5,16 @@
* I/O functions specific to nvmutil.
*/
-#ifdef __OpenBSD__
-#include <sys/param.h>
-#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
-#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <time.h>
#include <unistd.h>
#include "../include/common.h"
@@ -84,7 +79,7 @@ copy_gbe(void)
if (f->gbe_file_size == SIZE_8KB)
return;
- x_v_memcpy(f->buf + (unsigned long)GBE_PART_SIZE,
+ memcpy(f->buf + (unsigned long)GBE_PART_SIZE,
f->buf + (unsigned long)(f->gbe_file_size >> 1),
(unsigned long)GBE_PART_SIZE);
}
@@ -130,7 +125,7 @@ read_file(void)
/* needs sync, for verification
*/
- if (x_i_fsync(f->tmp_fd) == -1)
+ if (fsync_on_eintr(f->tmp_fd) == -1)
err(errno, "%s: fsync (tmpfile copy)", f->tname);
_r = rw_file_exact(f->tmp_fd, f->bufcmp, f->gbe_file_size,
@@ -140,7 +135,7 @@ read_file(void)
if (_r < 0)
err(errno, "%s: read failed (cmp)", f->tname);
- if (x_i_memcmp(f->buf, f->bufcmp, f->gbe_file_size) != 0)
+ if (memcmp(f->buf, f->bufcmp, f->gbe_file_size) != 0)
err(errno, "%s: %s: read contents differ (pre-test)",
f->fname, f->tname);
}
@@ -232,7 +227,7 @@ write_to_gbe_bin(void)
* We may otherwise read from
* cache, so we must sync.
*/
- if (x_i_fsync(f->tmp_fd) == -1)
+ if (fsync_on_eintr(f->tmp_fd) == -1)
err(errno, "%s: fsync (pre-verification)",
f->tname);
@@ -251,12 +246,12 @@ write_to_gbe_bin(void)
saved_errno = errno;
- if (x_i_close(f->tmp_fd) == -1) {
+ if (close_on_eintr(f->tmp_fd) == -1) {
fprintf(stderr, "FAIL: %s: close\n", f->tname);
f->io_err_gbe_bin = 1;
}
- if (x_i_close(f->gbe_fd) == -1) {
+ if (close_on_eintr(f->gbe_fd) == -1) {
fprintf(stderr, "FAIL: %s: close\n", f->fname);
f->io_err_gbe_bin = 1;
}
@@ -336,7 +331,7 @@ check_written_part(unsigned long p)
f->rw_check_err_read[p] = f->io_err_gbe = 1;
else if ((unsigned long)rval != gbe_rw_size)
f->rw_check_partial_read[p] = f->io_err_gbe = 1;
- else if (x_i_memcmp(mem_offset, f->pad, gbe_rw_size) != 0)
+ else if (memcmp(mem_offset, f->pad, gbe_rw_size) != 0)
f->rw_check_bad_part[p] = f->io_err_gbe = 1;
if (f->rw_check_err_read[p] ||
@@ -440,7 +435,7 @@ gbe_mv(void)
saved_errno = errno;
- rval = x_i_rename(f->tname, f->fname);
+ rval = rename(f->tname, f->fname);
if (rval > -1) {
/*
@@ -489,13 +484,13 @@ gbe_mv(void)
if (rval < 0)
goto ret_gbe_mv;
- if (x_i_fsync(dest_fd) == -1)
+ if (fsync_on_eintr(dest_fd) == -1)
goto ret_gbe_mv;
- if (x_i_close(dest_fd) == -1)
+ if (close_on_eintr(dest_fd) == -1)
goto ret_gbe_mv;
- if (x_i_rename(dest_tmp, f->fname) == -1)
+ if (rename(dest_tmp, f->fname) == -1)
goto ret_gbe_mv;
if (fsync_dir(f->fname) < 0) {
@@ -509,7 +504,7 @@ gbe_mv(void)
ret_gbe_mv:
if (f->gbe_fd > -1) {
- if (x_i_close(f->gbe_fd) < 0)
+ if (close_on_eintr(f->gbe_fd) < 0)
rval = -1;
if (fsync_dir(f->fname) < 0) {
f->io_err_gbe_bin = 1;
@@ -519,7 +514,7 @@ ret_gbe_mv:
}
if (f->tmp_fd > -1) {
- if (x_i_close(f->tmp_fd) < 0)
+ if (close_on_eintr(f->tmp_fd) < 0)
rval = -1;
f->tmp_fd = -1;