summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Washburn <development@efficientek.com>2023-08-14 01:16:53 -0500
committerDaniel Kiper <daniel.kiper@oracle.com>2023-08-14 18:10:36 +0200
commit6889c67fe7f2d6bbaa1f6050d9e29e616740936b (patch)
treed3e6213e99749b5e1f863680cf67b1565d144e47
parentfcbea18c584257adc824cbb1c66cec2f4329869c (diff)
commands/ls: Send correct dirname to print functions
For each non-directory path argument to the ls command, the full path was being sent to the print functions, instead of the dirname. The long output print function expected dirname to be the directory containing the file and so could not open the file to get the file size because the generated path was incorrect. This caused the output to be a blank line. Signed-off-by: Glenn Washburn <development@efficientek.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
-rw-r--r--grub-core/commands/ls.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c
index 8e98c73cc..c746eae0c 100644
--- a/grub-core/commands/ls.c
+++ b/grub-core/commands/ls.c
@@ -242,8 +242,8 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
grub_file_close (file);
p = grub_strrchr (dirname, '/') + 1;
- dirname = grub_strndup (dirname, p - dirname);
- if (! dirname)
+ ctx.dirname = grub_strndup (dirname, p - dirname);
+ if (ctx.dirname == NULL)
goto fail;
all = 1;
@@ -253,7 +253,7 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human)
else
print_files (p, &info, &ctx);
- grub_free (dirname);
+ grub_free (ctx.dirname);
}
if (grub_errno == GRUB_ERR_NONE)