public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@gnu.org>
To: Sergey Bugaev <bugaevc@gmail.com>
Cc: bug-hurd@gnu.org, libc-alpha@sourceware.org
Subject: Re: [PATCH v2 1/3] hurd: Consolidate file_name_lookup implementation
Date: Wed, 1 Feb 2023 20:06:28 +0100	[thread overview]
Message-ID: <20230201190628.t7cezi3jcodxufdw@begin> (raw)
In-Reply-To: <20230130125216.6254-2-bugaevc@gmail.com>

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 <bugaevc@gmail.com>
> ---
>  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 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <hurd.h>
> +#include <hurd/fd.h>
>  #include <hurd/lookup.h>
>  #include <string.h>
>  #include <fcntl.h>
> @@ -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.

  reply	other threads:[~2023-02-01 19:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12 11:46 [RFC PATCH 0/3] O_TMPFILE and SHM_ANON for the Hurd Sergey Bugaev
2022-12-12 11:46 ` [RFC PATCH 1/3] hurd: Consolidate file_name_lookup implementation Sergey Bugaev
2022-12-12 11:46 ` [RFC PATCH 2/3] hurd: Implement O_TMPFILE Sergey Bugaev
2023-01-29 23:25   ` Samuel Thibault
2023-01-30  9:53     ` Sergey Bugaev
2023-01-30  9:59       ` Samuel Thibault
2023-01-30 12:52         ` [PATCH v2 0/3] O_TMPFILE and SHM_ANON for the Hurd Sergey Bugaev
2023-01-30 12:52         ` [PATCH v2 1/3] hurd: Consolidate file_name_lookup implementation Sergey Bugaev
2023-02-01 19:06           ` Samuel Thibault [this message]
2023-01-30 12:52         ` [PATCH v2 2/3] hurd: Implement O_TMPFILE Sergey Bugaev
2023-02-01 22:34           ` Samuel Thibault
2023-01-30 12:52         ` [PATCH v2 3/3] hurd: Implement SHM_ANON Sergey Bugaev
2023-02-01 22:36           ` Samuel Thibault
2022-12-12 11:46 ` [RFC PATCH " Sergey Bugaev
2023-01-29 23:31 ` [RFC PATCH 0/3] O_TMPFILE and SHM_ANON for the Hurd Samuel Thibault

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=20230201190628.t7cezi3jcodxufdw@begin \
    --to=samuel.thibault@gnu.org \
    --cc=bug-hurd@gnu.org \
    --cc=bugaevc@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).