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=-2.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,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 2B16B228FB for ; Tue, 23 Apr 2024 16:50:17 +0200 (CEST) Received: (qmail 15993 invoked by uid 550); 23 Apr 2024 14:50:13 -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 15958 invoked from network); 23 Apr 2024 14:50:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713883804; x=1714488604; darn=lists.openwall.com; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mBPaAMcek17cKF9wfLEyeruxcV+NyWft6Ayuty9dGKQ=; b=bRJrxj4m/PhXqUPSisBApweIJ166MN/1FWKEfBo8bgA8XB3eACKJemKQ2nYKpcWswD xQk5rfDaY+rLUuWA1aBbkUuqnpm577n2znOJisw80g8Pbh53VxdhTBBz9yFmf5V8dEuf odQn4PUkSG+2VlW4n0afaD5mSxlYbqeb6Ork9o4FJO1GQ6GVm0ollhqrTzfles8BejDa XzafYNvV988G0owwERjCWW5Ka+ZOtVihuW6msUxhWyMrJFakR/k5vqf0JlHgdjO/T1c5 IFa+CYjIvPd4avRR4caT5Czxd7M49AkpscLMlg3lBjL8QxiXhL9vzUeYrK7wlAbJKurS NJFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713883804; x=1714488604; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mBPaAMcek17cKF9wfLEyeruxcV+NyWft6Ayuty9dGKQ=; b=sSqxnnAur239OKIOzyF6Yl1aR1/LdYFAlwltn8DYlLf4cuxqONMwG5g+V1hCn9waiX sacZ7I+bNw+1zvYyLiC7blTl8SjlZqqV7XpPtuXVLhdWkHvHvHhQqCpzCBa/Lv2rB/df 9gElERz+vT2wDvsO9akLR2rS4DcNOE/KSfa8RrCFcL1XRCXV1doWOkahARY83MEBivZa P/MWxkFBKEMA0bQTMcQXGJdNrghSq1JKkDapovaVOpwXoplQ7Qjip4fqXMSR6hsvqoZh ZCPRDholuOrzZXOENjPRDMYy1pzSZkjcGKXdxDqy14OCGRCeeP02BOqoqyqvz7N4by/q Gbtw== X-Gm-Message-State: AOJu0YxoM52HW3n0XjMbWBcKMBAB1Vr+vKzFl5Rr5ntuqR1H23i2F/b1 mo002PIVH5Imj/JEqUpbLoAAIYzmacD4VrQbGz5zMsvpvmuwQNVpEe9b+Jhq1V46GQkCPd3X6O6 ceX+yERTwd8pFIvComWxg6LzyTgJxCEiee6ahl5bfUxZJc+QXTJ/4 X-Google-Smtp-Source: AGHT+IF3GLM+Yy3PncWpQYiW23nOi2AX8na7vddColAI7dGf1sGOy1aPH5DClurYKDqUVZ95YnZg1FT5+hKzKMN4RCo= X-Received: by 2002:a0c:fa49:0:b0:6a0:6167:9eab with SMTP id k9-20020a0cfa49000000b006a061679eabmr14091197qvo.16.1713883803478; Tue, 23 Apr 2024 07:50:03 -0700 (PDT) MIME-Version: 1.0 References: <20240421153640.379015-1-Tony.Ambardar@gmail.com> <20240422224726.GL4163@brightrain.aerifal.cx> In-Reply-To: <20240422224726.GL4163@brightrain.aerifal.cx> From: enh Date: Tue, 23 Apr 2024 07:49:47 -0700 Message-ID: To: musl@lists.openwall.com Cc: Tony Ambardar Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [musl] [PATCH v1] add renameat2 linux syscall wrapper fwiw, i wrote out the constants with shifts in bionic because that's what the uapi headers do ( iirc), and the preprocessor won't get upset if someone includes both this way. On Mon, Apr 22, 2024 at 3:47=E2=80=AFPM Rich Felker wrote= : > > On Sun, Apr 21, 2024 at 08:36:40AM -0700, Tony Ambardar wrote: > > This syscall is available since Linux 3.15 and also implemented in glib= c > > from version 2.28. It is commonly used in filesystem or security contex= ts. > > > > Defines RENAME_NOREPLACE, RENAME_EXCHANGE, RENAME_WHITEOUT are guarded = by > > _GNU_SOURCE as with glibc. > > > > Signed-off-by: Tony Ambardar > > --- > > include/stdio.h | 7 +++++++ > > src/linux/renameat2.c | 8 ++++++++ > > 2 files changed, 15 insertions(+) > > create mode 100644 src/linux/renameat2.c > > > > diff --git a/include/stdio.h b/include/stdio.h > > index cb858618..8312c3bf 100644 > > --- a/include/stdio.h > > +++ b/include/stdio.h > > @@ -158,6 +158,13 @@ char *ctermid(char *); > > #define L_ctermid 20 > > #endif > > > > +#if defined(_GNU_SOURCE) > > +#define RENAME_NOREPLACE (1 << 0) > > +#define RENAME_EXCHANGE (1 << 1) > > +#define RENAME_WHITEOUT (1 << 2) > > + > > +int renameat2(int, const char *, int, const char *, unsigned int); > > +#endif > > s/unsigned int/unsigned/ and maybe just write out the constants? I > think that's the style musl uses most places. > > > #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ > > || defined(_BSD_SOURCE) > > diff --git a/src/linux/renameat2.c b/src/linux/renameat2.c > > new file mode 100644 > > index 00000000..3062aa15 > > --- /dev/null > > +++ b/src/linux/renameat2.c > > @@ -0,0 +1,8 @@ > > +#define _GNU_SOURCE > > +#include > > +#include "syscall.h" > > + > > +int renameat2(int oldfd, const char *old, int newfd, const char *new, = unsigned int flags) > > +{ > > + return syscall(SYS_renameat2, oldfd, old, newfd, new, flags); > > +} > > -- > > 2.34.1 > > This probably at least needs to support flags=3D=3D0 on kernels without > SYS_renameat2 by calling renameat in that case. Then I'm not sure if > ENOSYS should be kept if the new syscall is missing, or just EINVAL or > whatever is used to report unsupported flags. > > Rich