Skip to content

Commit 3193e89

Browse files
listoutjankara
authored andcommitted
samples: fix building fs-monitor on musl systems
samples/fanotify/fs-monitor.c:22:9: error: unknown type name '__s32' 22 | __s32 error; | ^~~~~ samples/fanotify/fs-monitor.c:23:9: error: unknown type name '__u32' 23 | __u32 error_count; | ^~~~~ samples/fanotify/fs-monitor.c: In function 'handle_notifications': samples/fanotify/fs-monitor.c:98:50: error: 'fsid_t' has no member named 'val'; did you mean '__val'? 98 | fid->fsid.val[0], fid->fsid.val[1]); | ^~~ | __val samples/fanotify/fs-monitor.c:98:68: error: 'fsid_t' has no member named 'val'; did you mean '__val'? 98 | fid->fsid.val[0], fid->fsid.val[1]); | ^~~ | __val This is due to sys/fanotify.h on musl does not include linux/fanotify.h[0] unlike glibc which includes it. This also results in fsid not being of type __kernel_fsid_t, rather the libc's definition of it which does not have val, but instead __val. [0]: https://git.musl-libc.org/cgit/musl/tree/include/sys/fanotify.h Signed-off-by: Brahmajit Das <[email protected]> Signed-off-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 8631e01 commit 3193e89

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

samples/fanotify/fs-monitor.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include <sys/fanotify.h>
1313
#include <sys/types.h>
1414
#include <unistd.h>
15+
#ifndef __GLIBC__
16+
#include <asm-generic/int-ll64.h>
17+
#endif
1518

1619
#ifndef FAN_FS_ERROR
1720
#define FAN_FS_ERROR 0x00008000
@@ -95,7 +98,11 @@ static void handle_notifications(char *buffer, int len)
9598
fid = (struct fanotify_event_info_fid *) info;
9699

97100
printf("\tfsid: %x%x\n",
101+
#if defined(__GLIBC__)
98102
fid->fsid.val[0], fid->fsid.val[1]);
103+
#else
104+
fid->fsid.__val[0], fid->fsid.__val[1]);
105+
#endif
99106
print_fh((struct file_handle *) &fid->handle);
100107
break;
101108

0 commit comments

Comments
 (0)