Hello, OKUJI!
> If my understanding is correct, /dev/wd* and /dev/da* are block
> devices, so should GRUB access /dev/rwd* and /dev/rda* instead? In
libdisk uses /dev/rwd* and /dev/rda*
Perhaps it's better.
> addition, *BSD have an interface to get the geometry of a drive
> (DIOCG* ?), so I would be happy if you add the code.
Thanks for the tip. The subject is still correct :-)
ChangeLog:
* grub/asmstub.c: FreeBSD support added for device names and
geometry detection.
[__linux__]: On GLibc 2.0 and newer use lseek, don't include
<linux/fs.h> and define BLKFLSBUF if needed.
Please add doc/version.texi to CVS. Otherwise "./configure && make"
fails.
Pavel Roskin
Index: grub/asmstub.c
===================================================================
RCS file: /usr/home/proski/cvs/grub/grub/asmstub.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 asmstub.c
--- grub/asmstub.c 1999/09/13 16:20:59 1.1.1.1
+++ grub/asmstub.c 1999/09/13 19:39:11
@@ -52,6 +52,10 @@
# include <linux/fs.h> /* BLKFLSBUF */
#endif /* __linux__ */
+#ifdef __FreeBSD__
+# include <sys/disklabel.h>
+#endif /* __FreeBSD__ */
+
/* Simulated memory sizes. */
#define EXTENDED_MEMSIZE (4 * 1024 * 1024) /* 4MB */
#define CONVENTIONAL_MEMSIZE (640) /* 640kB */
@@ -261,6 +265,9 @@
#if defined(__linux__) || defined(__GNU__)
/* GNU/Linux and GNU/Hurd */
sprintf (name, "/dev/fd%d", unit);
+#elif defined(__FreeBSD__)
+ /* FreeBSD */
+ sprintf (name, "/dev/rfd%d", unit);
#else
# warning "BIOS drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */
@@ -277,6 +284,9 @@
#elif defined(__GNU__)
/* GNU/Hurd */
sprintf (name, "/dev/hd%d", unit);
+#elif defined(__FreeBSD__)
+ /* FreeBSD */
+ sprintf (name, "/dev/rwd%d", unit);
#else
# warning "BIOS drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */
@@ -293,6 +303,9 @@
#elif defined(__GNU__)
/* GNU/Hurd */
sprintf (name, "/dev/sd%d", unit);
+#elif defined(__FreeBSD__)
+ /* FreeBSD */
+ sprintf (name, "/dev/rda%d", unit);
#else
# warning "BIOS drives cannot be guessed in your operating system."
/* Set NAME to a bogus string. */
@@ -685,9 +698,19 @@
* hdg.sectors);
}
else
+#elif defined (__FreeBSD__)
+ struct disklabel hdg;
+ if (! ioctl (disks[drive].flags, DIOCGDINFO, &hdg))
+ {
+ disks[drive].cylinders = hdg.d_ncylinders;
+ disks[drive].heads = hdg.d_ntracks;
+ disks[drive].sectors = hdg.d_nsectors;
+ disks[drive].total_sectors = hdg.d_secperunit;
+ }
+ else
+#else
/* FIXME: should have some other alternatives before using
arbitrary defaults. */
-#else
# warning "In your operating system, automatic detection of geometries \
will not be performed."
#endif
Index: grub/asmstub.c
===================================================================
RCS file: /var/cvs/grub/grub/asmstub.c,v
retrieving revision 1.2
diff -u -r1.2 asmstub.c
--- grub/asmstub.c 1999/09/13 19:57:53 1.2
+++ grub/asmstub.c 1999/09/13 20:18:29
@@ -47,9 +47,14 @@
#ifdef __linux__
# include <sys/ioctl.h> /* ioctl */
# include <linux/hdreg.h> /* HDIO_GETGEO */
-/* FIXME: only include if libc doesn't have large file support. */
-# include <linux/unistd.h> /* _llseek */
-# include <linux/fs.h> /* BLKFLSBUF */
+# if !(__GLIBC__ >= 2)
+/* Maybe libc doesn't have large file support. */
+# include <linux/unistd.h> /* _llseek */
+# include <linux/fs.h> /* BLKFLSBUF */
+# endif /* __GLIBC__ */
+# ifndef BLKFLSBUF
+# define BLKFLSBUF _IO(0x12,97)
+# endif /* BLKFLSBUF */
#endif /* __linux__ */
#ifdef __FreeBSD__
@@ -858,8 +863,8 @@
return BIOSDISK_ERROR_GEOMETRY;
/* Seek to the specified location. */
-#ifdef __linux__
- /* FIXME: only use this section if libc doesn't have large file support */
+#if defined(__linux__) && !(__GLIBC__ >= 2)
+ /* Maybe libc doesn't have large file support */
{
loff_t offset, result;
static int _llseek (uint fd, ulong hi, ulong lo, loff_t *res, uint wh);