Page MenuHomeFreeBSD
Authored By
fsu
Jan 10 2019, 5:22 PM
Size
983 B
Referenced Files
None
Subscribers
None

test_xattr.c

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/xattr.h>
void test_assert(int x, int line) {
if (!x) {
printf("test_assert => FAILED. Line:%d, errno = %d\n", line, errno);
exit(1);
}
}
/*
* Before the fix:
* root@:~ # ./exec
* test_assert => FAILED. Line:28, errno = 61
*
* After the fix:
* root@:~ # ./exec
*/
int main() {
const char *path = "//tmp/test.file";
int fd = open(path, O_RDONLY | O_CREAT);
if(fd < 0) {
printf("Cannot create file => %d\n", errno);
exit(1);
}
close(fd);
ssize_t ret = listxattr(path, NULL, 0);
test_assert(errno == ENOTSUP, __LINE__);
ret = getxattr(path, "user.key", NULL, 0);
test_assert(errno == ENOTSUP, __LINE__);
ret = setxattr(path, "user.key", "value", sizeof("value"), XATTR_CREATE);
test_assert(errno == ENOTSUP, __LINE__);
ret = removexattr(path, "user.key");
test_assert(errno == ENOTSUP, __LINE__);
return 0;
}

File Metadata

Mime Type
text/x-c
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1709314
Default Alt Text
test_xattr.c (983 B)

Event Timeline