grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Add grub_util_readlink()
@ 2019-10-18 12:42 Javier Martinez Canillas
  2019-10-18 12:42 ` [PATCH 2/2] Make editenv chase symlinks including those across devices Javier Martinez Canillas
  2019-10-23  9:19 ` [PATCH 1/2] Add grub_util_readlink() Daniel Kiper
  0 siblings, 2 replies; 7+ messages in thread
From: Javier Martinez Canillas @ 2019-10-18 12:42 UTC (permalink / raw)
  To: grub-devel; +Cc: Peter Jones, Adam Jackson, Javier Martinez Canillas

From: Peter Jones <pjones@redhat.com>

Add a grub_util_readlink() helper function.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

 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 a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c
index 355100789a7..87a106c9b82 100644
--- a/grub-core/osdep/windows/hostdisk.c
+++ b/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)
 {
diff --git a/include/grub/osdep/hostfile_aros.h b/include/grub/osdep/hostfile_aros.h
index a059c0fa40a..161fbb7bdfd 100644
--- a/include/grub/osdep/hostfile_aros.h
+++ b/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 a/include/grub/osdep/hostfile_unix.h b/include/grub/osdep/hostfile_unix.h
index 9ffe46fa3ca..17cd3aa8b30 100644
--- a/include/grub/osdep/hostfile_unix.h
+++ b/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 a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h
index bf6451b6db4..8c92d0591bb 100644
--- a/include/grub/osdep/hostfile_windows.h
+++ b/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
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH 0/2] Allow editenv to follow symlinks to find/make grubenv
@ 2014-09-04 15:36 Peter Jones
  2014-09-04 15:36 ` [PATCH 1/2] Add grub_util_readlink() Peter Jones
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Jones @ 2014-09-04 15:36 UTC (permalink / raw)
  To: grub-devel

Hi,
This is a patch series to allow grub-editenv and related utilities to
follow symbolic links when finding its config file.  This allows, for
example, the ability to have two builds of grub for different platforms
that have different prefixes set, but still use the same userland grub
utilities.

For example, in our EFI builds we'll typically have prefix set as
/EFI/fedora (on the EFI System Partition), but when you install on a BIOS
machine it'll be /boot/grub2 (which may or may not be its own mountpoint.)

With this patch, on EFI machines we can make /boot/grub2/grubenv a symlink
to /boot/efi/EFI/fedora/grubenv , and the same copy of grub-set-default will
work on both kinds of systems.

Note: I'm not entirely sure I've done the gnulib parts of the first patch
the preferred way, but they do appear to be functional.  I wound up using
"gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname readlink regex"
and then only adding in the parts directly related to readlink().



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-10-28 13:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-18 12:42 [PATCH 1/2] Add grub_util_readlink() Javier Martinez Canillas
2019-10-18 12:42 ` [PATCH 2/2] Make editenv chase symlinks including those across devices Javier Martinez Canillas
2019-10-23  9:42   ` Daniel Kiper
2019-10-28 13:09     ` Javier Martinez Canillas
2019-10-23  9:19 ` [PATCH 1/2] Add grub_util_readlink() Daniel Kiper
2019-10-28 13:04   ` Javier Martinez Canillas
  -- strict thread matches above, loose matches on Subject: below --
2014-09-04 15:36 [PATCH 0/2] Allow editenv to follow symlinks to find/make grubenv Peter Jones
2014-09-04 15:36 ` [PATCH 1/2] Add grub_util_readlink() Peter Jones

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 NNTP newsgroup(s).