- seek = (off64_t)seek_blocks * (off64_t)st.st_blksize;
- len = blocks * st.st_blksize;
-
- buf = mmap(0, len, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, 0, 0);
- if (buf == MAP_FAILED) {
- printf("No memory %s\n", strerror(errno));
- return 1;
- }
- memset(buf, pad, len);
-
- if (action == O_WRONLY || action == O_RDWR) {
- if (lseek64(fd, seek, SEEK_SET) < 0) {
- printf("lseek64 failed: %s\n", strerror(errno));
- return 1;
- }
-
- rc = write(fd, buf, len);
- if (rc != len) {
- printf("Write error %s (rc = %d, len = %ld)\n",
- strerror(errno), rc, len);
- return 1;
- }
- }
-
- if (action == O_RDONLY || action == O_RDWR) {
- if (lseek64(fd, seek, SEEK_SET) < 0) {
- printf("Cannot seek %s\n", strerror(errno));
- return 1;
- }
- /* reset all bytes to something nor 0x0 neither 0xab */
- memset(buf, 0x5e, len);
- rc = read(fd, buf, len);
- if (rc != len) {
- printf("Read error: %s rc = %d\n",strerror(errno),rc);
- return 1;
- }
-
- if (check_bytes(buf, pad, len) != len) {
- printf("Data mismatch\n");
- return 1;
- }
- }
-
- printf("PASS\n");
- return 0;
+ seek = (off64_t)seek_blocks * (off64_t)st.st_blksize;
+ len = blocks * st.st_blksize;
+
+ buf = mmap(0, len,
+ PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, 0, 0);
+ if (buf == MAP_FAILED) {
+ printf("No memory %s\n", strerror(errno));
+ return 1;
+ }
+ memset(buf, pad, len);
+
+ if (action == O_WRONLY || action == O_RDWR) {
+ if (lseek64(fd, seek, SEEK_SET) < 0) {
+ printf("lseek64 failed: %s\n", strerror(errno));
+ return 1;
+ }
+
+ rc = write(fd, buf, len);
+ if (rc != len) {
+ printf("Write error %s (rc = %d, len = %ld)\n",
+ strerror(errno), rc, len);
+ return 1;
+ }
+ }
+
+ if (action == O_RDONLY || action == O_RDWR) {
+ if (lseek64(fd, seek, SEEK_SET) < 0) {
+ printf("Cannot seek %s\n", strerror(errno));
+ return 1;
+ }
+ /* reset all bytes to something nor 0x0 neither 0xab */
+ memset(buf, 0x5e, len);
+ rc = read(fd, buf, len);
+ if (rc != len) {
+ printf("Read error: %s rc = %d\n", strerror(errno), rc);
+ return 1;
+ }
+
+ if (check_bytes(buf, pad, len) != len) {
+ printf("Data mismatch\n");
+ return 1;
+ }
+ }
+
+ printf("PASS\n");
+ return 0;