0001-nfs-utils-print-time-in-64-bit.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. From cb75ec49c0a92f55b2241eb1cd95a3fdf63f0dac Mon Sep 17 00:00:00 2001
  2. From: Rosen Penev <rosenp@gmail.com>
  3. Date: Mon, 13 Apr 2020 14:14:45 -0400
  4. Subject: [PATCH] nfs-utils: print time in 64-bit
  5. musl 1.2.0 defines time_t as 64-bit, even under 32-bit OSes.
  6. Fixes -Wformat errors.
  7. Signed-off-by: Rosen Penev <rosenp@gmail.com>
  8. Signed-off-by: Steve Dickson <steved@redhat.com>
  9. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
  10. ---
  11. support/nfs/cacheio.c | 3 ++-
  12. utils/idmapd/idmapd.c | 11 ++++++-----
  13. 2 files changed, 8 insertions(+), 6 deletions(-)
  14. diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c
  15. index 7c4cf373..126c1283 100644
  16. --- a/support/nfs/cacheio.c
  17. +++ b/support/nfs/cacheio.c
  18. @@ -20,6 +20,7 @@
  19. #endif
  20. #include <nfslib.h>
  21. +#include <inttypes.h>
  22. #include <stdio.h>
  23. #include <stdio_ext.h>
  24. #include <string.h>
  25. @@ -238,7 +239,7 @@ cache_flush(int force)
  26. stb.st_mtime > now)
  27. stb.st_mtime = time(0);
  28. - sprintf(stime, "%ld\n", stb.st_mtime);
  29. + sprintf(stime, "%" PRId64 "\n", (int64_t)stb.st_mtime);
  30. for (c=0; cachelist[c]; c++) {
  31. int fd;
  32. sprintf(path, "/proc/net/rpc/%s/flush", cachelist[c]);
  33. diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c
  34. index c187e7d7..893159f1 100644
  35. --- a/utils/idmapd/idmapd.c
  36. +++ b/utils/idmapd/idmapd.c
  37. @@ -54,6 +54,7 @@
  38. #include <dirent.h>
  39. #include <unistd.h>
  40. #include <netdb.h>
  41. +#include <inttypes.h>
  42. #include <signal.h>
  43. #include <stdio.h>
  44. #include <stdlib.h>
  45. @@ -172,7 +173,7 @@ flush_nfsd_cache(char *path, time_t now)
  46. int fd;
  47. char stime[32];
  48. - sprintf(stime, "%ld\n", now);
  49. + sprintf(stime, "%" PRId64 "\n", (int64_t)now);
  50. fd = open(path, O_RDWR);
  51. if (fd == -1)
  52. return -1;
  53. @@ -625,8 +626,8 @@ nfsdcb(int UNUSED(fd), short which, void *data)
  54. /* Name */
  55. addfield(&bp, &bsiz, im.im_name);
  56. /* expiry */
  57. - snprintf(buf1, sizeof(buf1), "%lu",
  58. - time(NULL) + cache_entry_expiration);
  59. + snprintf(buf1, sizeof(buf1), "%" PRId64,
  60. + (int64_t)time(NULL) + cache_entry_expiration);
  61. addfield(&bp, &bsiz, buf1);
  62. /* Note that we don't want to write the id if the mapping
  63. * failed; instead, by leaving it off, we write a negative
  64. @@ -653,8 +654,8 @@ nfsdcb(int UNUSED(fd), short which, void *data)
  65. snprintf(buf1, sizeof(buf1), "%u", im.im_id);
  66. addfield(&bp, &bsiz, buf1);
  67. /* expiry */
  68. - snprintf(buf1, sizeof(buf1), "%lu",
  69. - time(NULL) + cache_entry_expiration);
  70. + snprintf(buf1, sizeof(buf1), "%" PRId64,
  71. + (int64_t)time(NULL) + cache_entry_expiration);
  72. addfield(&bp, &bsiz, buf1);
  73. /* Note we're ignoring the status field in this case; we'll
  74. * just map to nobody instead. */
  75. --
  76. 2.20.1