mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH v2] pass AT_NO_AUTOMOUNT when emulating fstatat via statx
Date: Sat, 7 Oct 2023 17:09:27 -0400	[thread overview]
Message-ID: <20231007210927.GJ4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <20231007180218.231638-1-izbyshev@ispras.ru>

On Sat, Oct 07, 2023 at 09:02:18PM +0300, Alexey Izbyshev wrote:
> AT_NO_AUTOMOUNT is implied for stat/lstat/fstatat syscalls since Linux
> 3.1 [1]. However, this is not the case for statx syscall, which defaults
> to automounting, so this flag must be passed explicitly when statx is
> used to implement stat-like functions.
> 
> This change affects only arches which use 32-bit seconds in struct kstat,
> as well as out-of-tree/future ports to arches which lack SYS_fstatat.
> 
> [1] https://git.kernel.org/torvalds/c/b6c8069d3577481390b3f24a8434ad72a3235594
> ---
> Fixed the wrong statement about affected arches in the commit message.

Indeed, statx is always used on 32-bit archs. 32-bit archs with no
legacy 32-bit kernel timespec struct (i.e. rv32) don't have the legacy
stat syscalls either.

> ---
>  src/stat/fstatat.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/stat/fstatat.c b/src/stat/fstatat.c
> index 04506375d897..9eed063b26bc 100644
> --- a/src/stat/fstatat.c
> +++ b/src/stat/fstatat.c
> @@ -36,6 +36,7 @@ static int fstatat_statx(int fd, const char *restrict path, struct stat *restric
>  {
>  	struct statx stx;
>  
> +	flag |= AT_NO_AUTOMOUNT;
>  	int ret = __syscall(SYS_statx, fd, path, flag, 0x7ff, &stx);
>  	if (ret) return ret;
>  
> -- 
> 2.39.2

I think this is ok. I recall noticing something about this when
initially adding it but not being sure what behavior the legacy stat
syscall would give or whether it's "right". But short of a very good
reason to differ from the kernel default (which would then require
changing other archs to match), I think we just need to make it
consistent with what happens on other archs.

Rich

      reply	other threads:[~2023-10-07 21:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-07 18:02 Alexey Izbyshev
2023-10-07 21:09 ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231007210927.GJ4163@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).