mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Tony Ambardar <tony.ambardar@gmail.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] [PATCH v2] add renameat2 linux syscall wrapper
Date: Mon, 6 May 2024 20:01:35 -0400	[thread overview]
Message-ID: <20240507000135.GF5341@brightrain.aerifal.cx> (raw)
In-Reply-To: <Zjlq0nlT6POMfWb8@kodidev-ubuntu>

On Mon, May 06, 2024 at 04:42:10PM -0700, Tony Ambardar wrote:
> On Mon, May 06, 2024 at 10:50:57AM -0400, Rich Felker wrote:
> > On Tue, Apr 23, 2024 at 04:43:55PM -0700, Tony Ambardar wrote:
> > > This syscall is available since Linux 3.15 and also implemented in glibc
> > > from version 2.28. It is commonly used in filesystem or security contexts.
> > > 
> 
> [SNIP]
> 
> > 
> > If flags is 0, the SYS_renameat syscall is semantically equivalent to
> > the SYS_renameat2 one, so it would be better to just unconditionally
> > do that first rather than failing and falling back.
> > 
> 
> Do you mean rearranging and dropping the ENOSYS conditional, e.g. something
> like below?
> 
> >       int r;
> > #ifdef SYS_renameat
> >       if (!flags) r = __syscall(SYS_renameat, oldfd, old, newfd, new);
> >       else
> > #endif
> >       r = __syscall(SYS_renameat2, oldfd, old, newfd, new, flags);
> >       return __syscall_ret(r);
> 
> Please clarify and I'll update.
> 
> Thanks,
> Tony

Yes, or just (simpler, without any "int r;"):

	if (!flags) return syscall(SYS_renameat, ...);

etc. The use of __syscall and manually calling __syscall_ret is only
helpful if you want to peek/poke at error codes prior to setting errno
and returning.

Rich

  reply	other threads:[~2024-05-07  0:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-21 15:36 [musl] [PATCH v1] " Tony Ambardar
2024-04-22 22:47 ` Rich Felker
2024-04-23  4:39   ` Tony Ambardar
2024-04-23 15:51     ` Rich Felker
2024-04-23 14:49   ` enh
2024-04-23 15:48     ` Rich Felker
2024-04-23 23:43 ` [musl] [PATCH v2] " Tony Ambardar
2024-05-06 14:50   ` Rich Felker
2024-05-06 23:42     ` Tony Ambardar
2024-05-07  0:01       ` Rich Felker [this message]
2024-05-07  3:28   ` [musl] [PATCH v3] " Tony Ambardar

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=20240507000135.GF5341@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=tony.ambardar@gmail.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).