Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1 | From 3cca69b85c88c6eb4f02313b3c6a9e0f6cc0b5d7 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 14 Dec 2022 18:14:22 -0800 |
| 4 | Subject: [PATCH] testcases: Fix largefile support |
| 5 | |
| 6 | Use standard functions ( not 64-bit equivalents ) which operate on off_t |
| 7 | and pass -D_FILE_OFFSET_BITS=64 to enable LFS always so off_t is 64bit |
| 8 | for these tests. |
| 9 | |
| 10 | This helps making it portable across musl which has removed the 64bit |
| 11 | transition functions from _GNU_SOURCE namespace. |
| 12 | |
| 13 | Upstream-Status: Submitted [https://lists.linux.it/pipermail/ltp/2022-December/032310.html] |
| 14 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 15 | --- |
| 16 | testcases/kernel/io/direct_io/Makefile | 2 +- |
| 17 | testcases/kernel/io/direct_io/diotest2.c | 4 ++-- |
| 18 | testcases/kernel/io/direct_io/diotest5.c | 10 +++++----- |
| 19 | testcases/kernel/io/direct_io/diotest6.c | 4 ++-- |
| 20 | testcases/kernel/syscalls/fcntl/fcntl18.c | 6 +++--- |
| 21 | testcases/kernel/syscalls/fcntl/fcntl34.c | 2 +- |
| 22 | testcases/kernel/syscalls/fcntl/fcntl36.c | 4 ++-- |
| 23 | testcases/kernel/syscalls/llseek/Makefile | 2 ++ |
| 24 | testcases/kernel/syscalls/llseek/llseek01.c | 14 +++++++------- |
| 25 | testcases/kernel/syscalls/llseek/llseek02.c | 12 ++++++------ |
| 26 | testcases/kernel/syscalls/llseek/llseek03.c | 6 +++--- |
| 27 | testcases/kernel/syscalls/open/Makefile | 2 ++ |
| 28 | testcases/kernel/syscalls/open/open12.c | 6 +++--- |
| 29 | testcases/kernel/syscalls/openat/Makefile | 2 ++ |
| 30 | testcases/kernel/syscalls/openat/openat02.c | 6 +++--- |
| 31 | testcases/kernel/syscalls/sync_file_range/Makefile | 2 ++ |
| 32 | .../syscalls/sync_file_range/sync_file_range01.c | 4 ++-- |
| 33 | .../syscalls/sync_file_range/sync_file_range02.c | 6 +++--- |
| 34 | 18 files changed, 51 insertions(+), 43 deletions(-) |
| 35 | |
| 36 | diff --git a/testcases/kernel/io/direct_io/Makefile b/testcases/kernel/io/direct_io/Makefile |
| 37 | index 777f7b166..7480d7b0d 100644 |
| 38 | --- a/testcases/kernel/io/direct_io/Makefile |
| 39 | +++ b/testcases/kernel/io/direct_io/Makefile |
| 40 | @@ -5,7 +5,7 @@ top_srcdir ?= ../../../.. |
| 41 | |
| 42 | include $(top_srcdir)/include/mk/testcases.mk |
| 43 | |
| 44 | -CFLAGS += -DSHARED_OFILE -D_GNU_SOURCE |
| 45 | +CFLAGS += -DSHARED_OFILE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE |
| 46 | |
| 47 | LDLIBS += -lpthread |
| 48 | |
| 49 | diff --git a/testcases/kernel/io/direct_io/diotest2.c b/testcases/kernel/io/direct_io/diotest2.c |
| 50 | index c407c46ae..db47ee8ef 100644 |
| 51 | --- a/testcases/kernel/io/direct_io/diotest2.c |
| 52 | +++ b/testcases/kernel/io/direct_io/diotest2.c |
| 53 | @@ -78,7 +78,7 @@ int bufsize = BUFSIZE; |
| 54 | * For each iteration, write data starting at offse+iter*bufsize |
| 55 | * location in the file and read from there. |
| 56 | */ |
| 57 | -int runtest(int fd_r, int fd_w, int iter, off64_t offset, int action) |
| 58 | +int runtest(int fd_r, int fd_w, int iter, off_t offset, int action) |
| 59 | { |
| 60 | char *buf1; |
| 61 | char *buf2; |
| 62 | @@ -136,7 +136,7 @@ static void cleanup(void); |
| 63 | int main(int argc, char *argv[]) |
| 64 | { |
| 65 | int iter = 100; /* Iterations. Default 100 */ |
| 66 | - off64_t offset = 0; /* Offset. Default 0 */ |
| 67 | + off_t offset = 0; /* Offset. Default 0 */ |
| 68 | int i, action, fd_r, fd_w; |
| 69 | int fail_count = 0, total = 0, failed = 0; |
| 70 | |
| 71 | diff --git a/testcases/kernel/io/direct_io/diotest5.c b/testcases/kernel/io/direct_io/diotest5.c |
| 72 | index 9bf917c64..ac66f2a04 100644 |
| 73 | --- a/testcases/kernel/io/direct_io/diotest5.c |
| 74 | +++ b/testcases/kernel/io/direct_io/diotest5.c |
| 75 | @@ -75,14 +75,14 @@ int TST_TOTAL = 3; /* Total number of test conditions */ |
| 76 | static int bufsize = BUFSIZE; /* Buffer size. Default 4k */ |
| 77 | static int iter = 20; /* Iterations. Default 20 */ |
| 78 | static int nvector = 20; /* Vector array. Default 20 */ |
| 79 | -static off64_t offset = 0; /* Start offset. Default 0 */ |
| 80 | +static off_t offset = 0; /* Start offset. Default 0 */ |
| 81 | static char filename[LEN]; /* Test data file */ |
| 82 | static int fd1 = -1; |
| 83 | /* |
| 84 | * runtest: Write the data in vector array to the file. Read the data |
| 85 | * from the file into another vectory array and verify. Repeat the test. |
| 86 | */ |
| 87 | -int runtest(int fd_r, int fd_w, int iter, off64_t offset, int action) |
| 88 | +int runtest(int fd_r, int fd_w, int iter, off_t offset, int action) |
| 89 | { |
| 90 | int i; |
| 91 | struct iovec *iov1, *iov2, *iovp; |
| 92 | @@ -218,7 +218,7 @@ int main(int argc, char *argv[]) |
| 93 | tst_brkm(TBROK, cleanup, "fd_w open failed for %s: %s", |
| 94 | filename, strerror(errno)); |
| 95 | } |
| 96 | - if ((fd_r = open64(filename, O_DIRECT | O_RDONLY | O_CREAT, 0666)) < 0) { |
| 97 | + if ((fd_r = open(filename, O_DIRECT | O_RDONLY | O_CREAT, 0666)) < 0) { |
| 98 | tst_brkm(TBROK, cleanup, "fd_r open failed for %s: %s", |
| 99 | filename, strerror(errno)); |
| 100 | } |
| 101 | @@ -240,7 +240,7 @@ int main(int argc, char *argv[]) |
| 102 | tst_brkm(TBROK, cleanup, "fd_w open failed for %s: %s", |
| 103 | filename, strerror(errno)); |
| 104 | } |
| 105 | - if ((fd_r = open64(filename, O_RDONLY | O_CREAT, 0666)) < 0) { |
| 106 | + if ((fd_r = open(filename, O_RDONLY | O_CREAT, 0666)) < 0) { |
| 107 | tst_brkm(TBROK, cleanup, "fd_r open failed for %s: %s", |
| 108 | filename, strerror(errno)); |
| 109 | } |
| 110 | @@ -261,7 +261,7 @@ int main(int argc, char *argv[]) |
| 111 | tst_brkm(TBROK, cleanup, "fd_w open failed for %s: %s", |
| 112 | filename, strerror(errno)); |
| 113 | } |
| 114 | - if ((fd_r = open64(filename, O_DIRECT | O_RDONLY | O_CREAT, 0666)) < 0) { |
| 115 | + if ((fd_r = open(filename, O_DIRECT | O_RDONLY | O_CREAT, 0666)) < 0) { |
| 116 | tst_brkm(TBROK, cleanup, "fd_r open failed for %s: %s", |
| 117 | filename, strerror(errno)); |
| 118 | } |
| 119 | diff --git a/testcases/kernel/io/direct_io/diotest6.c b/testcases/kernel/io/direct_io/diotest6.c |
| 120 | index a06e6b82b..1905380f0 100644 |
| 121 | --- a/testcases/kernel/io/direct_io/diotest6.c |
| 122 | +++ b/testcases/kernel/io/direct_io/diotest6.c |
| 123 | @@ -62,7 +62,7 @@ int TST_TOTAL = 3; |
| 124 | |
| 125 | static int iter = 100; |
| 126 | static int bufsize = BUFSIZE; |
| 127 | -static off64_t offset = 0; |
| 128 | +static off_t offset = 0; |
| 129 | static int nvector = 20; |
| 130 | static char filename[LEN]; |
| 131 | static int fd1 = -1; |
| 132 | @@ -84,7 +84,7 @@ static void prg_usage(void) |
| 133 | */ |
| 134 | int runtest(int fd_r, int fd_w, int childnum, int action) |
| 135 | { |
| 136 | - off64_t seekoff; |
| 137 | + off_t seekoff; |
| 138 | int i, ret = -1; |
| 139 | ssize_t n = 0; |
| 140 | struct iovec *iov_r, *iov_w; |
| 141 | diff --git a/testcases/kernel/syscalls/fcntl/fcntl18.c b/testcases/kernel/syscalls/fcntl/fcntl18.c |
| 142 | index 5eefbd128..1105dd393 100644 |
| 143 | --- a/testcases/kernel/syscalls/fcntl/fcntl18.c |
| 144 | +++ b/testcases/kernel/syscalls/fcntl/fcntl18.c |
| 145 | @@ -103,11 +103,11 @@ int main(int ac, char **av) |
| 146 | tst_resm(TINFO, "Enter block 2"); |
| 147 | fail = 0; |
| 148 | /* Error condition if address is bad */ |
| 149 | - retval = fcntl(fd, F_GETLK64, (struct flock *)INVAL_FLAG); |
| 150 | + retval = fcntl(fd, F_GETLK, (struct flock *)INVAL_FLAG); |
| 151 | if (errno == EFAULT) { |
| 152 | - tst_resm(TPASS, "Test F_GETLK64: for errno EFAULT PASSED"); |
| 153 | + tst_resm(TPASS, "Test F_GETLK: for errno EFAULT PASSED"); |
| 154 | } else { |
| 155 | - tst_resm(TFAIL, "Test F_GETLK64: for errno EFAULT FAILED"); |
| 156 | + tst_resm(TFAIL, "Test F_GETLK: for errno EFAULT FAILED"); |
| 157 | fail = 1; |
| 158 | } |
| 159 | if (fail) { |
| 160 | diff --git a/testcases/kernel/syscalls/fcntl/fcntl34.c b/testcases/kernel/syscalls/fcntl/fcntl34.c |
| 161 | index 3442114ff..536dead29 100644 |
| 162 | --- a/testcases/kernel/syscalls/fcntl/fcntl34.c |
| 163 | +++ b/testcases/kernel/syscalls/fcntl/fcntl34.c |
| 164 | @@ -54,7 +54,7 @@ void *thread_fn_01(void *arg) |
| 165 | |
| 166 | memset(buf, (intptr_t)arg, write_size); |
| 167 | |
| 168 | - struct flock64 lck = { |
| 169 | + struct flock lck = { |
| 170 | .l_whence = SEEK_SET, |
| 171 | .l_start = 0, |
| 172 | .l_len = 1, |
| 173 | diff --git a/testcases/kernel/syscalls/fcntl/fcntl36.c b/testcases/kernel/syscalls/fcntl/fcntl36.c |
| 174 | index d6b07fc41..4e4d48afc 100644 |
| 175 | --- a/testcases/kernel/syscalls/fcntl/fcntl36.c |
| 176 | +++ b/testcases/kernel/syscalls/fcntl/fcntl36.c |
| 177 | @@ -72,7 +72,7 @@ static void *fn_ofd_w(void *arg) |
| 178 | int fd = SAFE_OPEN(fname, O_RDWR); |
| 179 | long wt = pa->cnt; |
| 180 | |
| 181 | - struct flock64 lck = { |
| 182 | + struct flock lck = { |
| 183 | .l_whence = SEEK_SET, |
| 184 | .l_start = pa->offset, |
| 185 | .l_len = pa->length, |
| 186 | @@ -151,7 +151,7 @@ static void *fn_ofd_r(void *arg) |
| 187 | int i; |
| 188 | int fd = SAFE_OPEN(fname, O_RDWR); |
| 189 | |
| 190 | - struct flock64 lck = { |
| 191 | + struct flock lck = { |
| 192 | .l_whence = SEEK_SET, |
| 193 | .l_start = pa->offset, |
| 194 | .l_len = pa->length, |
| 195 | diff --git a/testcases/kernel/syscalls/llseek/Makefile b/testcases/kernel/syscalls/llseek/Makefile |
| 196 | index 044619fb8..8a916d0fa 100644 |
| 197 | --- a/testcases/kernel/syscalls/llseek/Makefile |
| 198 | +++ b/testcases/kernel/syscalls/llseek/Makefile |
| 199 | @@ -6,3 +6,5 @@ top_srcdir ?= ../../../.. |
| 200 | include $(top_srcdir)/include/mk/testcases.mk |
| 201 | |
| 202 | include $(top_srcdir)/include/mk/generic_leaf_target.mk |
| 203 | + |
| 204 | +CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE |
| 205 | diff --git a/testcases/kernel/syscalls/llseek/llseek01.c b/testcases/kernel/syscalls/llseek/llseek01.c |
| 206 | index 50f35493d..efb444dc8 100644 |
| 207 | --- a/testcases/kernel/syscalls/llseek/llseek01.c |
| 208 | +++ b/testcases/kernel/syscalls/llseek/llseek01.c |
| 209 | @@ -4,7 +4,7 @@ |
| 210 | * 07/2001 Ported by Wayne Boyer |
| 211 | */ |
| 212 | /* |
| 213 | - * Verify that lseek64() call succeeds to set the file pointer position to an |
| 214 | + * Verify that lseek() call succeeds to set the file pointer position to an |
| 215 | * offset larger than file size limit (RLIMIT_FSIZE). Also, verify that any |
| 216 | * attempt to write to this location fails. |
| 217 | */ |
| 218 | @@ -27,22 +27,22 @@ static int fildes; |
| 219 | |
| 220 | static void verify_llseek(void) |
| 221 | { |
| 222 | - TEST(lseek64(fildes, (loff_t) (80 * BUFSIZ), SEEK_SET)); |
| 223 | + TEST(lseek(fildes, (loff_t) (80 * BUFSIZ), SEEK_SET)); |
| 224 | if (TST_RET == (80 * BUFSIZ)) |
| 225 | - tst_res(TPASS, "lseek64() can set file pointer position larger than file size limit"); |
| 226 | + tst_res(TPASS, "lseek() can set file pointer position larger than file size limit"); |
| 227 | else |
| 228 | - tst_res(TFAIL, "lseek64() returned wrong value %ld when write past file size", TST_RET); |
| 229 | + tst_res(TFAIL, "lseek() returned wrong value %ld when write past file size", TST_RET); |
| 230 | |
| 231 | if (write(fildes, write_buff, BUFSIZ) == -1) |
| 232 | tst_res(TPASS,"write failed after file size limit"); |
| 233 | else |
| 234 | tst_brk(TFAIL, "write successful after file size limit"); |
| 235 | |
| 236 | - TEST(lseek64(fildes, (loff_t) BUFSIZ, SEEK_SET)); |
| 237 | + TEST(lseek(fildes, (loff_t) BUFSIZ, SEEK_SET)); |
| 238 | if (TST_RET == BUFSIZ) |
| 239 | - tst_res(TPASS,"lseek64() can set file pointer position under filer size limit"); |
| 240 | + tst_res(TPASS,"lseek() can set file pointer position under filer size limit"); |
| 241 | else |
| 242 | - tst_brk(TFAIL,"lseek64() returns wrong value %ld when write under file size", TST_RET); |
| 243 | + tst_brk(TFAIL,"lseek() returns wrong value %ld when write under file size", TST_RET); |
| 244 | |
| 245 | if (write(fildes, write_buff, BUFSIZ) != -1) |
| 246 | tst_res(TPASS, "write succcessfully under file size limit"); |
| 247 | diff --git a/testcases/kernel/syscalls/llseek/llseek02.c b/testcases/kernel/syscalls/llseek/llseek02.c |
| 248 | index 3d9c21fc9..5431969f9 100644 |
| 249 | --- a/testcases/kernel/syscalls/llseek/llseek02.c |
| 250 | +++ b/testcases/kernel/syscalls/llseek/llseek02.c |
| 251 | @@ -5,8 +5,8 @@ |
| 252 | */ |
| 253 | /* |
| 254 | * Description: |
| 255 | - * 1) lseek64(2) fails and sets errno to EINVAL when whence is invalid. |
| 256 | - * 2) lseek64(2) fails ans sets errno to EBADF when fd is not an open |
| 257 | + * 1) lseek(2) fails and sets errno to EINVAL when whence is invalid. |
| 258 | + * 2) lseek(2) fails ans sets errno to EBADF when fd is not an open |
| 259 | * file descriptor. |
| 260 | */ |
| 261 | |
| 262 | @@ -39,17 +39,17 @@ static void verify_llseek(unsigned int n) |
| 263 | { |
| 264 | struct tcase *tc = &tcases[n]; |
| 265 | |
| 266 | - TEST(lseek64(*tc->fd, (loff_t) 1, tc->whence)); |
| 267 | + TEST(lseek(*tc->fd, (loff_t) 1, tc->whence)); |
| 268 | if (TST_RET != (off_t) -1) { |
| 269 | - tst_res(TFAIL, "lseek64(%d, 1, %d) succeeded unexpectedly (%ld)", |
| 270 | + tst_res(TFAIL, "lseek(%d, 1, %d) succeeded unexpectedly (%ld)", |
| 271 | *tc->fd, tc->whence, TST_RET); |
| 272 | return; |
| 273 | } |
| 274 | if (TST_ERR == tc->exp_err) { |
| 275 | - tst_res(TPASS | TTERRNO, "lseek64(%d, 1, %d) failed as expected", |
| 276 | + tst_res(TPASS | TTERRNO, "lseek(%d, 1, %d) failed as expected", |
| 277 | *tc->fd, tc->whence); |
| 278 | } else { |
| 279 | - tst_res(TFAIL | TTERRNO, "lseek64(%d, 1, %d) failed " |
| 280 | + tst_res(TFAIL | TTERRNO, "lseek(%d, 1, %d) failed " |
| 281 | "unexpectedly, expected %s", *tc->fd, tc->whence, |
| 282 | tst_strerrno(tc->exp_err)); |
| 283 | } |
| 284 | diff --git a/testcases/kernel/syscalls/llseek/llseek03.c b/testcases/kernel/syscalls/llseek/llseek03.c |
| 285 | index d780f2af6..6c34119e5 100644 |
| 286 | --- a/testcases/kernel/syscalls/llseek/llseek03.c |
| 287 | +++ b/testcases/kernel/syscalls/llseek/llseek03.c |
| 288 | @@ -72,7 +72,7 @@ static const char *str_whence(int whence) |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | -static void verify_lseek64(unsigned int n) |
| 293 | +static void verify_lseek(unsigned int n) |
| 294 | { |
| 295 | struct tcase *tc = &tcases[n]; |
| 296 | char read_buf[128]; |
| 297 | @@ -82,7 +82,7 @@ static void verify_lseek64(unsigned int n) |
| 298 | |
| 299 | SAFE_READ(1, fd, read_buf, 4); |
| 300 | |
| 301 | - TEST(lseek64(fd, tc->off, tc->whence)); |
| 302 | + TEST(lseek(fd, tc->off, tc->whence)); |
| 303 | |
| 304 | if (TST_RET == -1) { |
| 305 | tst_res(TFAIL | TTERRNO, "llseek failed on %s ", TEST_FILE); |
| 306 | @@ -121,6 +121,6 @@ exit: |
| 307 | static struct tst_test test = { |
| 308 | .needs_tmpdir = 1, |
| 309 | .setup = setup, |
| 310 | - .test = verify_lseek64, |
| 311 | + .test = verify_lseek, |
| 312 | .tcnt = ARRAY_SIZE(tcases), |
| 313 | }; |
| 314 | diff --git a/testcases/kernel/syscalls/open/Makefile b/testcases/kernel/syscalls/open/Makefile |
| 315 | index 044619fb8..8a916d0fa 100644 |
| 316 | --- a/testcases/kernel/syscalls/open/Makefile |
| 317 | +++ b/testcases/kernel/syscalls/open/Makefile |
| 318 | @@ -6,3 +6,5 @@ top_srcdir ?= ../../../.. |
| 319 | include $(top_srcdir)/include/mk/testcases.mk |
| 320 | |
| 321 | include $(top_srcdir)/include/mk/generic_leaf_target.mk |
| 322 | + |
| 323 | +CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE |
| 324 | diff --git a/testcases/kernel/syscalls/open/open12.c b/testcases/kernel/syscalls/open/open12.c |
| 325 | index bdf29a9a8..c840de53d 100644 |
| 326 | --- a/testcases/kernel/syscalls/open/open12.c |
| 327 | +++ b/testcases/kernel/syscalls/open/open12.c |
| 328 | @@ -233,14 +233,14 @@ static void test_cloexec(void) |
| 329 | static void test_largefile(void) |
| 330 | { |
| 331 | int fd; |
| 332 | - off64_t offset; |
| 333 | + off_t offset; |
| 334 | |
| 335 | fd = SAFE_OPEN(cleanup, LARGE_FILE, |
| 336 | O_LARGEFILE | O_RDWR | O_CREAT, 0777); |
| 337 | |
| 338 | - offset = lseek64(fd, 4.1*1024*1024*1024, SEEK_SET); |
| 339 | + offset = lseek(fd, 4.1*1024*1024*1024, SEEK_SET); |
| 340 | if (offset == -1) |
| 341 | - tst_brkm(TBROK | TERRNO, cleanup, "lseek64 failed"); |
| 342 | + tst_brkm(TBROK | TERRNO, cleanup, "lseek failed"); |
| 343 | |
| 344 | SAFE_WRITE(cleanup, 1, fd, LARGE_FILE, sizeof(LARGE_FILE)); |
| 345 | |
| 346 | diff --git a/testcases/kernel/syscalls/openat/Makefile b/testcases/kernel/syscalls/openat/Makefile |
| 347 | index 044619fb8..8a916d0fa 100644 |
| 348 | --- a/testcases/kernel/syscalls/openat/Makefile |
| 349 | +++ b/testcases/kernel/syscalls/openat/Makefile |
| 350 | @@ -6,3 +6,5 @@ top_srcdir ?= ../../../.. |
| 351 | include $(top_srcdir)/include/mk/testcases.mk |
| 352 | |
| 353 | include $(top_srcdir)/include/mk/generic_leaf_target.mk |
| 354 | + |
| 355 | +CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE |
| 356 | diff --git a/testcases/kernel/syscalls/openat/openat02.c b/testcases/kernel/syscalls/openat/openat02.c |
| 357 | index 2ce119033..f6113852a 100644 |
| 358 | --- a/testcases/kernel/syscalls/openat/openat02.c |
| 359 | +++ b/testcases/kernel/syscalls/openat/openat02.c |
| 360 | @@ -22,7 +22,7 @@ |
| 361 | * 2)openat() succeeds to enable the close-on-exec flag for a |
| 362 | * file descriptor, when 'flags' is set to O_CLOEXEC. |
| 363 | * 3)openat() succeeds to allow files whose sizes cannot be |
| 364 | - * represented in an off_t but can be represented in an off64_t |
| 365 | + * represented in an off_t but can be represented in an off_t |
| 366 | * to be opened, when 'flags' is set to O_LARGEFILE. |
| 367 | * 4)openat() succeeds to not update the file last access time |
| 368 | * (st_atime in the inode) when the file is read, when 'flags' |
| 369 | @@ -193,12 +193,12 @@ void testfunc_cloexec(void) |
| 370 | void testfunc_largefile(void) |
| 371 | { |
| 372 | int fd; |
| 373 | - off64_t offset; |
| 374 | + off_t offset; |
| 375 | |
| 376 | fd = SAFE_OPEN(cleanup, LARGE_FILE, |
| 377 | O_LARGEFILE | O_RDWR | O_CREAT, 0777); |
| 378 | |
| 379 | - offset = lseek64(fd, 4.1*1024*1024*1024, SEEK_SET); |
| 380 | + offset = lseek(fd, 4.1*1024*1024*1024, SEEK_SET); |
| 381 | if (offset == -1) |
| 382 | tst_brkm(TBROK | TERRNO, cleanup, "lseek64 failed"); |
| 383 | |
| 384 | diff --git a/testcases/kernel/syscalls/sync_file_range/Makefile b/testcases/kernel/syscalls/sync_file_range/Makefile |
| 385 | index 044619fb8..8a916d0fa 100644 |
| 386 | --- a/testcases/kernel/syscalls/sync_file_range/Makefile |
| 387 | +++ b/testcases/kernel/syscalls/sync_file_range/Makefile |
| 388 | @@ -6,3 +6,5 @@ top_srcdir ?= ../../../.. |
| 389 | include $(top_srcdir)/include/mk/testcases.mk |
| 390 | |
| 391 | include $(top_srcdir)/include/mk/generic_leaf_target.mk |
| 392 | + |
| 393 | +CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE |
| 394 | diff --git a/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c b/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c |
| 395 | index 187ef6071..47188aa48 100644 |
| 396 | --- a/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c |
| 397 | +++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c |
| 398 | @@ -44,8 +44,8 @@ static int bfd = -1; |
| 399 | |
| 400 | struct test_case { |
| 401 | int *fd; |
| 402 | - off64_t offset; |
| 403 | - off64_t nbytes; |
| 404 | + off_t offset; |
| 405 | + off_t nbytes; |
| 406 | unsigned int flags; |
| 407 | int error; |
| 408 | } tcases[] = { |
| 409 | diff --git a/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c |
| 410 | index 5da751c70..28a8156c8 100644 |
| 411 | --- a/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c |
| 412 | +++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c |
| 413 | @@ -31,10 +31,10 @@ |
| 414 | |
| 415 | struct testcase { |
| 416 | char *fname; |
| 417 | - off64_t sync_off; |
| 418 | - off64_t sync_size; |
| 419 | + off_t sync_off; |
| 420 | + off_t sync_size; |
| 421 | size_t exp_sync_size; |
| 422 | - off64_t write_off; |
| 423 | + off_t write_off; |
| 424 | size_t write_size_mb; |
| 425 | const char *desc; |
| 426 | }; |