Skip to content

Commit

Permalink
zfs-test/mmap_seek: fix build on musl
Browse files Browse the repository at this point in the history
it needs linux/fs.h for SEEK_DATA and friends

without linux/fs.h:

```
mmap_seek.c
mmap_seek.c: In function 'seek_data':
mmap_seek.c:37:40: error: 'SEEK_DATA' undeclared (first use in this function);
did you mean 'SEEK_SET'?
   37 |  off_t data_offset = lseek(fd, offset, SEEK_DATA);
```

also it needs sys/sysmacros.h for P2ROUNDUP
without it:

```
mmap_seek.c: In function 'main':
mmap_seek.c:122:19: warning:
implicit declaration of function 'P2ROUNDUP' [-Wimplicit-function-declaration]
  122 |  seek_hole(fd, 0, P2ROUNDUP(file_size / 2, block_size));
      |                   ^~~~~~~~~
powerpc64-gentoo-linux-musl/bin/ld: mmap_seek.o: in function `main':
mmap_seek.c:(.text.startup+0x1b8): undefined reference to `P2ROUNDUP'
powerpc64-gentoo-linux-musl/bin/ld: mmap_seek.c:(.text.startup+0x1d8):
	undefined reference to `P2ROUNDUP'
powerpc64-gentoo-linux-musl/bin/ld: mmap_seek.c:(.text.startup+0x21c):
	undefined reference to `P2ROUNDUP'
collect2: error: ld returned 1 exit status
make[5]: *** [Makefile:754: mmap_seek] Error 1
```

Closes: #12891
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
  • Loading branch information
gyakovlev committed Dec 20, 2021
1 parent 8623bd9 commit 123c87b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/zfs-tests/cmd/mmap_seek/mmap_seek.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/sysmacros.h>
#include <errno.h>
#ifdef __linux__
#include <linux/fs.h>
#endif

static void
seek_data(int fd, off_t offset, off_t expected)
Expand Down

0 comments on commit 123c87b

Please sign in to comment.