Received: from list by lists.gnu.org with archive (Exim 4.71) id 1d43T9-0005LX-FX for mharc-grub-devel@gnu.org; Fri, 28 Apr 2017 06:49:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d43T6-0005LQ-Vh for grub-devel@gnu.org; Fri, 28 Apr 2017 06:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d43T3-0004Ls-0g for grub-devel@gnu.org; Fri, 28 Apr 2017 06:49:45 -0400 Received: from ao2.it ([92.243.12.208]:47406) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d43T2-0004Jw-QZ for grub-devel@gnu.org; Fri, 28 Apr 2017 06:49:40 -0400 Received: from localhost ([::1] helo=jcn) by ao2.it with smtp (Exim 4.84_2) (envelope-from ) id 1d43Su-0005Dw-87; Fri, 28 Apr 2017 12:49:32 +0200 Date: Fri, 28 Apr 2017 12:49:31 +0200 From: Antonio Ospite To: grub-devel@gnu.org Cc: Antonio Ospite Subject: Re: [RFC PATCH 0/2] grub-probe: improve message when disk cannot be opened Message-Id: <20170428124931.d8a7a5a2e02fbebb138a78d7@ao2.it> In-Reply-To: <20160823101728.18774-1-ao2@ao2.it> References: <20160823101728.18774-1-ao2@ao2.it> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 92.243.12.208 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Apr 2017 10:49:46 -0000 On Tue, 23 Aug 2016 12:17:26 +0200 Antonio Ospite wrote: > Hi, > > right now when running grub-probe and the disk cannot be opened the > error message can be misleading, it always says "disk not found" but in > some case the disk may exist but the user has no permissions to open > it, see https://savannah.gnu.org/bugs/?42409 > Ping. Now that grub 2.02 has been released maybe there is a chance that someone looks at this issue? The two patches from this thread still apply to the current master branch. I can resend them if needed. Thanks, Antonio > The message can be improved by propagating informations about the cause > of the failure from the bottom layers. > > Please take a look at the patches in this series, I marked them RFC > because I am new to grub code and I am not sure that all the error paths > set a meaningful message, but I wanted some code to base the discussion > on. > > Patch 1/2 aims to prevent overriding the error messages from the > disk->open() methods called in grub_disk_open(). > > Patch 2/2 exposes to the user the —now more informative— message from > grub_disk_open(). > > Before these changes I was getting this output when running grub-probe > with insufficient permissions: > > $ LANG=C ./grub-probe / > ./grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1. > ./grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1. > ./grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1. > ./grub-probe: error: disk `hostdisk//dev/sda1' not found. > > > After the patches the reason of the failure is clearer: > > $ LANG=C ./grub-probe / > ./grub-probe: warning: cannot open `/dev/sda': Permission denied, so falling back to partition device /dev/sda1. > ./grub-probe: warning: cannot open `/dev/sda': Permission denied, so falling back to partition device /dev/sda1. > ./grub-probe: warning: cannot open `/dev/sda': Permission denied, so falling back to partition device /dev/sda1. > ./grub-probe: error: cannot open `/dev/sda1': Permission denied. > > > As I said, this is the final effect I am aiming for but I am not 100% > sure my solution is complete. > > Thanks, > Antonio > > > Antonio Ospite (2): > * grub-core/kern/disk.c: don't override grub_errmsg when > grub_disk_open fails > * util/getroot.c: improve error message when a disk cannot be opened > > grub-core/kern/disk.c | 3 +-- > util/getroot.c | 15 +++++++++------ > 2 files changed, 10 insertions(+), 8 deletions(-) > -- Antonio Ospite https://ao2.it https://twitter.com/ao2it A: Because it messes up the order in which people normally read text. See http://en.wikipedia.org/wiki/Posting_style Q: Why is top-posting such a bad thing?