From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Qu5n9-0000ud-Kj for mharc-grub-devel@gnu.org; Thu, 18 Aug 2011 12:50:03 -0400 Received: from eggs.gnu.org ([140.186.70.92]:37234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qu5n6-0000tu-C2 for grub-devel@gnu.org; Thu, 18 Aug 2011 12:50:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qu5n4-0007bz-Vs for grub-devel@gnu.org; Thu, 18 Aug 2011 12:50:00 -0400 Received: from mail-fx0-f41.google.com ([209.85.161.41]:62084) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qu5n4-0007bl-HI for grub-devel@gnu.org; Thu, 18 Aug 2011 12:49:58 -0400 Received: by fxg9 with SMTP id 9so1770716fxg.0 for ; Thu, 18 Aug 2011 09:49:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; bh=u6ocyZ5Xq5xk8wF7RwR9gOiw41tl0Qu6bccKXFbDaUM=; b=vqRBr/sGD7NKhcMIqivb4SlG8RbU25q+JdoPR5pVTIIgoeJA64LK08H4if4hclC6EV /9PdvooVtEQXHZBZGvKJ92abECOAC6XkaLw/LlVf+XtLeh4czaWh56pI4rpJ/Af/db/f jGxKCtN2a1gSMcEwS2FnexY2XwuNBDOlInaJs= Received: by 10.223.62.76 with SMTP id w12mr1332712fah.123.1313686196689; Thu, 18 Aug 2011 09:49:56 -0700 (PDT) Received: from debian.x201.phnet (39-92.62-81.cust.bluewin.ch [81.62.92.39]) by mx.google.com with ESMTPS id g16sm1865660faa.27.2011.08.18.09.49.52 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 18 Aug 2011 09:49:53 -0700 (PDT) Message-ID: <4E4D42A8.4000503@gmail.com> Date: Thu, 18 Aug 2011 18:49:44 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110626 Iceowl/1.0b2 Icedove/3.1.11 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: Re: [Patch] Enable libzfs detection on Linux References: <37B025F9-45D9-4424-8458-6B40D2D5A249@gmail.com> In-Reply-To: <37B025F9-45D9-4424-8458-6B40D2D5A249@gmail.com> X-Enigmail-Version: 1.1.2 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig443FB358EB302CBA0D71FE1E" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.161.41 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 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: Thu, 18 Aug 2011 16:50:01 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig443FB358EB302CBA0D71FE1E Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09.08.2011 19:48, Zachary Bedell wrote: > Attached is a patch which allows Grub to detect and use libzfs on Linux= as provided by the ZfsOnLinux project. =20 > > Most of this work was originally done by Darik Horn (dajhorn on GitHub)= against the Grub 1.99 releases as patched by Ubuntu. I've forward porte= d the patches to trunk and separated some of the Ubuntu-specific stuff. = These apply against trunk independent of the other ZFS work I've been doi= ng. > > Changes include: > > configure.ac: =20 > * Add check for libspl to bring in Solaris Porting Library for Linux s= upport. > * Include reference to Linux ZFS's config header to get necessary defi= nes for other ZFS headers on Linux. > * Add checks for libavl, libefi, libunicode, libzpool -- Linux decompo= ses these libraries which are lumped into libzfs on other platforms. > > getroot.c: > * Add ref to mnttab.h from libspl to allow getextmntent to work on Lin= ux. > * Change the order of the grub_find_root_device_from_mountinfo vs find= _root_device_from_libzfs calls so that libzfs runs first, falling down to= mountinfo if zfs isn't detected. > * Scan /proc/mounts and /etc/mtab in addition to /etc/mnttab to discov= er mounted filesystems in grub_find_zpool_from_dir. > /etc/mtab is just a regular file and in many cases is out-of-sync with re= al state of affairs. Should be ignored altogether. Use of /etc/mnttab is = unfortunate but I know of no other way on other platforms (since I haven'= t looked into it). > These patches have been in use by a number of folks using ZfsOnLinux fo= r some time, and they've been robust on those systems. I've tried to ens= ure the changes won't impact non-Linux platforms, though I'm not sure I t= rust my knowledge of autoconf enough to be positive there are no side eff= ects. > You forget the effect of other code changes (below) > - FILE *mnttab =3D fopen ("/etc/mnttab", "r"); > + FILE *mnttab; > + mnttab =3D fopen ("/proc/mounts", "r"); /proc on FreeBSD is very different from Linux one. Don't try /proc/mounts except if you have Linux. > + > + if (! mnttab) > + mnttab =3D fopen ("/etc/mtab", "r"); > + > + if (! mnttab) > + mnttab =3D fopen ("/etc/mnttab", "r"); > + > if (! mnttab) > return; > =20 > -if [ "x`${grub_probe} --device ${GRUB_DEVICE} --target=3Dfs 2>/dev/nul= l || true`" =3D xbtrfs ]; then > +LINUX_ROOT_FS=3D`${grub_probe} --device ${GRUB_DEVICE} --target=3Dfs 2= >/dev/null || true` > +LINUX_ROOT_STAT=3D`stat -f --printf=3D%T / || true` > + > +if [ "x${LINUX_ROOT_FS}" =3D xbtrfs ] || [ "x${LINUX_ROOT_STAT}" =3D x= btrfs ]; then This changes logic for btrfs. I don't think it's necessary or good to just change it. > +if [ "x${LINUX_ROOT_FS}" =3D xzfs ]; then > + GRUB_CMDLINE_LINUX=3D"boot=3Dzfs \$bootfs ${GRUB_CMDLINE_LINUX}" > +fi > + > fi > + if [ "x${LINUX_ROOT_FS}" =3D xzfs ]; then > + cat << EOF > + insmod zfsinfo > + zfs-bootfs (\$root) bootfs > +EOF In this place $root refers to whereever kernel is. So if /boot is separate it will be wrong. Moreover you completely forget the possible subvolumes. One could have e.g. FreeBSD in /freebsd/@/... GNU/Linux in /gnu/linux/@ /boot in /boot/@ In this case $bootfs has to take subvolume into account. Also nothing guarantees that / is accessible from GRUB proper at all. The ZFS in question may be on e.g. SAN. You need to figure parameters in 10_linux, not on boot time. --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------enig443FB358EB302CBA0D71FE1E Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAk5NQq8ACgkQNak7dOguQgl68AEAvi/xJ+Npr4Rq93NS59YHEFvG kiJRfUPF+jD421bjdDoA/AyDzutEjdSMvslmUD1BOQn4Vq3hJB45lQ4omoAClI07 =cRIt -----END PGP SIGNATURE----- --------------enig443FB358EB302CBA0D71FE1E--