All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] commands/ls: Print ???????????? if unable to get file size
@ 2023-08-14  6:20 Glenn Washburn
  2023-08-14 14:13 ` Daniel Kiper
  0 siblings, 1 reply; 2+ messages in thread
From: Glenn Washburn @ 2023-08-14  6:20 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

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>
---
 grub-core/commands/ls.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
index c746eae0c7e7..6a1c7f5d3626 100644
--- a/grub-core/commands/ls.c
+++ b/grub-core/commands/ls.c
@@ -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"));
-- 
2.34.1


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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] commands/ls: Print ???????????? if unable to get file size
  2023-08-14  6:20 [PATCH] commands/ls: Print ???????????? if unable to get file size Glenn Washburn
@ 2023-08-14 14:13 ` Daniel Kiper
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2023-08-14 14:13 UTC (permalink / raw)
  To: Glenn Washburn; +Cc: grub-devel

On Mon, Aug 14, 2023 at 01:20:29AM -0500, Glenn Washburn wrote:
> 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>

Daniel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-14 14:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-14  6:20 [PATCH] commands/ls: Print ???????????? if unable to get file size Glenn Washburn
2023-08-14 14:13 ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.