From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MEted-0002Tc-IN for mharc-grub-devel@gnu.org; Thu, 11 Jun 2009 19:25:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MEteZ-0002SB-HO for grub-devel@gnu.org; Thu, 11 Jun 2009 19:25:51 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MEteU-0002Qw-Od for grub-devel@gnu.org; Thu, 11 Jun 2009 19:25:50 -0400 Received: from [199.232.76.173] (port=48665 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MEteU-0002Qr-Fq for grub-devel@gnu.org; Thu, 11 Jun 2009 19:25:46 -0400 Received: from moutng.kundenserver.de ([212.227.126.177]:51913) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MEteT-0004NQ-TH for grub-devel@gnu.org; Thu, 11 Jun 2009 19:25:46 -0400 Received: from [85.180.28.41] (e180028041.adsl.alicedsl.de [85.180.28.41]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0MKv1o-1MEteS3pnc-000jQ2; Fri, 12 Jun 2009 01:25:45 +0200 From: Felix Zielcke To: The development of GRUB 2 In-Reply-To: <1244762505.3552.64.camel@fz.local> References: <1241620317.3746.8.camel@fz.local> <1243885166.3417.11.camel@fz.local> <1244496026.3833.37.camel@fz.local> <1244674821.8525.23.camel@fz.local> <1244762505.3552.64.camel@fz.local> Content-Type: text/plain Date: Fri, 12 Jun 2009 01:25:44 +0200 Message-Id: <1244762744.3552.65.camel@fz.local> Mime-Version: 1.0 X-Mailer: Evolution 2.26.2 Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX19rOzlxbvIuvioHRi9aa5k+AiONSceayZyHTGI LFfVOhIUHv/LAxAktY/HjMfFG1Yqga5slnB6x0nK2Mr5GuNTzY CcW8pijoc1sGpQUYcwFbA== X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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: Thu, 11 Jun 2009 23:25:51 -0000 Am Freitag, den 12.06.2009, 01:21 +0200 schrieb Felix Zielcke: > Am Donnerstag, den 11.06.2009, 01:00 +0200 schrieb Felix Zielcke: > > Am Dienstag, den 09.06.2009, 23:51 +0200 schrieb Vladimir 'phcoder' > > Serbinenko: > > > > > + > > > +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 > > > > Changed. > > > > > + 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 > > > > Changed. > > > + strcpy(buf2,buf); > > > Just save (p - buf) instead of copying buf to buf2 > > > > I did this now if realpath () isn't avaible. > > Now realpath is used in case it's avaible. POSIX specifies it and > > readlink is actually using it if it's avaible. I didn't read the source > > correctly. > > The problem is just Cygwin. It has it but it returns the cygwin path. > > So C:\\Windows would get /cygdrive/c/windows, which is easy to handle. > > But realpath ("/boot/grub") would return /boot/grub which isn't true > > from Windows/GRUB point of view. > > Maybe Christian and Bean can say something about it. > > MingW doestn't have it and I don't know what Windows would have, so the > > MingW users would still use my own way. > > Here's now a new one which aborts if realpath is avaible but doestn't > support (path, NULL) > and the fallback function is changed to dynamically allocate the memory. > And now all memory is properly free'd args just noticed I forgot the *free_ptr = buf2; I'm too lazy now to send an extra patch just for this. -- Felix Zielcke