020-i386-improve-basename-compatibility.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From 99f62f58fac57214ecc3c9aabf6bf61ac1e1201d Mon Sep 17 00:00:00 2001
  2. From: Tony Ambardar <[email protected]>
  3. Date: Fri, 7 Jun 2024 21:54:56 -0700
  4. Subject: [PATCH] i386: improve basename() compatibility
  5. Drop usage of glibc basename() in favour of a simpler implementation that
  6. works across GNU and musl libc, and is similar to existing code in fs2dt.c.
  7. This fixes compile errors seen building against musl.
  8. Signed-off-by: Tony Ambardar <[email protected]>
  9. ---
  10. kexec/arch/i386/x86-linux-setup.c | 5 +++--
  11. 1 file changed, 3 insertions(+), 2 deletions(-)
  12. --- a/kexec/arch/i386/x86-linux-setup.c
  13. +++ b/kexec/arch/i386/x86-linux-setup.c
  14. @@ -318,6 +318,7 @@ static int add_edd_entry(struct x86_linu
  15. uint8_t devnum, version;
  16. uint32_t mbr_sig;
  17. struct edd_info *edd_info;
  18. + char *basename = strrchr(sysfs_name,'/') + 1;
  19. if (!current_mbr || !current_edd) {
  20. fprintf(stderr, "%s: current_edd and current_edd "
  21. @@ -329,9 +330,9 @@ static int add_edd_entry(struct x86_linu
  22. memset(edd_info, 0, sizeof(struct edd_info));
  23. /* extract the device number */
  24. - if (sscanf(basename(sysfs_name), "int13_dev%hhx", &devnum) != 1) {
  25. + if (sscanf(basename, "int13_dev%hhx", &devnum) != 1) {
  26. fprintf(stderr, "Invalid format of int13_dev dir "
  27. - "entry: %s\n", basename(sysfs_name));
  28. + "entry: %s\n", basename);
  29. return -1;
  30. }