Blame src/regression/lseek-large.c

Szabolcs Nagy feee04
// lseek should work with >2G offset
Szabolcs Nagy feee04
#include <stdio.h>
Szabolcs Nagy feee04
#include <sys/types.h>
Szabolcs Nagy feee04
#include <unistd.h>
Szabolcs Nagy feee04
#include <string.h>
Szabolcs Nagy feee04
#include <errno.h>
Szabolcs Nagy feee04
#include "test.h"
Szabolcs Nagy feee04
Szabolcs Nagy feee04
#define A(c) ((c) || (t_error(#c " failed: %s\n", strerror(errno)), 0))
Szabolcs Nagy feee04
Szabolcs Nagy feee04
int main(void)
Szabolcs Nagy feee04
{
Szabolcs Nagy feee04
	off_t a[] = {0x7fffffff, 0x80000000, 0x80000001, 0xffffffff, 0x100000001, 0x1ffffffff, 0 };
Szabolcs Nagy feee04
	off_t r;
Szabolcs Nagy feee04
	FILE *f;
Szabolcs Nagy feee04
	int fd;
Szabolcs Nagy feee04
	int i;
Szabolcs Nagy feee04
Szabolcs Nagy feee04
	A((f = tmpfile()) != 0);
Szabolcs Nagy feee04
	A((fd = fileno(f)) != -1);
Szabolcs Nagy feee04
	for (i = 0; a[i]; i++) {
Szabolcs Nagy feee04
		r = lseek(fd, a[i], SEEK_SET);
Szabolcs Nagy feee04
		if (r != a[i])
Szabolcs Nagy feee04
			t_error("lseek(fd, 0x%llx, SEEK_SET) got 0x%llx\n", (long long)a[i], (long long)r);
Szabolcs Nagy feee04
	}
Szabolcs Nagy feee04
	return t_status;
Szabolcs Nagy feee04
}