From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org, Daniel Kiper <dkiper@net-space.pl>
Cc: Vladimir Serbinenko <phcoder@gmail.com>,
Glenn Washburn <development@efficientek.com>
Subject: [PATCH v2 0/3] More ls improvements
Date: Sat, 8 Jun 2024 16:58:30 -0500 [thread overview]
Message-ID: <cover.1714214367.git.development@efficientek.com> (raw)
Currently when given a path to a file, ls will open the file to determine
if its is valid and then run the appropriate print function, in contrast to
directory arguments that use the directory iterator and callback on each
file. One issue with this is that opening a file does not allow access to
its modification time information, whereas the info object from the callback
called by the directory iterator does and the longlist print function will
print the modification time if present. The result is that when longlisting
ls arguments, directory arguments show moditication times but file arguments
do not. Patch 1 rectifies this an in the process simplifies the code path
by using the directory iterator for file arguments as well.
Patches 2 and 3 aim to make the output of GRUB's ls look more like GNU's
ls output. And patch 3 also fixes an issue where there are blank lines
between consecutive file arguments.
v2:
* Remove first patch of v1
* Reset grub_errno in grub_ls_list_files instead
Glenn Washburn (3):
commands/ls: Allow printing mtime for file arguments
commands/ls: Add directory header for dir args and print full paths
for file args
commands/ls: Proper line breaks between arguments
grub-core/commands/ls.c | 123 ++++++++++++++++++++++++----------------
1 file changed, 75 insertions(+), 48 deletions(-)
Range-diff against v1:
1: c9066a31480c < -: ------------ disk: Reset grub_errno upon entering grub_disk_read()
2: 8947f5257962 ! 1: 187a173d6e8a commands/ls: Allow printing mtime for file arguments
@@ grub-core/commands/ls.c: grub_ls_list_files (char *dirname, int longlist, int al
if (grub_errno == GRUB_ERR_BAD_FILE_TYPE
&& path[grub_strlen (path) - 1] != '/')
{
- /* PATH might be a regular file. */
+- /* PATH might be a regular file. */
- char *p;
- grub_file_t file;
- struct grub_dirhook_info info;
@@ grub-core/commands/ls.c: grub_ls_list_files (char *dirname, int longlist, int al
- goto fail;
-
- grub_file_close (file);
--
++ /*
++ * Reset errno as it is currently set, but will cause subsequent code
++ * to think there is an error.
++ */
++ grub_errno = GRUB_ERR_NONE;
+
- p = grub_strrchr (dirname, '/') + 1;
- ctx.dirname = grub_strndup (dirname, p - dirname);
++ /* PATH might be a regular file. */
+ ctx.filename = grub_strrchr (dirname, '/') + 1;
+ ctx.dirname = grub_strndup (dirname, ctx.filename - dirname);
if (ctx.dirname == NULL)
3: ce655165f508 ! 2: cd02a1fa4512 commands/ls: Add directory header for dir args and print full paths for file args
@@ grub-core/commands/ls.c: grub_ls_list_files (char *dirname, int longlist, int al
(fs->fs_dir) (dev, path, print_files, &ctx);
@@ grub-core/commands/ls.c: grub_ls_list_files (char *dirname, int longlist, int all, int human)
- && path[grub_strlen (path) - 1] != '/')
- {
+ grub_errno = GRUB_ERR_NONE;
+
/* PATH might be a regular file. */
+ ctx.print_dirhdr = 0;
ctx.filename = grub_strrchr (dirname, '/') + 1;
4: 1a14220825c2 = 3: 6988321447be commands/ls: Proper line breaks between arguments
--
2.34.1
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next reply other threads:[~2024-06-08 22:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-08 21:58 Glenn Washburn [this message]
2024-06-08 21:58 ` [PATCH v2 1/3] commands/ls: Allow printing mtime for file arguments Glenn Washburn
2024-11-27 16:23 ` Daniel Kiper
2024-06-08 21:58 ` [PATCH v2 2/3] commands/ls: Add directory header for dir args and print full paths for file args Glenn Washburn
2024-11-27 16:27 ` Daniel Kiper
2024-06-08 21:58 ` [PATCH v2 3/3] commands/ls: Proper line breaks between arguments Glenn Washburn
2024-11-27 16:29 ` Daniel Kiper
2024-11-08 19:20 ` [PATCH v2 0/3] More ls improvements Glenn Washburn
2024-11-12 16:12 ` Daniel Kiper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1714214367.git.development@efficientek.com \
--to=development@efficientek.com \
--cc=dkiper@net-space.pl \
--cc=grub-devel@gnu.org \
--cc=phcoder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.