Received: from list by lists.gnu.org with archive (Exim 4.71) id 1SLCFW-0000J5-U9 for mharc-grub-devel@gnu.org; Fri, 20 Apr 2012 07:43:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SLCFQ-0000Ig-Qt for grub-devel@gnu.org; Fri, 20 Apr 2012 07:43:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SLCFN-00029p-FK for grub-devel@gnu.org; Fri, 20 Apr 2012 07:43:32 -0400 Received: from mail-vb0-f41.google.com ([209.85.212.41]:41044) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SLCFN-000296-8K for grub-devel@gnu.org; Fri, 20 Apr 2012 07:43:29 -0400 Received: by vbbey12 with SMTP id ey12so7862584vbb.0 for ; Fri, 20 Apr 2012 04:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=T9xMvTGnxxPpocf8Vn711PDw6/JrJP2HhB0+VW+fP1s=; b=upN8KO+/vFnDS1DK9QwifS0dpfXHseGD7se3KhYMPB1Ss6AihhrX+jAqg/RL/qdEhs DhGYLzu5MZYjFHJwyqH5Jp8+zwRPEMzmRj+czxmpj58jyuFZzr5RZF4Rbu6O80S03rJn seIGCYHgrBnepdAjyjkPD63tj4uH9UOgW31BgGOZ/vVpv2h1fnRQ3tHwJEMDjjoW2+0b GypHnG7Mg/ajndVhmRYt9wUDWBdir1ykj2KZq+WpJHbhvahfLaqvG7+qFZsUErdnDk43 fKdq4UoBH+VeTAwjWJwPbwuCcDd8tWjvm3/K1YpzLULa7xMdIJWmSuFHUBZfSYwFdDpx 6S6w== Received: by 10.52.20.35 with SMTP id k3mr2054644vde.44.1334922206603; Fri, 20 Apr 2012 04:43:26 -0700 (PDT) Received: from linux-dsax.tai.apac.novell.com ([130.57.30.250]) by mx.google.com with ESMTPS id n12sm7493518vdt.1.2012.04.20.04.43.24 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 Apr 2012 04:43:26 -0700 (PDT) Sender: =?UTF-8?B?5by15paH6I+v?= Date: Fri, 20 Apr 2012 19:40:48 +0800 From: Michael Chang To: grub-devel@gnu.org Subject: [PATCH] fix grub-probe fail on by-(id|uuid|path) device names Message-ID: <20120420114048.GA31890@linux-dsax.tai.apac.novell.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="a8Wt8u1KmwUX3Y2C" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.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: Fri, 20 Apr 2012 11:43:37 -0000 --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This patch fixes grub-probe fails on probing devices under /dev/disk/by-id and other similar mount-by alias names. The method used to determine the whole disk is by it's name without numeric character end, but this may be wrong for the by-(id|uuid|path) names as they are not necessary ended without numeric character. For instance, my disk was named "/dev/disk/by-id/ata-WDC_WD1600BEKT-60V5T1_WD-WXK0A69Y4761". The fix is use resolved link to kernel device names (like /dev/sda) instead of these alias names. Downstream bug: https://bugzilla.novell.com/show_bug.cgi?id=757746 --a8Wt8u1KmwUX3Y2C Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="use_kernel_device_name_in_device_is_wholedisk.patch" === modified file 'util/getroot.c' --- util/getroot.c 2012-03-31 10:27:10 +0000 +++ util/getroot.c 2012-04-20 11:06:18 +0000 @@ -2093,7 +2093,16 @@ static int device_is_wholedisk (const char *os_dev) { - int len = strlen (os_dev); + int len; + char os_dev_realpath[PATH_MAX]; + + if (strncmp (os_dev, "/dev/disk/by-id/", 16) == 0 || + strncmp (os_dev, "/dev/disk/by-uuid/", 18) == 0 || + strncmp (os_dev, "/dev/disk/by-path/", 18) == 0) + if (realpath (os_dev, os_dev_realpath)) + os_dev = os_dev_realpath; + + len = strlen (os_dev); if (os_dev[len - 1] < '0' || os_dev[len - 1] > '9') return 1; --a8Wt8u1KmwUX3Y2C--