From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 701F4253B6 for ; Tue, 7 May 2024 02:01:31 +0200 (CEST) Received: (qmail 28388 invoked by uid 550); 7 May 2024 00:01:22 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 28336 invoked from network); 7 May 2024 00:01:21 -0000 Date: Mon, 6 May 2024 20:01:35 -0400 From: Rich Felker To: Tony Ambardar Cc: musl@lists.openwall.com Message-ID: <20240507000135.GF5341@brightrain.aerifal.cx> References: <20240421153640.379015-1-Tony.Ambardar@gmail.com> <20240423234355.2414567-1-Tony.Ambardar@gmail.com> <20240506145056.GG10433@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH v2] add renameat2 linux syscall wrapper 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