From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1UbTvd-0000jS-2Q for mharc-grub-devel@gnu.org; Sun, 12 May 2013 06:54:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbTvZ-0000jL-GB for grub-devel@gnu.org; Sun, 12 May 2013 06:54:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UbTvX-0004Hh-4b for grub-devel@gnu.org; Sun, 12 May 2013 06:54:53 -0400 Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]:56043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbTvW-0004Hb-V4 for grub-devel@gnu.org; Sun, 12 May 2013 06:54:51 -0400 Received: by mail-wg0-f42.google.com with SMTP id j13so2019216wgh.5 for ; Sun, 12 May 2013 03:54:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=zj4Cb0+/3aDcyrKz2Gk51lVy/LGOetvAMy1CsHyj2uo=; b=kYlKpgMFiaG9wzyQnzHZaZX5A5+EG9Z+Ey5xD78a/CuNm9VpliYeqwk7PeqarwCfIr g1T8MpqcnWEBd1z06T5GAkhFaKfCvxlVkYWb3n1q0HWqoqluU7MPldvW3MjyDpRr1z+3 C8gwF7m16q3Tkguj4rucXedmIQmHiHNIoIkm/U76XptNIbXaVNPCqMh/8QttUG+Cv4O7 JRSy3wvbMGYxY0PekK4lrv/hRb5pWR3BWqVkUw8EebMJZWVgtvObHqyGkBQByeeBZpCu pgIO92YwLiTSwEV19pQyH9geilKd66O//g5wKVGNWRp/0a8TN2hURStZSIGu694eK7Ep KcxA== X-Received: by 10.180.90.164 with SMTP id bx4mr12631906wib.13.1368356090197; Sun, 12 May 2013 03:54:50 -0700 (PDT) Received: from [192.168.56.2] (ppp-173-23.31-151.libero.it. [151.31.23.173]) by mx.google.com with ESMTPSA id cw8sm8518751wib.7.2013.05.12.03.54.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 12 May 2013 03:54:49 -0700 (PDT) Message-ID: <518F7544.5020202@gmail.com> Date: Sun, 12 May 2013 12:56:04 +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: [PATCH 2/2] ls core command: handle listing of the root directory References: <518F74AA.6090907@gmail.com> In-Reply-To: <518F74AA.6090907@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:400c:c00::22a 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, 12 May 2013 10:54:56 -0000 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. 2013-05-12 Francesco Lavra * grub-core/kern/corecmd.c (grub_core_cmd_ls): Handle listing of the root directory. === modified file 'grub-core/kern/corecmd.c' --- grub-core/kern/corecmd.c 2013-05-12 09:45:56 +0000 +++ grub-core/kern/corecmd.c 2013-05-12 09:55:53 +0000 @@ -137,7 +137,13 @@ if (! path) path = argv[0]; else - path++; + { + path++; + if (*path == '\0') + /* The argument is a device name: list all files at the root + directory of the device. */ + path = (char *) "/"; + } if (fs) {