[LTP] [PATCH v5 4/7] syscalls/statx01: Relax mnt_id test condition

Eric Biggers ebiggers@kernel.org
Sat May 13 02:28:54 CEST 2023


Hi Yang,

On Tue, May 09, 2023 at 05:14:05PM +0800, Yang Xu wrote:
> Before this patch, we test stx_mnt_id only when glibc's statx struct has
> this member. Now, if glibc miss this filed, we will use __spare2[0], see
> url[1]. If glibc miss statx struct, we will use ltp owner definition.

I don't think this is the right approach either.  Actually, this new proposal is
arguably worse than leaving the problem unsolved.  The problem with this new
proposal is that the fields in struct statx whose names are prefixed with
"__spare" were never intended to be used directly.  Their names can change from
one kernel version to the next, and they can change to a different offset and/or
size while keeping the same name.  That can result in breakages that only
reproduce on very specific versions of <sys/stat.h>.

As I've said several times, the proper way to ensure that the tests can be built
even when the system struct statx doesn't contain all the needed fields is to
use the LTP struct statx whenever the system one does not fully suffice.

One way to do that would be to make the tests use the struct via a different
name, such as struct ltp_statx, and define that to either the system statx or
the LTP statx depending on which one has the right definition.

It might also be possible to #define statx to achieve the same effect (though
maybe that would cause a collision with the function statx()...)

Anyway, I don't want to derail the STATX_DIOALIGN test too much, so if you're
having a lot of trouble solving this problem properly, I'm okay with just
adding the STATX_DIOALIGN test without it solved for now...

- Eric


More information about the ltp mailing list