From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [209.51.188.92]) by sourceware.org (Postfix) with ESMTPS id 0BA883858D33 for ; Wed, 1 Feb 2023 19:06:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0BA883858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNIRG-0005sl-Lr; Wed, 01 Feb 2023 14:06:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=506Phch/gs6wZsJ+DCxwH/AKQFrURYaNRmY7sqdGqMM=; b=fsXSBNrCZY070ghtFBNH DHTqCeaCs53mZOBJIRHFckk588zSMNQi+IDHL03S0jL++AiUr26f2tpJxihCW8Iytt1kCbfAt533k ll/jpgt92Ud/bGZDLLI/Uzfu9HRMFz+5Y6jUUJ1FxCUpPHLL7RjWZ07kzahirt+/n0MKEKVG+2JTU XY0H5UQiZt9URJg5g1JANHZoBAwCOcVSI+BZocSzZY/9D6wUkd/RBAj03Xqx9uK0y38fhr4Bs5oPh fZpXqOdTWNi2SY6cPgNJJ01zCp5DHT6CI9poII+94VIThLitegSa9Drtx5K3vL8188ZExfQMFVWyn PCXsgHHmI9NInQ==; Received: from lfbn-bor-1-1163-184.w92-158.abo.wanadoo.fr ([92.158.138.184] helo=begin) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNIRD-0007ZF-2J; Wed, 01 Feb 2023 14:06:33 -0500 Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1pNIRA-00BQM1-1T; Wed, 01 Feb 2023 20:06:28 +0100 Date: Wed, 1 Feb 2023 20:06:28 +0100 From: Samuel Thibault To: Sergey Bugaev Cc: bug-hurd@gnu.org, libc-alpha@sourceware.org Subject: Re: [PATCH v2 1/3] hurd: Consolidate file_name_lookup implementation Message-ID: <20230201190628.t7cezi3jcodxufdw@begin> Mail-Followup-To: Sergey Bugaev , bug-hurd@gnu.org, libc-alpha@sourceware.org References: <20230130095907.mlvp3pbmtarkhhql@begin> <20230130125216.6254-2-bugaevc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230130125216.6254-2-bugaevc@gmail.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Applied, thanks! Sergey Bugaev, le lun. 30 janv. 2023 15:52:14 +0300, a ecrit: > Instead of __file_name_lookup_at delegating to __file_name_lookup > in simple cases, make __file_name_lookup_at deal with both cases, and > have __file_name_lookup simply wrap __file_name_lookup_at. > > Signed-off-by: Sergey Bugaev > --- > hurd/hurdlookup.c | 10 ++-------- > hurd/lookup-at.c | 51 ++++++++++++++++++++++++++++++++--------------- > 2 files changed, 37 insertions(+), 24 deletions(-) > > diff --git a/hurd/hurdlookup.c b/hurd/hurdlookup.c > index 49eac443..3cfe444f 100644 > --- a/hurd/hurdlookup.c > +++ b/hurd/hurdlookup.c > @@ -16,6 +16,7 @@ > . */ > > #include > +#include > #include > #include > #include > @@ -220,14 +221,7 @@ weak_alias (__hurd_directory_name_split, hurd_directory_name_split) > file_t > __file_name_lookup (const char *file_name, int flags, mode_t mode) > { > - error_t err; > - file_t result; > - > - err = __hurd_file_name_lookup (&_hurd_ports_use, &__getdport, 0, > - file_name, flags, mode & ~_hurd_umask, > - &result); > - > - return err ? (__hurd_fail (err), MACH_PORT_NULL) : result; > + return __file_name_lookup_at (AT_FDCWD, 0, file_name, flags, mode); > } > weak_alias (__file_name_lookup, file_name_lookup) > > diff --git a/hurd/lookup-at.c b/hurd/lookup-at.c > index 6f30a067..25dab5a1 100644 > --- a/hurd/lookup-at.c > +++ b/hurd/lookup-at.c > @@ -36,9 +36,6 @@ __file_name_lookup_at (int fd, int at_flags, > if (err) > return (__hurd_fail (err), MACH_PORT_NULL); > > - if (fd == AT_FDCWD || file_name[0] == '/') > - return __file_name_lookup (file_name, flags, mode); > - > if (empty != 0 && file_name[0] == '\0') > { > enum retry_type doretry; > @@ -56,22 +53,44 @@ __file_name_lookup_at (int fd, int at_flags, > return err ? (__hurd_dfail (fd, err), MACH_PORT_NULL) : result; > } > > - file_t startdir; > - error_t use_init_port (int which, error_t (*operate) (mach_port_t)) > + if (fd == AT_FDCWD || file_name[0] == '/') > { > - return (which == INIT_PORT_CWDIR ? (*operate) (startdir) > - : _hurd_ports_use (which, operate)); > + err = __hurd_file_name_lookup (&_hurd_ports_use, &__getdport, 0, > + file_name, flags, mode & ~_hurd_umask, > + &result); > + if (err) > + { > + __hurd_fail (err); > + return MACH_PORT_NULL; > + } > + } > + else > + { > + file_t startdir; > + /* We need to look the file up relative to the given directory (and > + not our cwd). For this to work, we supply our own wrapper for > + _hurd_ports_use, which replaces cwd with our startdir. */ > + error_t use_init_port (int which, error_t (*operate) (mach_port_t)) > + { > + return (which == INIT_PORT_CWDIR ? (*operate) (startdir) > + : _hurd_ports_use (which, operate)); > + } > + > + err = HURD_DPORT_USE (fd, (startdir = port, > + __hurd_file_name_lookup (&use_init_port, > + &__getdport, NULL, > + file_name, > + flags, > + mode & ~_hurd_umask, > + &result))); > + if (err) > + { > + __hurd_dfail (fd, err); > + return MACH_PORT_NULL; > + } > } > > - err = HURD_DPORT_USE (fd, (startdir = port, > - __hurd_file_name_lookup (&use_init_port, > - &__getdport, NULL, > - file_name, > - flags, > - mode & ~_hurd_umask, > - &result))); > - > - return err ? (__hurd_dfail (fd, err), MACH_PORT_NULL) : result; > + return result; > } > > file_t > -- > 2.39.1 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.