【发布时间】:2021-05-05 05:13:25
【问题描述】:
我正在测试将时间戳添加到 xattr 的简单程序。 lsetxattr 系统调用返回 EPERM 错误。这是预期的行为吗? 如何将 xattr 设置为符号链接,而不是点击链接?
#include <sys/types.h>
#include <attr/xattr.h>
#include <errno.h>
#include <time.h>
#include <stdio.h>
int main(int argc, char **argv){
time_t t = time(NULL);
if(lsetxattr(argv[1], "user.ts", &t, sizeof(time_t), 0) == -1){
perror(argv[1]);
}
return(0);
}
示例:
> ls -l a b c
-rw-r--r-- 1 saka users 0 Feb 1 09:08 a
-rw-r--r-- 1 saka users 0 Feb 1 09:08 b
lrwxrwxrwx 1 saka users 1 Feb 1 09:08 c -> b
> ./ts a
> ./ts c
c: Operation not permitted
我在 3.10.0-862.14.4.el7.x86_64 上使用 xfs 或 ext3 进行了测试。
【问题讨论】:
标签: c linux filesystems system-calls