Revert "Merging in 1.0.2."

This reverts commit 50cf3276e7.
This commit is contained in:
Geoffrey Challen
2017-01-09 22:52:13 -05:00
parent 50cf3276e7
commit e318e3171e
118 changed files with 3158 additions and 1350 deletions

View File

@@ -41,6 +41,8 @@
#include <unistd.h>
#include <fcntl.h>
#include <err.h>
#include <string.h>
#include <test161/test161.h>
int
main(int argc, char *argv[])
@@ -57,15 +59,16 @@ main(int argc, char *argv[])
filename = argv[1];
size = atoi(argv[2]);
byte = '\n';
byte = '@';
if (size == 0) {
err(1, "Sparse files of length zero are not meaningful");
}
printf("Creating a sparse file of size %d\n", size);
tprintf("Creating a sparse file of size %d\n", size);
nprintf(".");
fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC);
fd = open(filename, O_RDWR|O_CREAT|O_TRUNC);
if (fd < 0) {
err(1, "%s: create", filename);
}
@@ -73,6 +76,7 @@ main(int argc, char *argv[])
if (lseek(fd, size-1, SEEK_SET) == -1) {
err(1, "%s: lseek", filename);
}
nprintf(".");
r = write(fd, &byte, 1);
if (r < 0) {
err(1, "%s: write", filename);
@@ -80,8 +84,30 @@ main(int argc, char *argv[])
else if (r != 1) {
errx(1, "%s: write: Unexpected result count %d", filename, r);
}
nprintf(".");
// Now check this byte.
// First seek to the beginning and then seek back to where the byte
// should be.
if(lseek(fd, 0, SEEK_SET) == -1) {
err(1, "lseek failed to seek to beginning of file\n");
}
nprintf(".");
// Now seek back to where the byte should be
// While at it, also test SEEK_CUR
if(lseek(fd, size-1, SEEK_CUR) == -1) {
err(1, "lseek failed to seek to %d of file\n", size-1);
}
nprintf(".");
char test;
r = read(fd, &test, 1);
if(test != byte) {
err(1, "Byte test failed. Expected (%c) != Observed (%c)\n", byte, test);
}
nprintf(".");
close(fd);
nprintf("\n");
success(TEST161_SUCCESS, SECRET, "/testbin/sparsefile");
return 0;
}