Skip to content

Conversation

@rusty-snake
Copy link
Contributor

Description

This PR updates statx constants and types for features added in Linux 6.8 to 6.14.

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot label +stable-nominated

@rustbot
Copy link
Collaborator

rustbot commented Apr 12, 2025

r? @tgross35

rustbot has assigned @tgross35.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added O-linux-like O-unix S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Apr 12, 2025
@rusty-snake
Copy link
Contributor Author

No idea why CI is failing.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as long as CI passes

@tgross35 tgross35 enabled auto-merge April 16, 2025 18:02
@tgross35 tgross35 force-pushed the statx-update branch 3 times, most recently from 1cb7f9b to 82fecbd Compare April 25, 2025 06:16
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some of this may not be available on arm32 Android, can you check this against the bionic headers? https://cs.android.com/android/platform/superproject/main, cc @maurer

@rusty-snake
Copy link
Contributor Author

I'm not familiar with bionic/their source tree or how to check. Do we know it works on non-arm32 android (e.g. armv8)? Because the CI skipping it's sometimes hard to tell whether it broken because of architecture or libc or both. I can #[cfg] them out it this is wanted but I suspect it is more likely that they were added to recent. Android 15 uses Linux 6.6 as the "main-kernel" right now AFAIK. These were all added in Linux 6.8 and later. Bionic supports statx so I suspect it will also support these new flags.

Copy link

@maurer maurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tl;dr:

  • Remove support for statx_dio_read_align on Android; it won't arrive for at least a year.
  • Bump the NDK version to 28, and the rest of your stuff should work.

This is going to be compatible from the Android PoV - only STATX_DIO_READ_ALIGN is not yet present in bionic, and that's likely because the latest kernel version Android uses is 6.12 right now.

The reason you're getting an error from offsetof for stx_subvol is not because of the architecture, it's because NDK 27 (current LTS NDK) does not yet have that field. NDK 28 (stable and released, but not LTS) does.

Probably (subject to @tgross35 agreement) we should switch to NDK 28b in this PR.

Support in bionic for statx_dio_read_align is probably more than a year out, because Android needs to release a kernel >= 6.14, and then needs to have an NDK release. I don't anticipate any differences between our support and anyone else's, but no Android device will exist that supports it for at least a year, so it'd be a mistake to try to use it. I'd suggest configuring out statx_dio_read_align both field and constant.

pub const STATX_MNT_ID_UNIQUE: c_uint = 0x4000;
pub const STATX_SUBVOL: c_uint = 0x_0000_8000;
pub const STATX_WRITE_ATOMIC: c_uint = 0x_0001_0000;
pub const STATX_DIO_READ_ALIGN: c_uint = 0x_0002_0000;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constant is not yet present in bionic, likely because it was introduced to Linux in 6.14, and the latest Android kernel is 6.12.

@tgross35
Copy link
Contributor

Probably (subject to @tgross35 agreement) we should switch to NDK 28b in this PR.

I have no objections to bumping the version. Is there any chance you, or anyone else from the android team / more familiar, might be able to do it in a separate PR? We have been having some pretty consistent intermittent failures (#4297), it would be good for somebody more familiar with the platform to double check that the way we are setting up and testing actually makes sense.

@tgross35
Copy link
Contributor

@rusty-snake would you be able to rebase this? If there are still Android CI failures, it would be fine to move the constants to linux_like/linux and then cfg out the fields for Android (As Matthew mentioned above)

auto-merge was automatically disabled November 2, 2025 14:25

Head branch was pushed to by a user without write access

@rustbot
Copy link
Collaborator

rustbot commented Nov 2, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Comment on lines +4223 to +4266
// linux 5.17 min
"PR_SET_VMA" | "PR_SET_VMA_ANON_NAME" => true,

// present in recent kernels only
"PR_SCHED_CORE" | "PR_SCHED_CORE_CREATE" | "PR_SCHED_CORE_GET" | "PR_SCHED_CORE_MAX" | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" | "PR_SCHED_CORE_SCOPE_THREAD" | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => true,

// present in recent kernels only >= 5.13
"PR_PAC_SET_ENABLED_KEYS" | "PR_PAC_GET_ENABLED_KEYS" => true,
// present in recent kernels only >= 5.19
"PR_SME_SET_VL" | "PR_SME_GET_VL" | "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" => true,

// Added in Linux 5.14
"FUTEX_LOCK_PI2" => true,

// Added in linux 6.1
"STATX_DIOALIGN"
| "CAN_RAW_XL_FRAMES"
| "CANXL_HDR_SIZE"
| "CANXL_MAX_DLC"
| "CANXL_MAX_DLC_MASK"
| "CANXL_MAX_DLEN"
| "CANXL_MAX_MTU"
| "CANXL_MIN_DLC"
| "CANXL_MIN_DLEN"
| "CANXL_MIN_MTU"
| "CANXL_MTU"
| "CANXL_PRIO_BITS"
| "CANXL_PRIO_MASK"
| "CANXL_SEC"
| "CANXL_XLF"
=> true,

"STATX_MNT_ID_UNIQUE" // Added in Linux 6.8
| "STATX_SUBVOL" // Added in Linux 6.10
| "STATX_WRITE_ATOMIC" // Added in Linux 6.11
| "STATX_ATTR_WRITE_ATOMIC" // Added in Linux 6.11
| "STATX_DIO_READ_ALIGN" // Added in Linux 6.14
=> true,

// FIXME(linux): Parts of netfilter/nfnetlink*.h require more recent kernel headers:
| "RTNLGRP_MCTP_IFADDR" // linux v5.17+
| "RTNLGRP_TUNNEL" // linux v5.18+
| "RTNLGRP_STATS" // linux v5.18+
=> true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this come through the rebase? Most of these constants are unrelated to what is added here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-linux-like O-unix S-waiting-on-author stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants