header_verbose_list.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  4. */
  5. #include "libbb.h"
  6. #include "bb_archive.h"
  7. void FAST_FUNC header_verbose_list(const file_header_t *file_header)
  8. {
  9. struct tm tm_time;
  10. struct tm *ptm = &tm_time; //localtime(&file_header->mtime);
  11. char modestr[12];
  12. #if ENABLE_FEATURE_TAR_UNAME_GNAME
  13. char uid[sizeof(int)*3 + 2];
  14. /*char gid[sizeof(int)*3 + 2];*/
  15. char *user;
  16. char *group;
  17. localtime_r(&file_header->mtime, ptm);
  18. user = file_header->tar__uname;
  19. if (user == NULL) {
  20. sprintf(uid, "%u", (unsigned)file_header->uid);
  21. user = uid;
  22. }
  23. group = file_header->tar__gname;
  24. if (group == NULL) {
  25. /*sprintf(gid, "%u", (unsigned)file_header->gid);*/
  26. group = utoa(file_header->gid);
  27. }
  28. printf("%s %s/%s %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
  29. bb_mode_string(modestr, file_header->mode),
  30. user,
  31. group,
  32. file_header->size,
  33. 1900 + ptm->tm_year,
  34. 1 + ptm->tm_mon,
  35. ptm->tm_mday,
  36. ptm->tm_hour,
  37. ptm->tm_min,
  38. ptm->tm_sec,
  39. file_header->name);
  40. #else /* !FEATURE_TAR_UNAME_GNAME */
  41. localtime_r(&file_header->mtime, ptm);
  42. printf("%s %u/%u %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
  43. bb_mode_string(modestr, file_header->mode),
  44. (unsigned)file_header->uid,
  45. (unsigned)file_header->gid,
  46. file_header->size,
  47. 1900 + ptm->tm_year,
  48. 1 + ptm->tm_mon,
  49. ptm->tm_mday,
  50. ptm->tm_hour,
  51. ptm->tm_min,
  52. ptm->tm_sec,
  53. file_header->name);
  54. #endif /* FEATURE_TAR_UNAME_GNAME */
  55. /* NB: GNU tar shows "->" for symlinks and "link to" for hardlinks */
  56. if (file_header->link_target) {
  57. printf(" -> %s", file_header->link_target);
  58. }
  59. bb_putchar('\n');
  60. }