From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Uj9a3-0000xb-6e for mharc-grub-devel@gnu.org; Sun, 02 Jun 2013 10:48:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uj9Zz-0000xS-Vd for grub-devel@gnu.org; Sun, 02 Jun 2013 10:48:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uj9Zx-00087w-7w for grub-devel@gnu.org; Sun, 02 Jun 2013 10:48:19 -0400 Received: from mail-ea0-x22c.google.com ([2a00:1450:4013:c01::22c]:55779) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uj9Zx-00087s-1Q for grub-devel@gnu.org; Sun, 02 Jun 2013 10:48:17 -0400 Received: by mail-ea0-f172.google.com with SMTP id g14so466782eak.17 for ; Sun, 02 Jun 2013 07:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=3PHTK7qiMg2+qq00/2V1lNByVFVnwn0QY2nthr4HiiI=; b=ybviq5G6m7PfnHj3GofSxG2ZetPJ0V3gi5uaaXfcyOKbT7eF+/ybFgDNERNSvNEy1H P1HA567Y2DPykEzhKMeHJiXaeRA6Rb0k5x2n18uOC7Wh5RJgpboE+urGDFQyqlpg85K/ l+4tCW/rh3nnpGs6Z+RY7wdOKdOZcHsPEIjn2NGrzt2tujCEkJfZBIfLvndAX1qQK42h SCBDwyEpkH2rH5+IAk16ryfco02loehxKR1CT92tWvFqUBIk67a0RvAPuKvF6M0czP/y 44kQtO+lwnfgxR1BNeKs8E2jwe+wkjMW7ZZt//XjZML1XkG6pD5xtoJ6eq8kM3D2yOSO 1QaA== X-Received: by 10.14.29.7 with SMTP id h7mr19924607eea.90.1370184496072; Sun, 02 Jun 2013 07:48:16 -0700 (PDT) Received: from [192.168.56.2] (adsl-ull-89-138.46-151.net24.it. [151.46.138.89]) by mx.google.com with ESMTPSA id b14sm8144494ees.16.2013.06.02.07.48.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Jun 2013 07:48:15 -0700 (PDT) Message-ID: <51AB5B37.5050707@gmail.com> Date: Sun, 02 Jun 2013 16:48:23 +0200 From: Francesco Lavra User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: [PATCH 2/2] ls core command: handle listing of the root directory References: <518F74AA.6090907@gmail.com> <518F7544.5020202@gmail.com> <51975749.6030501@gmail.com> In-Reply-To: <51975749.6030501@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::22c 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: Sun, 02 Jun 2013 14:48:22 -0000 On 05/18/2013 12:26 PM, Francesco Lavra wrote: > On 05/12/2013 12:56 PM, Francesco Lavra wrote: >> Currently, listing of the root directory of a device with the command: >> ls (device_name) >> requires the underlying filesystem driver to handle an empty path >> string as if it was the root directory path "/". This introduces >> duplicated code across the different filesystem drivers. If a given >> filesystem driver does not implement special handling of the empty >> path string, the above command gives "error: invalid file name `'." >> This error happens for instance with the ext4 filesystem. >> The best place to handle correctly the empty path string and transform >> it in "/" is the function grub_core_cmd_ls(), so that handling from >> each filesystem driver is not required anymore. > > After revision 5010, issuing the ls command with a device name as > parameter gives a response such as: > (device_name): Filesystem is . > But grub.texi says: > " > @deffn Command ls [arg @dots{}] > List devices or files. > > With no arguments, print all devices known to GRUB. > > If the argument is a device name enclosed in parentheses (@pxref{Device > syntax}), then list all files at the root directory of that device. > > If the argument is a directory given as an absolute file name (@pxref{File > name syntax}), then list the contents of that directory. > @end deffn > " > > Which is the correct behavior? Depending on the answer to the above question, you might want to consider applying one of the two patches below, as you see fit. Regards, Francesco 2013-06-02 Francesco Lavra * docs/grub.texi (ls): Fix command description in case of a device name passed as argument. === modified file 'docs/grub.texi' --- docs/grub.texi 2013-05-11 05:23:26 +0000 +++ docs/grub.texi 2013-06-02 14:35:24 +0000 @@ -4049,7 +4049,7 @@ With no arguments, print all devices known to GRUB. If the argument is a device name enclosed in parentheses (@pxref{Device -syntax}), then list all files at the root directory of that device. +syntax}), then print the name of the filesystem of that device. If the argument is a directory given as an absolute file name (@pxref{File name syntax}), then list the contents of that directory. 2013-06-02 Francesco Lavra * grub-core/kern/corecmd.c (grub_core_cmd_ls): Fix listing of root directory contents. === modified file 'grub-core/kern/corecmd.c' --- grub-core/kern/corecmd.c 2013-06-02 14:23:14 +0000 +++ grub-core/kern/corecmd.c 2013-06-02 14:28:24 +0000 @@ -147,13 +147,11 @@ if (! *path) { - if (grub_errno == GRUB_ERR_UNKNOWN_FS) - grub_errno = GRUB_ERR_NONE; - - grub_printf ("(%s): Filesystem is %s.\n", - device_name, fs ? fs->name : "unknown"); + /* The argument is a device name: list all files at the root directory + of the device. */ + path = (char *) "/"; } - else if (fs) + if (fs) { (fs->dir) (dev, path, grub_mini_print_files, NULL); grub_xputs ("\n");