Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NBr3H-0006sW-Sj for mharc-grub-devel@gnu.org; Sat, 21 Nov 2009 09:35:03 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NBr3E-0006pW-Px for grub-devel@gnu.org; Sat, 21 Nov 2009 09:35:01 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NBr38-0006kw-EV for grub-devel@gnu.org; Sat, 21 Nov 2009 09:34:59 -0500 Received: from [199.232.76.173] (port=57343 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBr37-0006kN-1G for grub-devel@gnu.org; Sat, 21 Nov 2009 09:34:53 -0500 Received: from toccata.ens-lyon.fr ([140.77.166.68]:44842 helo=toccata.ens-lyon.org) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NBr36-0007Rc-F9 for grub-devel@gnu.org; Sat, 21 Nov 2009 09:34:52 -0500 Received: from localhost (localhost [127.0.0.1]) by toccata.ens-lyon.org (Postfix) with ESMTP id 31BA784093 for ; Sat, 21 Nov 2009 15:34:49 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at toccata.ens-lyon.org Received: from toccata.ens-lyon.org ([127.0.0.1]) by localhost (toccata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1v4e5aKPhhpV for ; Sat, 21 Nov 2009 15:34:49 +0100 (CET) Received: from const.ipv6 (nocat-out.u-bordeaux.fr [147.210.179.68]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by toccata.ens-lyon.org (Postfix) with ESMTPSA id 06D678408C for ; Sat, 21 Nov 2009 15:34:49 +0100 (CET) Received: from samy by const.ipv6 with local (Exim 4.69) (envelope-from ) id 1NBr32-0001lL-1q for grub-devel@gnu.org; Sat, 21 Nov 2009 15:34:48 +0100 Date: Sat, 21 Nov 2009 15:34:48 +0100 From: Samuel Thibault To: grub-devel@gnu.org Message-ID: <20091121143448.GK4471@const.u-bordeaux.fr> References: <20091102023334.GD4557@const.famille.thibault.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20091102023334.GD4557@const.famille.thibault.fr> User-Agent: Mutt/1.5.12-2006-07-14 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) Subject: [PATCH,HURD] Make grub-probe work on GNU/Hurd X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2009 14:35:01 -0000 Hello, After discussions between Hurd developers, here is a patch to implement grub_guess_root_device() natively by directly asking the fs translator. This is the last bit needed to get grub-install working. Samuel 2009-11-21 Samuel Thibault * util/getroot.c: [__GNU__] Include , , and (grub_guess_root_device): [__GNU__] Call file_name_lookup and file_get_storage_info to implement grub_guess_root_device. Index: util/getroot.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- util/getroot.c (r=E9vision 2694) +++ util/getroot.c (copie de travail) @@ -30,6 +30,12 @@ # define DEV_CYGDRIVE_MAJOR 98 #endif =20 +#ifdef __GNU__ +#include +#include +#include +#endif + #include #include #include @@ -378,9 +384,66 @@ char * grub_guess_root_device (const char *dir) { - struct stat st; char *os_dev; +#ifdef __GNU__ + file_t file; + mach_port_t *ports; + int *ints; + loff_t *offsets; + char *data; + error_t err; + mach_msg_type_number_t num_ports =3D 0, num_ints =3D 0, num_offsets =3D= 0, data_len =3D 0; + size_t name_len; =20 + file =3D file_name_lookup (dir, 0, 0); + if (file =3D=3D MACH_PORT_NULL) + return 0; + + err =3D file_get_storage_info (file, + &ports, &num_ports, + &ints, &num_ints, + &offsets, &num_offsets, + &data, &data_len); + + if (num_ints < 1) + grub_util_error ("Storage info for `%s' does not include type", dir)= ; + if (ints[0] !=3D STORAGE_DEVICE) + grub_util_error ("Filesystem of `%s' is not stored on local disk", d= ir); + + if (num_ints < 5) + grub_util_error ("Storage info for `%s' does not include name", dir)= ; + name_len =3D ints[4]; + if (name_len < data_len) + grub_util_error ("Bogus name length for storage info for `%s'", dir)= ; + if (data[name_len - 1] !=3D '\0') + grub_util_error ("Storage name for `%s' not NUL-terminated", dir); + + os_dev =3D xmalloc (strlen ("/dev/") + data_len); + memcpy (os_dev, "/dev/", strlen ("/dev/")); + memcpy (os_dev + strlen ("/dev/"), data, data_len); + + if (ports && num_ports > 0) + { + mach_msg_type_number_t i; + for (i =3D 0; i < num_ports; i++) + { + mach_port_t port =3D ports[i]; + if (port !=3D MACH_PORT_NULL) + mach_port_deallocate (mach_task_self(), port); + } + munmap ((caddr_t) ports, num_ports * sizeof (*ports)); + } + + if (ints && num_ints > 0) + munmap ((caddr_t) ints, num_ints * sizeof (*ints)); + if (offsets && num_offsets > 0) + munmap ((caddr_t) offsets, num_offsets * sizeof (*offsets)); + if (data && data_len > 0) + munmap (data, data_len); + mach_port_deallocate (mach_task_self (), file); +#else /* !__GNU__ */ + struct stat st; + if (stat (dir, &st) < 0) grub_util_error ("Cannot stat `%s'", dir); =20 @@ -393,6 +456,7 @@ /* This might be truly slow, but is there any better way? */ os_dev =3D find_root_device ("/dev", st.st_dev); #endif +#endif /* !__GNU__ */ =20 return os_dev; }