]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
commands/ls: Print "????????????" if unable to get file size
authorGlenn Washburn <development@efficientek.com>
Mon, 14 Aug 2023 06:20:29 +0000 (01:20 -0500)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 14 Aug 2023 16:12:49 +0000 (18:12 +0200)
In long list mode, if the file can not be opened, the file is not printed.
Instead, print the file but print the size as "????????????".

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/ls.c

index c746eae0c7e7bbccc975d48b4323e8c65231ae8a..6a1c7f5d362673d79c187ce92175ee268cecee6a 100644 (file)
@@ -131,20 +131,20 @@ print_files_long (const char *filename, const struct grub_dirhook_info *info,
         should be reported as directories.  */
       file = grub_file_open (pathname, GRUB_FILE_TYPE_GET_SIZE
                             | GRUB_FILE_TYPE_NO_DECOMPRESS);
-      if (file)
+      if (file)
        {
-         grub_errno = 0;
-         grub_free (pathname);
-         return 0;
+         if (! ctx->human)
+           grub_printf ("%-12llu", (unsigned long long) file->size);
+         else
+           grub_printf ("%-12s", grub_get_human_size (file->size,
+                                                  GRUB_HUMAN_SIZE_SHORT));
+         grub_file_close (file);
        }
-
-      if (! ctx->human)
-       grub_printf ("%-12llu", (unsigned long long) file->size);
       else
-       grub_printf ("%-12s", grub_get_human_size (file->size,
-                                                  GRUB_HUMAN_SIZE_SHORT));
-      grub_file_close (file);
+       grub_xputs ("????????????");
+
       grub_free (pathname);
+      grub_errno = GRUB_ERR_NONE;
     }
   else
     grub_printf ("%-12s", _("DIR"));