• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // lseek should work with >2G offset
2 #include <stdio.h>
3 #include <sys/types.h>
4 #include <unistd.h>
5 #include <string.h>
6 #include <errno.h>
7 #include "test.h"
8 
9 #define A(c) ((c) || (t_error(#c " failed: %s\n", strerror(errno)), 0))
10 
main(void)11 int main(void)
12 {
13 	off_t a[] = {0x7fffffff, 0x80000000, 0x80000001, 0xffffffff, 0x100000001, 0x1ffffffff, 0 };
14 	off_t r;
15 	FILE *f;
16 	int fd;
17 	int i;
18 
19 	A((f = tmpfile()) != 0);
20 	A((fd = fileno(f)) != -1);
21 	for (i = 0; a[i]; i++) {
22 		r = lseek(fd, a[i], SEEK_SET);
23 		if (r != a[i])
24 			t_error("lseek(fd, 0x%llx, SEEK_SET) got 0x%llx\n", (long long)a[i], (long long)r);
25 	}
26 	return t_status;
27 }
28