Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/client/dfuse/pil4dfs/int_dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -5859,8 +5859,10 @@ utimens_timespec(const char *path, const struct timespec times[2], int flags)
int
utimensat(int dirfd, const char *path, const struct timespec times[2], int flags)
{
int idx_dfs, error = 0, rc;
char *full_path = NULL;
int idx_dfs, error = 0, rc;
char *full_path = NULL;
struct timespec times_loc[2];
struct timespec *times_ptr;

if (next_utimensat == NULL) {
next_utimensat = dlsym(RTLD_NEXT, "utimensat");
Expand All @@ -5878,18 +5880,30 @@ utimensat(int dirfd, const char *path, const struct timespec times[2], int flags
}
_Pragma("GCC diagnostic pop")

/* clang-format off */

if (times == NULL) {
clock_gettime(CLOCK_REALTIME, &times_loc[0]);
times_loc[1].tv_sec = times_loc[0].tv_sec;
times_loc[1].tv_nsec = times_loc[0].tv_nsec;
times_ptr = times_loc;
} else {
times_ptr = (struct timespec *)times;
}
/* clang-format on */

/* absolute path, dirfd is ignored */
if (path[0] == '/')
return utimens_timespec(path, times, flags);
return utimens_timespec(path, times_ptr, flags);

idx_dfs = check_path_with_dirfd(dirfd, &full_path, path, &error);
if (error)
goto out_err;

if (idx_dfs >= 0)
rc = utimens_timespec(full_path, times, flags);
rc = utimens_timespec(full_path, times_ptr, flags);
else
rc = next_utimensat(dirfd, path, times, flags);
rc = next_utimensat(dirfd, path, times_ptr, flags);

error = errno;
if (full_path) {
Expand Down
10 changes: 10 additions & 0 deletions src/tests/suite/dfuse_test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* (C) Copyright 2021-2024 Intel Corporation.
* (C) Copyright 2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -516,6 +517,15 @@ do_mtime(void **state)
rc = close(fd);
assert_return_code(rc, errno);

usleep(10000);
prev_ts.tv_sec = stbuf.st_mtim.tv_sec;
prev_ts.tv_nsec = stbuf.st_mtim.tv_nsec;
rc = utimensat(root, "mtime_file", NULL, 0);
assert_return_code(rc, errno);
rc = fstatat(root, "mtime_file", &stbuf, 0);
assert_return_code(rc, errno);
assert_true(timespec_gt(stbuf.st_mtim, prev_ts));

rc = unlinkat(root, "mtime_file", 0);
assert_return_code(rc, errno);

Expand Down
Loading