]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libmount: check for struct statx
authorMarkus Mayer <mmayer@broadcom.com>
Tue, 1 Aug 2023 19:59:27 +0000 (12:59 -0700)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Aug 2023 09:28:19 +0000 (11:28 +0200)
commita64cec15a9e050f0cec57081ec621507a8d8008d
tree1adcb9799a8d7ea276ed9a545be9ff34782b99b2
parent396798d6b08ba762958aabd3edb84b5c76c2b8a5
libmount: check for struct statx

Let's ensure struct statx exists before we try to use it. Checking for
the existence of linux/stat.h is not sufficient. This is because
[uapi/]linux/stat.h has existed since Linux 3.7, however struct statx
was only introduced with Linux 4.11.

The problem arises if one happens ot be using kernel headers from within
the aforementioned range, such as Linux 4.9.

  CC       libmount/src/la-utils.lo
In file included from libmount/src/utils.c:31:
./include/fileutils.h:100:33: warning: declaration of 'struct statx' will not
be visible outside of this function [-Wvisibility]
                    unsigned int mask, struct statx *stx)
                                              ^
libmount/src/utils.c:117:16: error: variable has incomplete type 'struct statx'
                struct statx stx = { 0 };
                             ^
libmount/src/utils.c:117:10: note: forward declaration of 'struct statx'
                struct statx stx = { 0 };
                       ^
libmount/src/utils.c:125:5: error: use of undeclared identifier 'STATX_TYPE'
                                STATX_TYPE
                                ^
libmount/src/utils.c:126:8: error: use of undeclared identifier 'STATX_MODE'
                                        | STATX_MODE
                                          ^
libmount/src/utils.c:127:8: error: use of undeclared identifier 'STATX_INO'
                                        | STATX_INO,
                                          ^
1 warning and 4 errors generated.
make[4]: *** [Makefile:11269: libmount/src/la-utils.lo] Error 1

Checking for the presence of struct statx explicitly avoids this
problem.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
configure.ac
include/fileutils.h
libmount/src/utils.c