tout(cct) << new_gid << std::endl;
tout(cct) << flags << std::endl;
- filepath path(relpath);
InodeRef in;
InodeRef dirinode;
return r;
}
- r = path_walk(path, &in, perms, !(flags & AT_SYMLINK_NOFOLLOW), 0, dirinode);
- if (r < 0) {
- return r;
+ if (!strcmp(relpath, "")) {
+#if defined(__linux__) && defined(AT_EMPTY_PATH)
+ if (flags & AT_EMPTY_PATH) {
+ in = dirinode;
+ goto out;
+ }
+#endif
+ return -CEPHFS_ENOENT;
+ } else {
+ filepath path(relpath);
+ r = path_walk(path, &in, perms, !(flags & AT_SYMLINK_NOFOLLOW), 0, dirinode);
+ if (r < 0) {
+ return r;
+ }
}
+
+out:
+
struct stat attr;
attr.st_uid = new_uid;
attr.st_gid = new_gid;
* @param relpath the relpath of the file/directory to change the ownership of.
* @param uid the user id to set on the file/directory.
* @param gid the group id to set on the file/directory.
- * @param flags bitfield that can be used to set AT_* modifier flags (AT_SYMLINK_NOFOLLOW)
+ * @param flags bitfield that can be used to set AT_* modifier flags (AT_SYMLINK_NOFOLLOW and AT_EMPTY_PATH)
* @returns 0 on success or negative error code on failure.
*/
int ceph_chownat(struct ceph_mount_info *cmount, int dirfd, const char *relpath,
// change ownership to nobody -- we assume nobody exists and id is always 65534
ASSERT_EQ(ceph_conf_set(cmount, "client_permissions", "0"), 0);
ASSERT_EQ(ceph_chownat(cmount, fd, rel_file_path, 65534, 65534, 0), 0);
+ // change relative fd ownership with AT_EMPTY_PATH
+#if defined(__linux__) && defined(AT_EMPTY_PATH)
+ int file_fd = ceph_openat(cmount, fd, rel_file_path, O_RDONLY, 0);
+ ASSERT_LE(0, file_fd);
+ ASSERT_EQ(ceph_chownat(cmount, file_fd, "", 65534, 65534, AT_EMPTY_PATH), 0);
+ ceph_close(cmount, file_fd);
+#endif
ASSERT_EQ(ceph_conf_set(cmount, "client_permissions", "1"), 0);
ceph_close(cmount, fd);