callback_setxattr (const char *path, const char *name, const char *value,
size_t size, int flags)
{
- return -ENOTSUP;
+ PATH_WRITE_ENTRYPOINT (path);
+
+ char buf[PATH_MAX];
+ snprintf (buf, sizeof (buf), "/proc/self/fd/%d/%s", basefd, path);
+
+ if (setxattr (buf, name, value, size, flags) == -1)
+ return -errno;
+ return 0;
}
static int
callback_getxattr (const char *path, const char *name, char *value,
size_t size)
{
- return -ENOTSUP;
+ path = ENSURE_RELPATH (path);
+
+ char buf[PATH_MAX];
+ snprintf (buf, sizeof (buf), "/proc/self/fd/%d/%s", basefd, path);
+
+ ssize_t n = getxattr (buf, name, value, size);
+ if (n == -1)
+ return -errno;
+ return n;
}
/*
static int
callback_listxattr (const char *path, char *list, size_t size)
{
- return -ENOTSUP;
+ path = ENSURE_RELPATH (path);
+ char buf[PATH_MAX];
+ snprintf (buf, sizeof (buf), "/proc/self/fd/%d/%s", basefd, path);
+
+ ssize_t n = llistxattr (buf, list, size);
+ if (n == -1)
+ return -errno;
+ return n;
}
/*
static int
callback_removexattr (const char *path, const char *name)
{
- return -ENOTSUP;
+ path = ENSURE_RELPATH (path);
+
+ char buf[PATH_MAX];
+ snprintf (buf, sizeof (buf), "/proc/self/fd/%d/%s", basefd, path);
+ if (lremovexattr (buf, name) == -1)
+ return -errno;
+ return 0;
}
struct fuse_operations callback_oper = {
setup_test_repository "bare"
-echo "1..11"
+echo "1..12"
cd ${test_tmpdir}
mkdir mnt
assert_file_has_content err.txt "chown:.*Read-only file system"
echo "ok failed mutation chmod + chown"
+if setfattr -n user.foo -v bar mnt/firstfile-link; then
+ assert_not_reached "set xattr on linked file"
+fi
+
# Test creating new files, using chown + chmod on them as well
echo anewfile-for-fuse > mnt/anewfile-for-fuse
assert_file_has_content mnt/anewfile-for-fuse anewfile-for-fuse
chown $(id -u) mnt/newfusedir/test-morenewfuse.${i}
done
assert_file_has_content checkout-test2/newfusedir/test-morenewfuse.3 3-morenewfuse-3
+
echo "ok new content"
+setfattr -n user.foo -v bar mnt/anewfile-for-fuse
+getfattr -d -m . mnt/anewfile-for-fuse > out.txt
+assert_file_has_content_literal out.txt 'user.foo="bar"'
+echo "ok new xattrs"
+
rm mnt/baz/cow
assert_not_has_file checkout-test2/baz/cow
rm mnt/baz/another -rf
assert_not_streq "${firstfile_orig_inode}" "${firstfile_new_inode}"
assert_test_file -f checkout-test2/firstfile
+# Test xattr modifications
+copyup_reset
+firstfile_orig_inode=$(stat -c %i checkout-test2/firstfile)
+setfattr -n user.foo -v bar mnt/firstfile
+getfattr -d -m . mnt/firstfile > out.txt
+assert_file_has_content_literal out.txt 'user.foo="bar"'
+firstfile_new_inode=$(stat -c %i checkout-test2/firstfile)
+assert_not_streq "${firstfile_orig_inode}" "${firstfile_new_inode}"
+assert_test_file -f checkout-test2/firstfile
+
copyup_reset
firstfile_link_orig_inode=$(stat -c %i checkout-test2/firstfile-link)
firstfile_orig_inode=$(stat -c %i checkout-test2/firstfile)