如何在 linux (UNIX) 中仅更改最后(创建 | 修改 | 访问)时间之一?

问题描述 投票:0回答:1

前几天,我搜索并询问了一些关于文件不同时间戳的问题。

现在我知道,我可以通过

creation time
获取
statx(2)
并通过
only
last (status change | modification | access) time
命令/实用程序更改
touch -m
文件的
debugfs
之一,而无需更改其他时间。

我想知道,如何更改每个

last (status change | modification | access) time
而不更改其他时间
only by system call
而不是通过任何命令/实用程序。如果不可能,这些命令/实用程序如何做到这一点?

我知道

Criticism of atime.

谢谢

c linux libc
1个回答
0
投票

该作业的 POSIX 函数是

futimens()
及其近亲
futimensat()

#include <sys/stat.h>

int futimens(int fd, const struct timespec times[2]);

特别是,它们支持特殊时间值

UTIME_OMIT
来指示“不要更改此时间字段”。

© www.soinside.com 2019 - 2024. All rights reserved.