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  <francescolavra...@gmail.com>

        * 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)
        {

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to