Merging in 2.0.2.

This commit is contained in:
Geoffrey Challen
2017-01-09 22:37:50 -05:00
parent a0406ec181
commit 50cf3276e7
118 changed files with 1350 additions and 3158 deletions

View File

@@ -41,8 +41,6 @@
#include <unistd.h>
#include <fcntl.h>
#include <err.h>
#include <string.h>
#include <test161/test161.h>
int
main(int argc, char *argv[])
@@ -59,16 +57,15 @@ main(int argc, char *argv[])
filename = argv[1];
size = atoi(argv[2]);
byte = '@';
byte = '\n';
if (size == 0) {
err(1, "Sparse files of length zero are not meaningful");
}
tprintf("Creating a sparse file of size %d\n", size);
nprintf(".");
printf("Creating a sparse file of size %d\n", size);
fd = open(filename, O_RDWR|O_CREAT|O_TRUNC);
fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC);
if (fd < 0) {
err(1, "%s: create", filename);
}
@@ -76,7 +73,6 @@ 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);
@@ -84,30 +80,8 @@ 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;
}