2010-08-04 Robert Millan <rmh@gnu.org>

* 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.
This commit is contained in:
Robert Millan 2010-08-04 13:29:13 +02:00
parent 62858144fe
commit 0de22aa997
4 changed files with 25 additions and 24 deletions

View file

@ -1,3 +1,16 @@
2010-08-04 Robert Millan <rmh@gnu.org>
* 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 <rmh@gnu.org> 2010-08-04 Robert Millan <rmh@gnu.org>
Support OpenSolaris in ZFS device resolution. Support OpenSolaris in ZFS device resolution.

View file

@ -45,10 +45,8 @@ extern const char *program_name;
void grub_init_all (void); void grub_init_all (void);
void grub_fini_all (void); void grub_fini_all (void);
char *grub_find_mount_point_from_dir (const char *dir) void grub_find_zpool_from_dir (const char *dir,
__attribute__ ((warn_unused_result)); char **poolname, char **poolfs);
void grub_find_zpool_from_mount_point (const char *mnt_point,
char **poolname, char **poolfs);
char *grub_make_system_path_relative_to_its_root (const char *path) char *grub_make_system_path_relative_to_its_root (const char *path)
__attribute__ ((warn_unused_result)); __attribute__ ((warn_unused_result));

View file

@ -181,15 +181,10 @@ find_root_device_from_libzfs (const char *dir)
char *device; char *device;
char *poolname; char *poolname;
char *poolfs; char *poolfs;
char *mnt_point;
mnt_point = grub_find_mount_point_from_dir (dir); grub_find_zpool_from_dir (dir, &poolname, &poolfs);
grub_find_zpool_from_mount_point (mnt_point, &poolname, &poolfs);
if (! poolname) if (! poolname)
{ return NULL;
free (mnt_point);
return NULL;
}
{ {
zpool_handle_t *zpool; zpool_handle_t *zpool;

View file

@ -277,8 +277,8 @@ grub_get_libzfs_handle (void)
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
/* Not ZFS-specific in itself, but for now it's only used by ZFS-related code. */ /* Not ZFS-specific in itself, but for now it's only used by ZFS-related code. */
char * static char *
grub_find_mount_point_from_dir (const char *dir) find_mount_point_from_dir (const char *dir)
{ {
struct stat st; struct stat st;
typeof (st.st_dev) fs; 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). */ /* ZFS has similar problems to those of btrfs (see above). */
void 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 *slash;
char *mnt_point;
*poolname = *poolfs = NULL; *poolname = *poolfs = NULL;
mnt_point = find_mount_point_from_dir (dir);
#if defined(HAVE_GETFSSTAT) /* FreeBSD and GNU/kFreeBSD */ #if defined(HAVE_GETFSSTAT) /* FreeBSD and GNU/kFreeBSD */
{ {
int mnt_count = getfsstat (NULL, 0, MNT_WAIT); 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; struct stat st;
char *p, *buf, *buf2, *buf3; char *p, *buf, *buf2, *buf3;
char *mnt_point, *poolname = NULL, *poolfs = NULL, *ret; char *poolname = NULL, *poolfs = NULL, *ret;
uintptr_t offset = 0; uintptr_t offset = 0;
dev_t num; dev_t num;
size_t len; 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) #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
/* For ZFS sub-pool filesystems, could be extended to others (btrfs?). */ /* For ZFS sub-pool filesystems, could be extended to others (btrfs?). */
mnt_point = grub_find_mount_point_from_dir (p); grub_find_zpool_from_dir (p, &poolname, &poolfs);
if (mnt_point)
{
grub_find_zpool_from_mount_point (mnt_point, &poolname, &poolfs);
free (mnt_point);
}
#endif #endif
len = strlen (p) + 1; len = strlen (p) + 1;