From: Robert Millan Date: Wed, 4 Aug 2010 11:29:13 +0000 (+0200) Subject: 2010-08-04 Robert Millan X-Git-Tag: 1.99~682 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0de22aa997fa162d626ed1c4f472bad4915e8e7f;p=thirdparty%2Fgrub.git 2010-08-04 Robert Millan * include/grub/emu/misc.h (grub_find_mount_point_from_dir) (grub_find_zpool_from_mount_point): Merge into ... (grub_find_zpool_from_dir): ... this. * kern/emu/misc.c: Likewise. * kern/emu/misc.c (grub_make_system_path_relative_to_its_root): Replace grub_find_mount_point_from_dir() / grub_find_zpool_from_mount_point() with grub_find_zpool_from_dir(). * kern/emu/getroot.c (find_root_device_from_libzfs): Likewise. --- diff --git a/ChangeLog b/ChangeLog index 958c55c79..daa85e4a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2010-08-04 Robert Millan + + * include/grub/emu/misc.h (grub_find_mount_point_from_dir) + (grub_find_zpool_from_mount_point): Merge into ... + (grub_find_zpool_from_dir): ... this. + * kern/emu/misc.c: Likewise. + + * kern/emu/misc.c + (grub_make_system_path_relative_to_its_root): Replace + grub_find_mount_point_from_dir() / grub_find_zpool_from_mount_point() + with grub_find_zpool_from_dir(). + * kern/emu/getroot.c (find_root_device_from_libzfs): Likewise. + 2010-08-04 Robert Millan Support OpenSolaris in ZFS device resolution. diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index 70cf05e0d..ebb81a37f 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -45,10 +45,8 @@ extern const char *program_name; void grub_init_all (void); void grub_fini_all (void); -char *grub_find_mount_point_from_dir (const char *dir) - __attribute__ ((warn_unused_result)); -void grub_find_zpool_from_mount_point (const char *mnt_point, - char **poolname, char **poolfs); +void grub_find_zpool_from_dir (const char *dir, + char **poolname, char **poolfs); char *grub_make_system_path_relative_to_its_root (const char *path) __attribute__ ((warn_unused_result)); diff --git a/kern/emu/getroot.c b/kern/emu/getroot.c index ee6e1c7ba..321b33bb3 100644 --- a/kern/emu/getroot.c +++ b/kern/emu/getroot.c @@ -181,15 +181,10 @@ find_root_device_from_libzfs (const char *dir) char *device; char *poolname; char *poolfs; - char *mnt_point; - mnt_point = grub_find_mount_point_from_dir (dir); - grub_find_zpool_from_mount_point (mnt_point, &poolname, &poolfs); + grub_find_zpool_from_dir (dir, &poolname, &poolfs); if (! poolname) - { - free (mnt_point); - return NULL; - } + return NULL; { zpool_handle_t *zpool; diff --git a/kern/emu/misc.c b/kern/emu/misc.c index 5a148c708..de22e3bff 100644 --- a/kern/emu/misc.c +++ b/kern/emu/misc.c @@ -277,8 +277,8 @@ grub_get_libzfs_handle (void) #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) /* Not ZFS-specific in itself, but for now it's only used by ZFS-related code. */ -char * -grub_find_mount_point_from_dir (const char *dir) +static char * +find_mount_point_from_dir (const char *dir) { struct stat st; typeof (st.st_dev) fs; @@ -332,18 +332,18 @@ grub_find_mount_point_from_dir (const char *dir) } } } -#endif - -#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) /* ZFS has similar problems to those of btrfs (see above). */ void -grub_find_zpool_from_mount_point (const char *mnt_point, char **poolname, char **poolfs) +grub_find_zpool_from_dir (const char *dir, char **poolname, char **poolfs) { char *slash; + char *mnt_point; *poolname = *poolfs = NULL; + mnt_point = find_mount_point_from_dir (dir); + #if defined(HAVE_GETFSSTAT) /* FreeBSD and GNU/kFreeBSD */ { int mnt_count = getfsstat (NULL, 0, MNT_WAIT); @@ -408,7 +408,7 @@ grub_make_system_path_relative_to_its_root (const char *path) { struct stat st; char *p, *buf, *buf2, *buf3; - char *mnt_point, *poolname = NULL, *poolfs = NULL, *ret; + char *poolname = NULL, *poolfs = NULL, *ret; uintptr_t offset = 0; dev_t num; size_t len; @@ -420,12 +420,7 @@ grub_make_system_path_relative_to_its_root (const char *path) #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) /* For ZFS sub-pool filesystems, could be extended to others (btrfs?). */ - mnt_point = grub_find_mount_point_from_dir (p); - if (mnt_point) - { - grub_find_zpool_from_mount_point (mnt_point, &poolname, &poolfs); - free (mnt_point); - } + grub_find_zpool_from_dir (p, &poolname, &poolfs); #endif len = strlen (p) + 1;