[4/5] support: Add support_path_support_time64_value
Commit Message
It allows to check for support on arbitrary timestamp values.
---
support/support.h | 11 +++++++++--
support/support_path_support_time64.c | 10 +++-------
2 files changed, 12 insertions(+), 9 deletions(-)
Comments
On 19/03/2021 19:31, Adhemerval Zanella via Libc-alpha wrote:
> It allows to check for support on arbitrary timestamp values.
> ---
> support/support.h | 11 +++++++++--
> support/support_path_support_time64.c | 10 +++-------
> 2 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/support/support.h b/support/support.h
> index 2e477c9e7c..5757c40833 100644
> --- a/support/support.h
> +++ b/support/support.h
> @@ -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);
> +}
>
> __END_DECLS
>
> diff --git a/support/support_path_support_time64.c b/support/support_path_support_time64.c
> index 452fedcde5..33b2bdff66 100644
> --- a/support/support_path_support_time64.c
> +++ b/support/support_path_support_time64.c
> @@ -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;
>
OK
@@ -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);
+}
__END_DECLS
@@ -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;