From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YAhaz-0007LL-58 for mharc-grub-devel@gnu.org; Mon, 12 Jan 2015 11:12:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAhaw-0007HY-Fk for grub-devel@gnu.org; Mon, 12 Jan 2015 11:11:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YAhar-00077i-Dc for grub-devel@gnu.org; Mon, 12 Jan 2015 11:11:58 -0500 Received: from mail.ixsystems.com ([69.198.165.135]:64519 helo=barracuda.ixsystems.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAhaq-00077L-SQ for grub-devel@gnu.org; Mon, 12 Jan 2015 11:11:53 -0500 X-ASG-Debug-ID: 1421079109-08ca0411b1003a0002-Td4drV Received: from [192.168.0.51] (75-130-56-30.static.kgpt.tn.charter.com [75.130.56.30]) by barracuda.ixsystems.com with ESMTP id U6T3PzZTY1FhVqYo (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Mon, 12 Jan 2015 08:11:50 -0800 (PST) X-Barracuda-Envelope-From: kris@pcbsd.org X-Barracuda-AUTH-User: kris@pcbsd.org X-Barracuda-Apparent-Source-IP: 75.130.56.30 Message-ID: <54B3F245.6020708@pcbsd.org> Date: Mon, 12 Jan 2015 11:11:49 -0500 From: Kris Moore User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: Re: Patch to fix kldstat(2) / dtrace when booting FreeBSD References: <54B0025E.4020407@pcbsd.org> <20150111212748.153e7951@opensuse.site> X-ASG-Orig-Subj: Re: Patch to fix kldstat(2) / dtrace when booting FreeBSD In-Reply-To: <20150111212748.153e7951@opensuse.site> Content-Type: multipart/mixed; boundary="------------060602040203010506050007" X-Barracuda-Connect: 75-130-56-30.static.kgpt.tn.charter.com[75.130.56.30] X-Barracuda-Start-Time: 1421079110 X-Barracuda-Encrypted: ECDHE-RSA-AES128-GCM-SHA256 X-Barracuda-URL: https://10.2.0.41:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ixsystems.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.14227 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 69.198.165.135 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: Mon, 12 Jan 2015 16:11:59 -0000 This is a multi-part message in MIME format. --------------060602040203010506050007 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/11/2015 13:27, Andrei Borzenkov wrote: > =D0=92 Fri, 09 Jan 2015 11:31:26 -0500 > Kris Moore =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > >> The following patch fixes an important issue when booting FreeBSD. >> FreeBSD's kldstat(2) function expects that the full pathname will be >> provided to kernel / modules. The current GRUB was striping this out a= nd >> only leaving the filename itself. This broke dtrace and other things >> which used the full pathname to locate the kernel or modules on disk. >> >> The attached patch fixes this behavior. >> >> diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c >> index 8f691e0..fb47969 100644 >> --- a/grub-core/loader/i386/bsd.c >> +++ b/grub-core/loader/i386/bsd.c >> @@ -415,11 +415,15 @@ grub_freebsd_add_meta_module (const char *filena= me, const char *type, >> grub_addr_t addr, grub_uint32_t size) >> { >> const char *name; >> - name =3D grub_strrchr (filename, '/'); >> + /* Don't strip the full path, some FreeBSD functionality, such >> + * as kldstat(2) / dtrace, rely on this. Instead we only need to rem= ove >> + * any ZFS dataset information first. */ >> + name =3D grub_strrchr (filename, '@'); > What if filename itself contains '@'? Is it possible? > I don't see anything in the manpages that explicitly prohibits certain characters, however, all the modules FreeBSD uses, and ones in ports, don't use any special characters of any kind. I suspect that having a module with a '@' in it would cause other potential breakage as well. >> if (name) >> name++; >> else >> name =3D filename; >> + > Please, could we avoid unrelated formatting changes? > >> if (grub_strcmp (type, "/boot/zfs/zpool.cache") =3D=3D 0) >> name =3D "/boot/zfs/zpool.cache"; >> =20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel Here you go, without the formatting changes. --=20 Kris Moore PC-BSD Software iXsystems --------------060602040203010506050007 Content-Type: text/x-csrc; name="patch-grub-core-loader-i386-bsd.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch-grub-core-loader-i386-bsd.c" diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index 8f691e0..7476f5a 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -415,7 +415,10 @@ grub_freebsd_add_meta_module (const char *filename, const char *type, grub_addr_t addr, grub_uint32_t size) { const char *name; - name = grub_strrchr (filename, '/'); + /* Don't strip the full path, some FreeBSD functionality, such + * as kldstat(2) / dtrace, rely on this. Instead we only need to remove + * any ZFS dataset information first. */ + name = grub_strrchr (filename, '@'); if (name) name++; else --------------060602040203010506050007--