From 62eafe888b057d94db502614b8bcc6cb29124eb9 Mon Sep 17 00:00:00 2001 From: okuji Date: Sat, 30 Sep 2000 17:56:29 +0000 Subject: [PATCH] call fstat to get a geometry on Hurd, don't include linux/cdrom.h any longer. --- ChangeLog | 12 ++++++++++++ docs/grub.8 | 2 +- docs/mbchk.1 | 2 +- lib/device.c | 38 ++++++++++++++++++++++++++++++++++++-- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 050cdb8d2..831740aac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2000-10-01 OKUJI Yoshinori + + * lib/device.c [__linux__]: Don't include . + [__linux__ && !CDROM_GET_CAPABILITY] (CDROM_GET_CAPABILITY): + Defined as 0x5331. + +2000-10-01 OKUJI Yoshinori + + * lib/device.c (get_drive_geometry) [__GNU__]: Get the number of + total sectors by fstat. The rest are filled with arbitrary + values. + 2000-09-30 OKUJI Yoshinori * util/grub-install.in (convert): The code for gnu* (i.e. diff --git a/docs/grub.8 b/docs/grub.8 index d3adbe027..bf9ae05c2 100644 --- a/docs/grub.8 +++ b/docs/grub.8 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.020. -.TH GRUB "8" "September 2000" "grub (GNU GRUB 0.5.96)" FSF +.TH GRUB "8" "October 2000" "grub (GNU GRUB 0.5.96)" FSF .SH NAME grub \- the grub shell .SH SYNOPSIS diff --git a/docs/mbchk.1 b/docs/mbchk.1 index 9e7867429..70433a425 100644 --- a/docs/mbchk.1 +++ b/docs/mbchk.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.020. -.TH MBCHK "1" "September 2000" "mbchk (GNU GRUB 0.5.96)" FSF +.TH MBCHK "1" "October 2000" "mbchk (GNU GRUB 0.5.96)" FSF .SH NAME mbchk \- check the format of a Multiboot kernel .SH SYNOPSIS diff --git a/lib/device.c b/lib/device.c index f35b1f926..77750c957 100644 --- a/lib/device.c +++ b/lib/device.c @@ -44,7 +44,9 @@ # include /* HDIO_GETGEO */ # include /* FLOPPY_MAJOR */ # include /* MAJOR */ -# include /* CDROM_GET_CAPABILITY */ +# ifndef CDROM_GET_CAPABILITY +# define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */ +# endif /* ! CDROM_GET_CAPABILITY */ # ifndef BLKGETSIZE # define BLKGETSIZE _IO(0x12,96) /* return device size */ # endif /* ! BLKGETSIZE */ @@ -94,7 +96,39 @@ get_drive_geometry (struct geometry *geom, char **map, int drive) close (fd); return; } - + +#elif defined(__GNU__) +# warning "Automatic detection of geometries will be performed only \ +partially. This is not fatal." + /* Hurd */ + { + /* For now, Hurd doesn't support the system call to get a geometry + from Mach, so get only the number of total sectors. */ + struct stat st; + + if (fstat (fd, &st) || ! st.st_blocks) + goto fail; + + geom->total_sectors = st.st_blocks; + + /* Set the rest arbitrarily. */ + if (drive & 0x80) + { + geom->cylinders = DEFAULT_HD_CYLINDERS; + geom->heads = DEFAULT_HD_HEADS; + geom->sectors = DEFAULT_HD_SECTORS; + } + else + { + geom->cylinders = DEFAULT_FD_CYLINDERS; + geom->heads = DEFAULT_FD_HEADS; + geom->sectors = DEFAULT_FD_SECTORS; + } + + close (fd); + return; + } + #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) /* FreeBSD, NetBSD or OpenBSD */ {