* [PATCH 0/3] Improve newc generation logging
@ 2023-06-28 7:38 Glenn Washburn
2023-06-28 7:38 ` [PATCH 1/3] misc: Support octal printf format code Glenn Washburn
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Glenn Washburn @ 2023-06-28 7:38 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Gary Lin, Glenn Washburn
The first two patches stand on their own, but are needed for the last patch.
The first patch adds the support for the %o format specifier, which prints
numbers in octal. The second patch was something Daniel requested in reply
to a different patch, adding PRI* macros for types grub_off_t and
grub_disk_addr_t. And the last patch improves the logging when generating
newc archives on the fly. Now all paths generated will be logged with their
size and mode.
Glenn
Glenn Washburn (3):
misc: Support octal printf format code
include/grub/types.h: Add PRI*GRUB_OFFSET and PRI*GRUB_DISK_ADDR
loader/linux: Print debug message for each generated newc path
generated
grub-core/kern/misc.c | 13 +++++++++++--
grub-core/loader/linux.c | 3 ++-
include/grub/types.h | 7 +++++--
3 files changed, 18 insertions(+), 5 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] misc: Support octal printf format code
2023-06-28 7:38 [PATCH 0/3] Improve newc generation logging Glenn Washburn
@ 2023-06-28 7:38 ` Glenn Washburn
2023-06-28 7:38 ` [PATCH 2/3] include/grub/types.h: Add PRI*GRUB_OFFSET and PRI*GRUB_DISK_ADDR Glenn Washburn
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Glenn Washburn @ 2023-06-28 7:38 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Gary Lin, Glenn Washburn
Also add parenthesis to nested terciary operator to improve clarity.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
grub-core/kern/misc.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index 977535282a33..739cc56691a1 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -666,7 +666,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
static inline char *
grub_lltoa (char *str, int c, unsigned long long n)
{
- unsigned base = ((c == 'x') || (c == 'X')) ? 16 : 10;
+ unsigned base = ((c == 'x') || (c == 'X')) ? 16 : ((c == 'o') ? 8 : 10);
char *p;
if ((long long) n < 0 && c == 'd')
@@ -681,9 +681,15 @@ grub_lltoa (char *str, int c, unsigned long long n)
do
{
unsigned d = (unsigned) (n & 0xf);
- *p++ = (d > 9) ? d + ((c == 'x') ? 'a' : 'A') - 10 : d + '0';
+ *p++ = (d > 9) ? (d + ((c == 'x') ? 'a' : 'A') - 10) : d + '0';
}
while (n >>= 4);
+ else if (base == 8)
+ do
+ {
+ *p++ = ((unsigned) (n & 0x7)) + '0';
+ }
+ while (n >>= 3);
else
/* BASE == 10 */
do
@@ -782,6 +788,7 @@ parse_printf_arg_fmt (const char *fmt0, struct printf_args *args,
case 'X':
case 'u':
case 'd':
+ case 'o':
case 'c':
case 'C':
case 's':
@@ -880,6 +887,7 @@ parse_printf_arg_fmt (const char *fmt0, struct printf_args *args,
{
case 'x':
case 'X':
+ case 'o':
case 'u':
args->ptr[curn].type = UNSIGNED_INT + longfmt;
break;
@@ -1089,6 +1097,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
case 'X':
case 'u':
case 'd':
+ case 'o':
write_number (str, &count, max_len, format1, rightfill, zerofill, c, curarg);
break;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] include/grub/types.h: Add PRI*GRUB_OFFSET and PRI*GRUB_DISK_ADDR
2023-06-28 7:38 [PATCH 0/3] Improve newc generation logging Glenn Washburn
2023-06-28 7:38 ` [PATCH 1/3] misc: Support octal printf format code Glenn Washburn
@ 2023-06-28 7:38 ` Glenn Washburn
2023-06-28 7:38 ` [PATCH 3/3] loader/linux: Print debug message for each generated newc path generated Glenn Washburn
2023-06-28 12:50 ` [PATCH 0/3] Improve newc generation logging Daniel Kiper
3 siblings, 0 replies; 5+ messages in thread
From: Glenn Washburn @ 2023-06-28 7:38 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Gary Lin, Glenn Washburn
These are currently always the same as PRI*GRUB_UINT64_T, but they may
not be in the future.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
include/grub/types.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/grub/types.h b/include/grub/types.h
index 9f43a5580935..0d96006fe2a2 100644
--- a/include/grub/types.h
+++ b/include/grub/types.h
@@ -182,10 +182,13 @@ typedef grub_uint64_t grub_properly_aligned_t;
#define GRUB_PROPERLY_ALIGNED_ARRAY(name, size) grub_properly_aligned_t name[((size) + sizeof (grub_properly_aligned_t) - 1) / sizeof (grub_properly_aligned_t)]
/* The type for representing a file offset. */
-typedef grub_uint64_t grub_off_t;
+typedef grub_uint64_t grub_off_t;
+#define PRIxGRUB_OFFSET PRIxGRUB_UINT64_T
+#define PRIuGRUB_OFFSET PRIuGRUB_UINT64_T
/* The type for representing a disk block address. */
-typedef grub_uint64_t grub_disk_addr_t;
+typedef grub_uint64_t grub_disk_addr_t;
+#define PRIxGRUB_DISK_ADDR PRIxGRUB_UINT64_T
/* Byte-orders. */
static inline grub_uint16_t grub_swap_bytes16(grub_uint16_t _x)
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] loader/linux: Print debug message for each generated newc path generated
2023-06-28 7:38 [PATCH 0/3] Improve newc generation logging Glenn Washburn
2023-06-28 7:38 ` [PATCH 1/3] misc: Support octal printf format code Glenn Washburn
2023-06-28 7:38 ` [PATCH 2/3] include/grub/types.h: Add PRI*GRUB_OFFSET and PRI*GRUB_DISK_ADDR Glenn Washburn
@ 2023-06-28 7:38 ` Glenn Washburn
2023-06-28 12:50 ` [PATCH 0/3] Improve newc generation logging Daniel Kiper
3 siblings, 0 replies; 5+ messages in thread
From: Glenn Washburn @ 2023-06-28 7:38 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Gary Lin, Glenn Washburn
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
grub-core/loader/linux.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
index cb2c3f6e4f06..35ad6bf19460 100644
--- a/grub-core/loader/linux.c
+++ b/grub-core/loader/linux.c
@@ -64,6 +64,7 @@ make_header (grub_uint8_t *ptr,
struct newc_head *head = (struct newc_head *) ptr;
grub_uint8_t *optr;
grub_size_t oh = 0;
+ grub_dprintf ("linux", "newc: Creating path '%s', mode=%s%o, size=%"PRIuGRUB_OFFSET"\n", name, (mode == 0) ? "" : "0", mode, fsize);
grub_memcpy (head->magic, "070701", 6);
set_field (head->ino, 0);
set_field (head->mode, mode);
@@ -106,6 +107,7 @@ insert_dir (const char *name, struct dir **root,
struct dir *cur, **head = root;
const char *cb, *ce = name;
*size = 0;
+
while (1)
{
for (cb = ce; *cb == '/'; cb++);
@@ -137,7 +139,6 @@ insert_dir (const char *name, struct dir **root,
grub_free (n);
return grub_errno;
}
- grub_dprintf ("linux", "Creating directory %s, %s\n", name, ce);
ptr = make_header (ptr, tmp_name, ce - name + 1,
040777, 0);
grub_free (tmp_name);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] Improve newc generation logging
2023-06-28 7:38 [PATCH 0/3] Improve newc generation logging Glenn Washburn
` (2 preceding siblings ...)
2023-06-28 7:38 ` [PATCH 3/3] loader/linux: Print debug message for each generated newc path generated Glenn Washburn
@ 2023-06-28 12:50 ` Daniel Kiper
3 siblings, 0 replies; 5+ messages in thread
From: Daniel Kiper @ 2023-06-28 12:50 UTC (permalink / raw)
To: Glenn Washburn; +Cc: grub-devel, Gary Lin
On Wed, Jun 28, 2023 at 02:38:21AM -0500, Glenn Washburn wrote:
> The first two patches stand on their own, but are needed for the last patch.
> The first patch adds the support for the %o format specifier, which prints
> numbers in octal. The second patch was something Daniel requested in reply
> to a different patch, adding PRI* macros for types grub_off_t and
> grub_disk_addr_t. And the last patch improves the logging when generating
> newc archives on the fly. Now all paths generated will be logged with their
> size and mode.
>
> Glenn
>
> Glenn Washburn (3):
> misc: Support octal printf format code
> include/grub/types.h: Add PRI*GRUB_OFFSET and PRI*GRUB_DISK_ADDR
> loader/linux: Print debug message for each generated newc path
> generated
For all patches Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>...
Daniel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-06-28 12:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-28 7:38 [PATCH 0/3] Improve newc generation logging Glenn Washburn
2023-06-28 7:38 ` [PATCH 1/3] misc: Support octal printf format code Glenn Washburn
2023-06-28 7:38 ` [PATCH 2/3] include/grub/types.h: Add PRI*GRUB_OFFSET and PRI*GRUB_DISK_ADDR Glenn Washburn
2023-06-28 7:38 ` [PATCH 3/3] loader/linux: Print debug message for each generated newc path generated Glenn Washburn
2023-06-28 12:50 ` [PATCH 0/3] Improve newc generation logging 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.