/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*/
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <stdio.h>
#include <string.h>
#include <unistd.h>
long len;
off64_t seek;
struct stat64 st;
+ char pad = 0xba;
int action;
int rc;
if (argc < 5 || argc > 6) {
- printf("Usage: %s <read/write/rdwr> file seek nr_blocks [blocksize]\n", argv[0]);
+ printf("Usage: %s <read/write/rdwr/readhole> file seek nr_blocks [blocksize]\n", argv[0]);
return 1;
}
action = O_WRONLY;
else if (!strcmp(argv[1], "rdwr"))
action = O_RDWR;
- else {
+ else if (!strcmp(argv[1], "readhole")) {
+ action = O_RDONLY;
+ pad = 0;
+ } else {
printf("Usage: %s <read/write/rdwr> file seek nr_blocks [blocksize]\n", argv[0]);
return 1;
}
printf("No memory %s\n", strerror(errno));
return 1;
}
- memset(wbuf, 0xba, len);
+ memset(wbuf, pad, len);
if (action == O_WRONLY || action == O_RDWR) {
if (lseek64(fd, seek, SEEK_SET) < 0) {
rc = read(fd, rbuf, len);
if (rc != len) {
- printf("Read error: %s (rc = %d)\n",strerror(errno),rc);
+ printf("Read error: %s rc = %d\n",strerror(errno),rc);
return 1;
}