(long unsigned)in->snap_btime.nsec());
}
+size_t Client::_vxattrcb_caps(Inode *in, char *val, size_t size)
+{
+ int issued;
+
+ in->caps_issued(&issued);
+ return snprintf(val, size, "%s/0x%x", ccap_string(issued).c_str(), issued);
+}
+
bool Client::_vxattrcb_mirror_info_exists(Inode *in)
{
// checking one of the xattrs would suffice
exists_cb: &Client::_vxattrcb_mirror_info_exists,
flags: 0,
},
+ {
+ name: "ceph.caps",
+ getxattr_cb: &Client::_vxattrcb_caps,
+ readonly: true,
+ exists_cb: NULL,
+ flags: 0,
+ },
{ name: "" } /* Required table terminator */
};
exists_cb: &Client::_vxattrcb_snap_btime_exists,
flags: 0,
},
+ {
+ name: "ceph.caps",
+ getxattr_cb: &Client::_vxattrcb_caps,
+ readonly: true,
+ exists_cb: NULL,
+ flags: 0,
+ },
{ name: "" } /* Required table terminator */
};
bool _vxattrcb_snap_btime_exists(Inode *in);
size_t _vxattrcb_snap_btime(Inode *in, char *val, size_t size);
+ size_t _vxattrcb_caps(Inode *in, char *val, size_t size);
+
bool _vxattrcb_mirror_info_exists(Inode *in);
size_t _vxattrcb_mirror_info(Inode *in, char *val, size_t size);
#include <map>
#include <vector>
#include <thread>
+#include <regex>
#ifndef ALLPERMS
#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
ceph_shutdown(cmount);
}
+TEST(LibCephFS, Caps_vxattr) {
+ struct ceph_mount_info *cmount;
+ ASSERT_EQ(ceph_create(&cmount, NULL), 0);
+ ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0);
+ ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
+ ASSERT_EQ(ceph_mount(cmount, NULL), 0);
+
+ char test_caps_vxattr_file[256];
+ char gxattrv[128];
+ int xbuflen = sizeof(gxattrv);
+ pid_t mypid = getpid();
+
+ sprintf(test_caps_vxattr_file, "test_caps_vxattr_%d", mypid);
+ int fd = ceph_open(cmount, test_caps_vxattr_file, O_CREAT, 0666);
+ ASSERT_GT(fd, 0);
+ ceph_close(cmount, fd);
+
+ int alen = ceph_getxattr(cmount, test_caps_vxattr_file, "ceph.caps", (void *)gxattrv, xbuflen);
+ ASSERT_GT(alen, 0);
+ gxattrv[alen] = '\0';
+
+ char caps_regex[] = "pA[sx]*L[sx]*X[sx]*F[sxcrwbal]*/0x[0-9a-fA-f]+";
+ ASSERT_TRUE(regex_match(gxattrv, regex(caps_regex)) == 1);
+ ceph_shutdown(cmount);
+}
+
TEST(LibCephFS, SnapXattrs) {
struct ceph_mount_info *cmount;
ASSERT_EQ(ceph_create(&cmount, NULL), 0);