Skip to content

Commit a89e4a9

Browse files
committed
syscalls/fallocate01: Fix compilation failure.
On newer distribution the addition of _GNU_SOURCE breaks the compilation because it exposes the FALLOC_FL_KEEP_SIZE as a macro constant which breaks the enum defition. So this commit adds FALLOC_FL_KEEP_SIZE to lapi/fcntl.h and removes the enum. Signed-off-by: Cyril Hrubis <[email protected]>
1 parent b24ce8f commit a89e4a9

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

include/lapi/fcntl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,8 @@
5555
# define O_NOATIME 01000000
5656
#endif
5757

58+
#ifndef FALLOC_FL_KEEP_SIZE
59+
# define FALLOC_FL_KEEP_SIZE 1
60+
#endif
61+
5862
#endif /* __LAPI_FCNTL_H__ */

testcases/kernel/syscalls/fallocate/fallocate01.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
#include "test.h"
104104
#include "usctest.h"
105105
#include "fallocate.h"
106+
#include "lapi/fcntl.h"
106107

107108
#define BLOCKS_WRITTEN 12
108109

@@ -198,8 +199,6 @@ void populate_files(int fd)
198199

199200
int main(int ac, char **av)
200201
{
201-
int fd;
202-
enum { DEFAULT, FALLOC_FL_KEEP_SIZE } mode;
203202
loff_t expected_size;
204203
int lc;
205204
char *msg;
@@ -210,23 +209,13 @@ int main(int ac, char **av)
210209
setup();
211210

212211
for (lc = 0; TEST_LOOPING(lc); lc++) {
213-
214212
tst_count = 0;
215213

216-
for (mode = DEFAULT; mode <= FALLOC_FL_KEEP_SIZE; mode++) {
217-
switch (mode) {
218-
case DEFAULT:
219-
fd = fd_mode1;
220-
expected_size =
221-
BLOCKS_WRITTEN * block_size + block_size;
222-
break;
223-
case FALLOC_FL_KEEP_SIZE:
224-
fd = fd_mode2;
225-
expected_size = BLOCKS_WRITTEN * block_size;
226-
break;
227-
}
228-
runtest(mode, fd, expected_size);
229-
}
214+
expected_size = BLOCKS_WRITTEN * block_size + block_size;
215+
runtest(0, fd_mode1, expected_size);
216+
217+
expected_size = BLOCKS_WRITTEN * block_size;
218+
runtest(FALLOC_FL_KEEP_SIZE, fd_mode2, expected_size);
230219
}
231220

232221
cleanup();

0 commit comments

Comments
 (0)