From c91e1793bff00a7aff881627c7fa15ce0e5a1b47 Mon Sep 17 00:00:00 2001 From: fzielcke Date: Sat, 11 Apr 2009 18:46:12 +0000 Subject: [PATCH] 2009-04-11 Felix Zielcke * util/hostdisk.c [__FreeBSD_kernel__]: Include sys/disk.h. (grub_util_biosdisk_open) [__FreeBSD_kernel__]: Add support for GNU/kFreeBSD. Check if a device is a character device. Use DIOCGMEDIASIZE to get the size. (convert_system_partition_to_system_disk) [__FreeBSD_kernel__]: Add support for GNU/kFreeBSD. (grub_util_biosdisk_get_grub_dev) [__FreeBSD_kernel__]: Check if OS_DEV is a character device instead of a block device. Add support for FreeBSD device names. * util/getroot.c (find_root_device) [__FreeBSD_kernel__]: Check if ENT is a character device instead of a block device. * util/grub-probe.c (probe) [__FreeBSD_kernel__]: Check if DEVICE_NAME is a character device instead of a block device. --- ChangeLog | 18 ++++++++++++++++++ util/getroot.c | 2 +- util/grub-probe.c | 2 +- util/hostdisk.c | 14 +++++++------- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6dd046f89..384e2b0e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2009-04-11 Felix Zielcke + + * util/hostdisk.c [__FreeBSD_kernel__]: Include sys/disk.h. + (grub_util_biosdisk_open) [__FreeBSD_kernel__]: Add support for + GNU/kFreeBSD. Check if a device is a character device. Use + DIOCGMEDIASIZE to get the size. + (convert_system_partition_to_system_disk) [__FreeBSD_kernel__]: Add + support for GNU/kFreeBSD. + (grub_util_biosdisk_get_grub_dev) [__FreeBSD_kernel__]: Check if OS_DEV + is a character device instead of a block device. Add support for + FreeBSD device names. + + * util/getroot.c (find_root_device) [__FreeBSD_kernel__]: Check if ENT + is a character device instead of a block device. + + * util/grub-probe.c (probe) [__FreeBSD_kernel__]: Check if DEVICE_NAME + is a character device instead of a block device. + 2009-04-11 Andrey Shuvikov * util/hostdisk.c [__FreeBSD__]: Include sys/disk.h. diff --git a/util/getroot.c b/util/getroot.c index daed9124a..68e1fad58 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -238,7 +238,7 @@ find_root_device (const char *dir, dev_t dev) } } -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) if (S_ISCHR (st.st_mode) && st.st_rdev == dev) #else if (S_ISBLK (st.st_mode) && st.st_rdev == dev) diff --git a/util/grub-probe.c b/util/grub-probe.c index 194c62bb7..bdb915964 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -112,7 +112,7 @@ probe (const char *path, char *device_name) if (path == NULL) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) if (! grub_util_check_char_device (device_name)) grub_util_error ("%s is not a character device.\n", device_name); #else diff --git a/util/hostdisk.c b/util/hostdisk.c index 001777e8e..2ef205786 100644 --- a/util/hostdisk.c +++ b/util/hostdisk.c @@ -86,7 +86,7 @@ struct hd_geometry # define FLOPPY_MAJOR 2 #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # include /* DIOCGMEDIASIZE */ #endif @@ -183,7 +183,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) return GRUB_ERR_NONE; } -#elif defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD__) +#elif defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) { unsigned long long nr; int fd; @@ -192,7 +192,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) if (fd == -1) return grub_error (GRUB_ERR_BAD_DEVICE, "cannot open `%s' while attempting to get disk size", map[drive].device); -# if defined(__FreeBSD__) +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode)) # else if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode)) @@ -202,7 +202,7 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) goto fail; } -# if defined(__FreeBSD__) +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) if (ioctl (fd, DIOCGMEDIASIZE, &nr)) # else if (ioctl (fd, BLKGETSIZE64, &nr)) @@ -758,7 +758,7 @@ convert_system_partition_to_system_disk (const char *os_dev) path[8] = 0; return path; -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) char *path = xstrdup (os_dev); if (strncmp ("/dev/", path, 5) == 0) { @@ -821,7 +821,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) return 0; } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) if (! S_ISCHR (st.st_mode)) #else if (! S_ISBLK (st.st_mode)) @@ -970,7 +970,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) return make_device_name (drive, dos_part, bsd_part); } -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) /* FreeBSD uses "/dev/[a-z]+[0-9]+(s[0-9]+[a-z]?)?". */ { int dos_part = -1;