summaryrefslogtreecommitdiff
path: root/sys-fs/inotify-tools/files/inotify-tools-3.22.6.0-musl.patch
blob: 0b6c9dbbe930ee315b776e9a1bafe2642128375a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
https://bugs.gentoo.org/831976 (undeclared _kernel_fsid_t)
https://bugs.gentoo.org/907887 (musl-1.2.4 lfs64 issues)

https://github.com/inotify-tools/inotify-tools/commit/8367bdd1eda71c10ab0a49c694846a622e543807
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 30 Dec 2022 04:04:56 -0800
Subject: [PATCH] Fix build with musl and add Alpine buildnode to CI (#174)

* configure: Add AC_SYS_LARGEFILE autoconf macro

This will define _FILE_OFFSET_BITS to be 64 if off_t is 64bit
and we do not need to define lfs64 functions

Signed-off-by: Khem Raj <raj.khem@gmail.com>

* Fix build for out-of-tree builds

When build tree is outside source-tree its not able to find
fanotify-dfid-name.h, add needed include paths on compiler commandline

Signed-off-by: Khem Raj <raj.khem@gmail.com>

* libinotifytools: Bridge differences between musl/glibc/kernel fnotify.h

System detects to use sys/fnotify.h and then assumes glibc's definitions
but musl has definitions of its own. perhaps portable thing would be to
use linux/fnotify.h interface directly on linux irrespective of libc

See the differences discussion here [1]

[1] https://inbox.vuxu.org/musl/20191112220151.GC27331@x230/T/#ma8700992467200c8792e0fa8508eae656b81aeba

Signed-off-by: Khem Raj <raj.khem@gmail.com>

* replace stat64/lstat64 with stat/lstat

lfs64 functions are not needed when off_t is 64-bit
Additionally this fixes build with musl which does not
export these functions without defining _LARGEFILE64_SOURCE

Signed-off-by: Khem Raj <raj.khem@gmail.com>

* Apply changes from clang-format

Signed-off-by: Khem Raj <raj.khem@gmail.com>

* Fix errors found by clang-format

Fixes
-Wno-gnu-variable-sized-type-not-at-end for musl clang-format

Signed-off-by: Khem Raj <raj.khem@gmail.com>

* ci: Enable musl in CI using alpine

Signed-off-by: Khem Raj <raj.khem@gmail.com>

* Tell clang-tidy to ignore warning about variable sized type

Signed-off-by: Eric Curtin <ecurtin@redhat.com>

* Add gcompat for code coverage tool

Signed-off-by: Eric Curtin <ecurtin@redhat.com>

* Skip sonarcloud on alpine

Signed-off-by: Eric Curtin <ecurtin@redhat.com>

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Eric Curtin <ecurtin@redhat.com>
Co-authored-by: Eric Curtin <ecurtin@redhat.com>
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,9 @@ AC_PROG_CC
 AM_INIT_AUTOMAKE
 LT_INIT
 
+# Add option for largefile support
+AC_SYS_LARGEFILE
+
 AC_PATH_PROG(DOXYGEN, doxygen, NO_DOXYGEN)
 
 AC_ARG_ENABLE(doxygen,
--- a/libinotifytools/src/Makefile.am
+++ b/libinotifytools/src/Makefile.am
@@ -2,6 +2,7 @@ SUBDIRS = inotifytools
 
 lib_LTLIBRARIES = libinotifytools.la
 libinotifytools_la_SOURCES = inotifytools.c inotifytools_p.h redblack.c redblack.h stats.c stats.h
+libinotifytools_la_CFLAGS = -I$(srcdir)/inotifytools
 libinotifytools_la_LDFLAGS = -version-info 4:1:4
 
 check_PROGRAMS = test
--- a/libinotifytools/src/inotifytools.c
+++ b/libinotifytools/src/inotifytools.c
@@ -51,10 +51,16 @@ struct fanotify_event_fid;
 #include <sys/vfs.h>
 #include "inotifytools/fanotify.h"
 
+#ifndef __GLIBC__
+#define val __val
+#define __kernel_fsid_t fsid_t
+#endif
+
 struct fanotify_event_fid {
 	struct fanotify_event_info_fid info;
 	struct file_handle handle;
 };
+
 #endif
 
 /**
@@ -1746,14 +1752,14 @@ int inotifytools_watch_recursively_with_exclude(char const* path,
 
 	static struct dirent * ent;
 	char * next_file;
-	static struct stat64 my_stat;
+	static struct stat my_stat;
 	ent = readdir( dir );
 	// Watch each directory within this directory
 	while ( ent ) {
 		if ( (0 != strcmp( ent->d_name, "." )) &&
 		     (0 != strcmp( ent->d_name, ".." )) ) {
 			nasprintf(&next_file,"%s%s", my_path, ent->d_name);
-			if ( -1 == lstat64( next_file, &my_stat ) ) {
+			if (-1 == lstat(next_file, &my_stat)) {
 				error = errno;
 				free( next_file );
 				if ( errno != EACCES ) {
@@ -1836,9 +1841,9 @@ int inotifytools_error() {
  * @internal
  */
 static int isdir( char const * path ) {
-	static struct stat64 my_stat;
+	static struct stat my_stat;
 
-	if ( -1 == lstat64( path, &my_stat ) ) {
+	if (-1 == lstat(path, &my_stat)) {
 		if (errno == ENOENT) return 0;
 		fprintf(stderr, "Stat failed on %s: %s\n", path, strerror(errno));
 		return 0;
--- a/libinotifytools/src/inotifytools/fanotify-dfid-name.h
+++ b/libinotifytools/src/inotifytools/fanotify-dfid-name.h
@@ -129,7 +129,7 @@ struct fanotify_event_info_fid {
 	 * Following is an opaque struct file_handle that can be passed as
 	 * an argument to open_by_handle_at(2).
 	 */
-	unsigned char handle[0];
+	unsigned char handle[];
 };
 
 struct fanotify_response {
--- a/libinotifytools/src/inotifytools/inotify-nosys.h
+++ b/libinotifytools/src/inotifytools/inotify-nosys.h
@@ -13,11 +13,6 @@
 #include <sys/syscall.h>
 #include <unistd.h>
 
-#ifdef __FreeBSD__
-#define stat64 stat
-#define lstat64 lstat
-#endif
-
 /*
  * struct inotify_event - structure read from the inotify device for each event
  *
--- a/libinotifytools/src/inotifytools/inotifytools.h
+++ b/libinotifytools/src/inotifytools/inotifytools.h
@@ -1,11 +1,6 @@
 #ifndef _inotifytools_H
 #define _inotifytools_H
 
-#ifdef __FreeBSD__
-#define stat64 stat
-#define lstat64 lstat
-#endif
-
 #ifdef __cplusplus
 extern "C"
 {
--- a/src/common.c
+++ b/src/common.c
@@ -45,14 +45,15 @@ void print_event_descriptions() {
 }
 
 int isdir(char const *path) {
-    static struct stat64 my_stat;
-
-    if (-1 == lstat64(path, &my_stat)) {
-        if (errno == ENOENT)
-            return 0;
-        fprintf(stderr, "Stat failed on %s: %s\n", path, strerror(errno));
-        return 0;
-    }
+	static struct stat my_stat;
+
+	if (-1 == lstat(path, &my_stat)) {
+		if (errno == ENOENT)
+			return 0;
+		fprintf(stderr, "Stat failed on %s: %s\n", path,
+			strerror(errno));
+		return 0;
+	}
 
     return S_ISDIR(my_stat.st_mode) && !S_ISLNK(my_stat.st_mode);
 }
--- a/src/common.h
+++ b/src/common.h
@@ -1,13 +1,9 @@
 #ifndef COMMON_H
 #define COMMON_H
 
-#ifdef __FreeBSD__
-#define stat64 stat
-#define lstat64 lstat
-#ifdef ENABLE_FANOTIFY
+#if defined(__FreeBSD__) && defined(ENABLE_FANOTIFY)
 #error "FreeBSD does not support fanotify"
 #endif
-#endif
 
 #include <stdbool.h>