Skip to contentSkip to conversation

Documentation on hexdump

PATCH In review Glenn Washburn 3 participants 5 messages Jul 26, 2023 – Aug 11, 2023

lore
Share & tools
lore
#0 lore raw

cover Documentation on hexdump

Add documentation on hexdump.

Glenn

Glenn Washburn (2):
docs: Document hexdump command
docs: A note to cat that hexdump should be used for binary data

 docs/grub.texi | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 docs: Document hexdump command

---
 docs/grub.texi | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
docs/grub.texi +15 -1
index dae10621b99f..5f6f0895ef4f 100644
@@ -4361,6 +4361,7 @@ you forget a command, you can run the command @command{help}
 * halt::                        Shut down your computer
 * hashsum::                     Compute or check hash checksum
 * help::                        Show help messages
+* hexdump::                     Show raw contents of a file or memory
 * insmod::                      Insert a module
 * keystatus::                   Check key modifier status
 * list_env::                    List variables in environment block
@@ -4979,6 +4980,20 @@ about each of the commands whose names begin with those @var{patterns}.
 @end deffn
 
 
+@node hexdump
+@subsection hexdump
+
+@deffn Command hexdump [--skip offset] [--length len] FILE_OR_DEVICE
+Show raw contents of a file or memory. When option @option{--skip} is given,
+@samp{offset} number of bytes are skipped from the start of the device or
+file given. And @option{--length} allows specifying a maximum number of bytes
+to be shown.
+
+If given the special device named @samp{(mem)}, then the @samp{offset} given to
+@option{--skip} is treated as the address of a memory location to dump from.
+@end deffn
+
+
 @node insmod
 @subsection insmod
 
@@ -6170,7 +6185,6 @@ GRUB shell may provide more information on parameters and usage.
 @item @command{gdbstub} -  Start GDB stub on given port
 @item @command{gdbstub_stop} - Stop GDB stub
 @item @command{hdparm} - Get/set ATA disk parameters.
-@item @command{hexdump} - Show raw contents of a file or memory.
 @item @command{hexdump_random} - Hexdump random data.
 @item @command{inb} - Read 8-bit value from PORT.
 @item @command{inl} - Read 32-bit value from PORT.
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 docs: A note to cat that hexdump should be used for binary data

In reply to Glenn Washburn

The cat command should not be used to print binary data because it can show bytes not in the binary data and not show bytes that are in the data, which can lead to confusion. This happens because cat does some processing of the data stream, namely trying to decode substrings as UTF-8.

---
 docs/grub.texi | 6 ++++++
 1 file changed, 6 insertions(+)
docs/grub.texi +6 -0
index 5f6f0895ef4f..71bd578c7a11 100644
@@ -4541,6 +4541,12 @@ will be displayed as a simple new line.  Otherwise, the carriage return will
 be displayed as a control character (@samp{<d>}) to make it easier to see
 when boot problems are caused by a file formatted using DOS-style line
 endings.
+
+Note: @command{cat} can be used to view the contents of devices using the
+block list syntax (@pxref{Block list syntax}). However, it is not advised
+to view binary data because it will try to decode UTF-8 strings, which can
+lead to some bytes missing or added in the output. Instead, use the
+@command{hexdump} command (@pxref{hexdump}).
 @end deffn
 
 
Signature · 1 line
2.34.1
Reviewed-by on the v1 series
#3 lore raw
In reply to Glenn Washburn
Quoted 11 lines · Glenn Washburn

Add documentation on hexdump.

Glenn

Glenn Washburn (2):
docs: Document hexdump command
docs: A note to cat that hexdump should be used for binary data

 docs/grub.texi | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

LGTM

- Oskari

Reviewed-by
#4 lore raw
Quoted 9 lines · Oskari Pirhonen
Quoted 8 lines · Glenn Washburn

Add documentation on hexdump.

Glenn

Glenn Washburn (2):
docs: Document hexdump command
docs: A note to cat that hexdump should be used for binary data

Quoted 6 lines
Quoted 2 lines
 docs/grub.texi | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

LGTM

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel