Skip to content

Commit

Permalink
lsfd: include linux/fcntl.h
Browse files Browse the repository at this point in the history
asm/-headers are implementation details and not meant to be included
directly. Instead use the linux/ header which will always include the
correct asm/-headers.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
  • Loading branch information
t-8ch committed Apr 28, 2024
1 parent 93128b7 commit b6e6fb4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
2 changes: 0 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@ AC_CHECK_HEADERS([linux/compiler.h linux/blkpg.h linux/major.h], [], [], [
#endif
])
AC_CHECK_HEADERS([ \
asm-generic/fcntl.h \
asm/fcntl.h \
asm/io.h \
byteswap.h \
endian.h \
Expand Down
16 changes: 5 additions & 11 deletions lsfd-cmd/decode-file-flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,24 @@

/* lsfd_decode_file_flags() is for decoding `flags' field of
* /proc/$pid/fdinfo/$fd. Bits of the field have name defined
* in fctl.h.
* in fcntl.h.
* A system on which lsfd is built may have multiple
* fctl.h files:
* fcntl.h files:
*
* - /usr/include/linux/fcntl.h (a part of Linux kernel)
* - /usr/include/asm/fcntl.h (a part of Linux kernel)
* - /usr/include/asm-generic/fcntl.h (a part of Linux kernel)
* - /usr/include/fcntl.h (a part of glibc)
* - /usr/include/bits/fcntl.h (a part of glibc)
*
* For decoding purpose, /usr/include/asm/fcntl.h or
* /usr/include/asm-generic/fcntl.h is needed.
* For decoding purpose, /usr/include/linuc/fcntl.h is needed.
*
* /usr/include/bits/fcntl.h and /usr/include/fcntl.h are
* not suitable for decoding. They should not be included.
* /usr/include/fcntl.h includes /usr/include/bits/fcntl.h.
*/

#if defined HAVE_ASM_FCNTL_H
#include <asm/fcntl.h>
#elif defined HAVE_ASM_GENERIC_FCNTL_H
#include <asm-generic/fcntl.h>
#else
#error "kernel's fcntl.h is not available"
#endif
#include <linux/fcntl.h>

#include <stddef.h> /* for size_t */
struct ul_buffer;
Expand Down
2 changes: 0 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ headers = '''
unistd.h
utmp.h
utmpx.h
asm-generic/fcntl.h
asm/fcntl.h
asm/io.h
linux/blkzoned.h
linux/capability.h
Expand Down

0 comments on commit b6e6fb4

Please sign in to comment.