Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1ME9Ef-0000PO-Mz for mharc-grub-devel@gnu.org; Tue, 09 Jun 2009 17:52:01 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ME9Ee-0000Ng-IM for grub-devel@gnu.org; Tue, 09 Jun 2009 17:52:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ME9EZ-0000Ee-JH for grub-devel@gnu.org; Tue, 09 Jun 2009 17:52:00 -0400 Received: from [199.232.76.173] (port=54378 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ME9EZ-0000EK-DN for grub-devel@gnu.org; Tue, 09 Jun 2009 17:51:55 -0400 Received: from mail-fx0-f217.google.com ([209.85.220.217]:41819) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ME9EY-0006z3-Q8 for grub-devel@gnu.org; Tue, 09 Jun 2009 17:51:55 -0400 Received: by fxm17 with SMTP id 17so401958fxm.42 for ; Tue, 09 Jun 2009 14:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=eZUQ5FxJ9w5G2hlnzbSJJ4dnSS7zSEPkQSk5dxrsrQo=; b=TKHzbXzLfuDh+SZDKn4MFTXHDQpSlPUVRGa+SbLeTACU7l5zBuV3/+fCz1JxRthEmV iEcOzfH3mmM4EKUSg3+gMzZj4npJ1+5FdoQ9aW5/bJF2V6vDfdduMLjoaEo0m1qKM1rn 1dM7yM5fEwTwqriOnoHIopANjgtpvhRjfwcRk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=xlTVzVgCHpMVMbj+A0Q2rLIeERuFEt2Ke7JPwGjLZOoZXN7fT6tuHFLeETEF1DcEp6 WjwwVsUBfxd8Eqzfm/dbf0hPYtnyGdkv5cV3qA8G5ZqtWL8rppCCsjo0G7COir4sUNYB Vkus901TwMBnF1+dIPmNy1JPdvAFXBxQmaNX8= MIME-Version: 1.0 Received: by 10.204.61.209 with SMTP id u17mr551258bkh.86.1244584313582; Tue, 09 Jun 2009 14:51:53 -0700 (PDT) In-Reply-To: <1244496026.3833.37.camel@fz.local> References: <1241620317.3746.8.camel@fz.local> <1243885166.3417.11.camel@fz.local> <1244496026.3833.37.camel@fz.local> Date: Tue, 9 Jun 2009 23:51:53 +0200 Message-ID: From: "Vladimir 'phcoder' Serbinenko" To: The development of GRUB 2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [PATCH] Re: grub-install --root-directory=/mnt /dev/sda1 fails X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jun 2009 21:52:00 -0000 2009-06-08 Felix Zielcke * include/grub/util/hostdisk.c (grub_make_system_path_relative_to_its_root): New function prototype. * util/hostdisk.c (grub_make_system_path_relative_to_its_root): New function. * util/i386/pc/grub-setup.c (setup): Use grub_make_system_path_relative_to_its_root to make core_path_dev relative to the partition. diff --git a/util/hostdisk.c b/util/hostdisk.c index a7262dd..0a786ba 100644 --- a/util/hostdisk.c +++ b/util/hostdisk.c @@ -1076,3 +1076,39 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) return make_device_name (drive, -1, -1); #endif } + +char *grub_make_system_path_relative_to_its_root (char *path) +{ + + struct stat st; + char buf[500], buf2[500]; Use malloc instead of static allocation + p = strrchr (buf, '/'); + if (p != buf) + *p = 0; + else *++p = 0; You assume path starts with /. You have to check this. Otherwise you may get sigsegv + strcpy(buf2,buf); Just save (p - buf) instead of copying buf to buf2 On Mon, Jun 8, 2009 at 11:20 PM, Felix Zielcke wrote: > Am Montag, den 01.06.2009, 21:39 +0200 schrieb Felix Zielcke: >> Am Mittwoch, den 06.05.2009, 17:12 +0200 schrieb Vladimir 'phcoder' >> Serbinenko: >> > Don't we already have a function which transforms host directory into >> > grub >> > directory? AFAIR we have. >> >> There's just the shell function in grub-mkconfig_lib.in >> Here's now a patch wich implements it in util/hostdisk.c and gets used >> for core_path_dev in setup (). >> But it doestn't work with symlinks. >> readlink () can only be used if the file pointed to is a symlink, not if >> a symlink is somewhere in between. >> coreutils where the readlink binary is from is GPL 3+ but the function >> for it uses hash tables and it seems like it would be too much code to >> copy just for this. > > Here's a new patch which prints out an error if stat () fails. > -- > Felix Zielcke > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > > -- Regards Vladimir 'phcoder' Serbinenko