logo

bootstrap-initrd

Linux initrd to bootstrap from a small binary seed git clone https://anongit.hacktivis.me/git/bootstrap-initrd.git/

0001-cmd-ln-change-same-reference-from-error-to-informati.patch (1901B)


  1. From c10e309cb4c029629c419d73a2b3f362b42ee65f Mon Sep 17 00:00:00 2001
  2. From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
  3. Date: Mon, 8 Sep 2025 19:55:00 +0200
  4. Subject: [PATCH] cmd/ln: change same reference from error to information
  5. POSIX (2008 and 2024) requires a message to standard error so has
  6. to be logged. Considering as the action is already done there's
  7. no need for an errorneous status.
  8. ---
  9. cmd/ln.c | 4 ++--
  10. test-cmd/ln.sh | 9 ++++++++-
  11. 2 files changed, 10 insertions(+), 3 deletions(-)
  12. diff --git a/cmd/ln.c b/cmd/ln.c
  13. index ad42486..5e866e1 100644
  14. --- a/cmd/ln.c
  15. +++ b/cmd/ln.c
  16. @@ -113,10 +113,10 @@ do_link(char *src, char *dest, int destfd)
  17. else if(src_stat.st_dev == dest_stat.st_dev && src_stat.st_ino == dest_stat.st_ino)
  18. {
  19. fprintf(stderr,
  20. - "ln: error: Source '%s' and destination '%s' refer to the same file\n",
  21. + "ln: info: Source '%s' and destination '%s' refer to the same file\n",
  22. src,
  23. dest);
  24. - return -1;
  25. + return 0;
  26. }
  27. if(unlink(dest) < 0)
  28. diff --git a/test-cmd/ln.sh b/test-cmd/ln.sh
  29. index ca0aa61..39ae619 100755
  30. --- a/test-cmd/ln.sh
  31. +++ b/test-cmd/ln.sh
  32. @@ -2,7 +2,7 @@
  33. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  34. # SPDX-License-Identifier: MPL-2.0
  35. -plans=63
  36. +plans=67
  37. WD=$(dirname "$0")
  38. target="${WD}/../cmd/ln"
  39. . "${WD}/tap.sh"
  40. @@ -107,3 +107,10 @@ t_readlink()
  41. " -s /foo/bar/dest_broken_symlink ./
  42. t_args 'dest_broken_symlink:force' '' -sf /foo/bar/dest_broken_symlink ./
  43. t_cmd 'dest_broken_symlink:cleanup' '' rm dest_broken_symlink
  44. +
  45. +t_args same:create '' -s "$target" same
  46. +t_args --exit=1 same:no_force "ln: error: Destination 'same' already exists
  47. +" -s "$target" same
  48. +t_args same:force "ln: info: Source '$target' and destination 'same' refer to the same file
  49. +" -fs "$target" same
  50. +t_cmd same:cleanup '' rm same
  51. --
  52. 2.49.1