libc/misc: Add statx() via struct stat composition. - #20035
Closed
xiaoxiang781216 wants to merge 1 commit into
Closed
libc/misc: Add statx() via struct stat composition.#20035xiaoxiang781216 wants to merge 1 commit into
xiaoxiang781216 wants to merge 1 commit into
Conversation
Implement the Linux statx(2) extended-status interface as a libc function that composes stat/lstat/fstat, following the existing fstatat() pattern. Expose the exact Linux struct statx ABI together with the STATX_* mask/attribute constants and AT_STATX_SYNC_* flags so ported code such as libuv, glib and libfuse builds unchanged. NuttX can only fill STATX_BASIC_STATS; btime, mount ID and DIO alignment remain zero with their mask bits clear. AT_EMPTY_PATH is handled via fstat(), AT_STATX_SYNC_* and AT_NO_AUTOMOUNT are accepted as no-ops, and the mask argument is treated as a hint, which Linux permits. Assisted-by: Copilot:zhipuai/glm-5.3 Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add the Linux
statx(2)extended-status interface to the libc as a composition of the existingstat/lstat/fstat/fstatatimplementations, following thefstatat()pattern:include/sys/stat.h: expose the exact Linuxstruct statx/struct statx_timestampABI (fixed-width fields, so the layout is stable across toolchains and a future kernel-space implementation will not break the user-space ABI), theSTATX_*request/result mask constants, and theSTATX_ATTR_*attribute constants.include/fcntl.h: add theAT_STATX_SYNC_AS_STAT/AT_STATX_FORCE_SYNC/AT_STATX_DONT_SYNC/AT_STATX_SYNC_TYPEandAT_RECURSIVEconstants.libs/libc/misc/lib_statx.c: implementstatx()by resolving the path likefstatat()(vialib_getfullpath()) and translating the resultingstruct statinto thestruct statxlayout.Semantics: NuttX can only fill
STATX_BASIC_STATS; birth time, mount ID and DIO alignment stay zero with their mask bits clear.AT_EMPTY_PATHis handled viafstat(),AT_STATX_SYNC_*andAT_NO_AUTOMOUNTare accepted as no-ops, and themaskargument is treated as a hint, which Linux also permits (the kernel may return more or fewer fields than requested).Ported code that uses
statx()(libuv, glib, libfuse, ...) now builds and runs unchanged.Impact
struct stat,stat(),lstat(),fstat()andfstatat()are untouched.statx()is always available like the other stat family members.lib_statx.c)./proc/mountsat runtime, so they are black-listed in the LTP port for now).Testing
Built and booted
sim:nshwith this change on top of apache/master (commit035d131b3cc):ostestpasses with 0 failures:tools/checkpatch.sh -c -u -m -g apache/master..HEADpasses.