grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 1/2] Add grub_util_readlink()


From: Daniel Kiper
Subject: Re: [PATCH v3 1/2] Add grub_util_readlink()
Date: Tue, 5 Nov 2019 12:42:25 +0100
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Oct 30, 2019 at 11:48:13AM +0100, Javier Martinez Canillas wrote:
> From: Peter Jones <address@hidden>
>
> Currently grub-editenv and related tools are not able to follow symbolic
> links when finding their config file. For example the grub-editenv create
> command will wrongly overwrite a symlink in /boot/grub2/grubenv with a new
> regular file, instead of creating a file in the path the symlink points to.
>
> A following patch will change that and add support in grub-editenv to
> follow symbolic links when finding the grub environment variables file.
>
> Add a grub_util_readlink() helper function that is just a wrapper around
> the platform specific function to read the value of a symbolic link. This
> helper function will be used by the following patch for grub-editenv.
>
> Signed-off-by: Peter Jones <address@hidden>
> Reviewed-by: Adam Jackson <address@hidden>
> Signed-off-by: Javier Martinez Canillas <address@hidden>
> Reviewed-by: Daniel Kiper <address@hidden>
>
> ---
>
> Changes in v3: None
> Changes in v2:
> - Add a better commit message explaining why the change is needed.
> - Add Reviewed-by tag from Daniel Kiper.
>
>  grub-core/osdep/windows/hostdisk.c    | 6 ++++++
>  include/grub/osdep/hostfile_aros.h    | 6 ++++++
>  include/grub/osdep/hostfile_unix.h    | 6 ++++++
>  include/grub/osdep/hostfile_windows.h | 2 ++
>  4 files changed, 20 insertions(+)
>
> diff --git grub-core/osdep/windows/hostdisk.c 
> grub-core/osdep/windows/hostdisk.c
> index 355100789a7..87a106c9b82 100644
> --- grub-core/osdep/windows/hostdisk.c
> +++ grub-core/osdep/windows/hostdisk.c
> @@ -365,6 +365,12 @@ grub_util_mkdir (const char *dir)
>    free (windows_name);
>  }
>
> +ssize_t
> +grub_util_readlink (const char *name, char *buf, size_t bufsize)
> +{
> +  return readlink(name, buf, bufsize);
> +}
> +
>  int
>  grub_util_rename (const char *from, const char *to)
>  {

This change breaks Windows build. I think that you should drop it and
do some #ifdefery in patch #2. I mean I would leave existing code for
Windows only and add new code for POSIX compliant systems.

> diff --git include/grub/osdep/hostfile_aros.h 
> include/grub/osdep/hostfile_aros.h
> index a059c0fa40a..161fbb7bdfd 100644
> --- include/grub/osdep/hostfile_aros.h
> +++ include/grub/osdep/hostfile_aros.h
> @@ -68,6 +68,12 @@ grub_util_rename (const char *from, const char *to)
>    return rename (from, to);
>  }
>
> +static inline ssize_t
> +grub_util_readlink (const char *name, char *buf, size_t bufsize)
> +{
> +  return readlink(name, buf, bufsize);
> +}
> +
>  #define grub_util_mkdir(a) mkdir ((a), 0755)
>
>  struct grub_util_fd
> diff --git include/grub/osdep/hostfile_unix.h 
> include/grub/osdep/hostfile_unix.h
> index 9ffe46fa3ca..17cd3aa8b30 100644
> --- include/grub/osdep/hostfile_unix.h
> +++ include/grub/osdep/hostfile_unix.h
> @@ -71,6 +71,12 @@ grub_util_rename (const char *from, const char *to)
>    return rename (from, to);
>  }
>
> +static inline ssize_t
> +grub_util_readlink (const char *name, char *buf, size_t bufsize)
> +{
> +  return readlink(name, buf, bufsize);
> +}
> +
>  #define grub_util_mkdir(a) mkdir ((a), 0755)
>
>  #if defined (__NetBSD__)
> diff --git include/grub/osdep/hostfile_windows.h 
> include/grub/osdep/hostfile_windows.h
> index bf6451b6db4..8c92d0591bb 100644
> --- include/grub/osdep/hostfile_windows.h
> +++ include/grub/osdep/hostfile_windows.h
> @@ -41,6 +41,8 @@ typedef struct grub_util_fd_dir *grub_util_fd_dir_t;
>
>  int
>  grub_util_rename (const char *from, const char *to);
> +ssize_t
> +grub_util_readlink (const char *name, char *buf, size_t bufsize);
>  int
>  grub_util_unlink (const char *name);
>  void

This change is also probably not needed then...

Daniel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]