[PATCH v4] linux: Add linux statx(fd, NULL, AT_EMPTY_PATH) support
Xi Ruoyao
xry111@xry111.site
Wed Aug 28 11:26:40 GMT 2024
On Wed, 2024-08-28 at 19:06 +0800, Miao Wang wrote:
> Hi,
>
> > 2024年8月28日 17:12,Florian Weimer <fweimer@redhat.com> 写道:
> >
> > * Miao Wang via:
> >
> > > diff --git a/sysdeps/unix/sysv/linux/internal-stat.h b/sysdeps/unix/sysv/linux/internal-stat.h
> > > index 9334059765..263e29637f 100644
> > > --- a/sysdeps/unix/sysv/linux/internal-stat.h
> > > +++ b/sysdeps/unix/sysv/linux/internal-stat.h
> > > @@ -29,3 +29,30 @@
> > > #else
> > > # define FSTATAT_USE_STATX 0
> > > #endif
> > > +
> > > +#if FSTATAT_USE_STATX || XSTAT_IS_XSTAT64
> > > +
> > > +/* buf MUST be a valid buffer, or the feature detection may not work properly */
> > > +
> >
> > “BUF must be a valid buffer”, I think.
> >
> > > +static inline int
> > > +__statx_empty_path (int fd, int flag, struct statx *buf)
> > > +{
> > > + flag |= AT_EMPTY_PATH;
> > > +#ifdef __ASSUME_STATX_NULL_PATH
> > > + return INTERNAL_SYSCALL_CALL (statx, fd, NULL, flag, STATX_BASIC_STATS, buf);
> > > +#else
> > > + static int statx_null_path_supported = 1;
> > > + int r;
> > > + int supported = atomic_load_relaxed (&statx_null_path_supported);
> > > + if (__glibc_likely (supported))
> >
> > This function shouldn't be inline because it defines a static variable.
> > You should move its definition to an appropriate .c file (perhaps a new
> > one) and add an attribute_hidden declaration to
> > sysdeps/unix/sysv/linux/internal-stat.h.
>
> I deliberately make this function inline because there will only be two
> users and it is expected that there will be no more users. So there will
> be limited copies of these code inside the compiled binary. Inlining this
> function help optimization of the two functions using it. The drawback
> will be the two functions will do the try-and-fall-back independently.
> Considering one of the functions, fxstat64, is provided for backward
> compatibility, I believe this drawback is acceptable.
Maybe separate the static variable to a global variable with hidden
visibility? Then there won't be this drawback.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
More information about the Libc-alpha
mailing list