Commit 6d0202c1 authored by Konstantin Khlebnikov's avatar Konstantin Khlebnikov

ioping: fix support of character devices

now it works for /dev/zero and /dev/null
Signed-off-by: default avatarKonstantin Khlebnikov <koct9i@gmail.com>
parent 705cd38c
...@@ -586,7 +586,7 @@ void parse_device(dev_t dev) ...@@ -586,7 +586,7 @@ void parse_device(dev_t dev)
#endif #endif
off_t get_device_size(int fd, struct stat *st) int get_device_size(int fd, struct stat *st)
{ {
unsigned long long blksize = 0; unsigned long long blksize = 0;
int ret = 0; int ret = 0;
...@@ -630,12 +630,9 @@ off_t get_device_size(int fd, struct stat *st) ...@@ -630,12 +630,9 @@ off_t get_device_size(int fd, struct stat *st)
blksize = 0; blksize = 0;
#endif #endif
(void)fd; (void)fd;
(void)st;
if (ret) st->st_size = blksize;
err(2, "block get size ioctl failed"); return ret;
return blksize;
} }
ssize_t do_pwrite(int fd, void *buf, size_t nbytes, off_t offset) ssize_t do_pwrite(int fd, void *buf, size_t nbytes, off_t offset)
...@@ -955,9 +952,23 @@ int main (int argc, char **argv) ...@@ -955,9 +952,23 @@ int main (int argc, char **argv)
if (fd < 0) if (fd < 0)
err(2, "failed to open \"%s\"", path); err(2, "failed to open \"%s\"", path);
device_size = get_device_size(fd, &st); if (get_device_size(fd, &st)) {
st.st_size = device_size; if (!S_ISCHR(st.st_mode))
fstype = "device"; err(2, "block get size ioctl failed");
st.st_size = offset + temp_wsize;
fstype = "character";
device = "device";
} else {
device_size = st.st_size;
fstype = "block";
device = "device ";
}
if (!cached && write_test && fdatasync(fd)) {
warnx("fdatasync not supported by \"%s\", "
"enable cached requests", path);
cached = 1;
}
} else { } else {
errx(2, "unsupported destination: \"%s\"", path); errx(2, "unsupported destination: \"%s\"", path);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment