]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
support: Add support_path_support_time64_value
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 19 Mar 2021 16:44:20 +0000 (13:44 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 29 Mar 2021 13:22:13 +0000 (10:22 -0300)
It allows to check for support on arbitrary timestamp values.

support/support.h
support/support_path_support_time64.c

index 90f3ff9d1a1c43bc1479aa3b18e3b38763ac22a7..b0352726bf670900fca888bc6ca8350453e12595 100644 (file)
@@ -130,9 +130,16 @@ extern void support_copy_file (const char *from, const char *to);
 extern ssize_t support_copy_file_range (int, off64_t *, int, off64_t *,
                                        size_t, unsigned int);
 
-/* Return true is PATH supports 64-bit time_t interfaces for file
+/* Return true if PATH supports 64-bit time_t interfaces for file
    operations (such as fstatat or utimensat).  */
-extern bool support_path_support_time64 (const char *path);
+extern bool support_path_support_time64_value (const char *path, int64_t at,
+                                              int64_t mt);
+static __inline bool support_path_support_time64 (const char *path)
+{
+  /* 1s and 2s after y2038 limit.  */
+  return support_path_support_time64_value (path, 0x80000001ULL,
+                                           0x80000002ULL);
+}
 
 /* Return true if stat supports nanoseconds resolution.  */
 extern bool support_stat_nanoseconds (void);
index 452fedcde521e29496a104d15d3098b7458676e8..33b2bdff6686a24fe6b9aac36f423f93fd44524c 100644 (file)
@@ -36,19 +36,15 @@ utimesat_call (const char *path, const struct __timespec64 tsp[2])
 #endif
 
 bool
-support_path_support_time64 (const char *path)
+support_path_support_time64_value (const char *path, int64_t at, int64_t mt)
 {
 #ifdef __linux__
   /* Obtain the original timestamps to restore at the end.  */
   struct statx ostx;
   TEST_VERIFY_EXIT (statx (AT_FDCWD, path, 0, STATX_BASIC_STATS, &ostx) == 0);
 
-  const struct __timespec64 tsp[] =
-  {
-    /* 1s and 2s after y2038 limit.  */
-    { 0x80000001ULL, 0 },
-    { 0x80000002ULL, 0 }
-  };
+  const struct __timespec64 tsp[] = { { at, 0 }, { mt, 0 } };
+
   /* Return is kernel does not support __NR_utimensat_time64.  */
   if (utimesat_call (path, tsp) == -1)
     return false;