return r;
}
+int Client::may_delete(const char *relpath, const UserPerm& perms) {
+ ldout(cct, 20) << __func__ << " " << relpath << "; " << perms << dendl;
+
+ RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
+ if (!mref_reader.is_state_satisfied())
+ return -ENOTCONN;
+
+ filepath path(relpath);
+ string name = path.last_dentry();
+ path.pop_dentry();
+ InodeRef dir;
+
+ std::scoped_lock lock(client_lock);
+ int r = path_walk(path, &dir, perms);
+ if (r < 0)
+ return r;
+ if (cct->_conf->client_permissions) {
+ int r = may_delete(dir.get(), name.c_str(), perms);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;
+}
+
int Client::may_hardlink(Inode *in, const UserPerm& perms)
{
ldout(cct, 20) << __func__ << " " << *in << "; " << perms << dendl;
loff_t telldir(dir_result_t *dirp);
void seekdir(dir_result_t *dirp, loff_t offset);
+ int may_delete(const char *relpath, const UserPerm& perms);
int link(const char *existing, const char *newname, const UserPerm& perm, std::string alternate_name="");
int unlink(const char *path, const UserPerm& perm);
int rename(const char *from, const char *to, const UserPerm& perm, std::string alternate_name="");
* @{
*/
+
+/**
+ * Checks if deleting a file, link or directory is allowed.
+ *
+ * @param cmount the ceph mount handle to use.
+ * @param path the path of the file, link or directory.
+ * @returns 0 on success or negative error code on failure.
+ */
+int ceph_may_delete(struct ceph_mount_info *cmount, const char *path);
+
/**
* Removes a file, link, or symbolic link. If the file/link has multiple links to it, the
* file will not disappear from the namespace until all references to it are removed.
cmount->get_client()->seekdir(reinterpret_cast<dir_result_t*>(dirp), offset);
}
+extern "C" int ceph_may_delete(struct ceph_mount_info *cmount, const char *path)
+{
+ if (!cmount->is_mounted())
+ return -ENOTCONN;
+ return cmount->get_client()->may_delete(path, cmount->default_perms);
+}
+
extern "C" int ceph_link (struct ceph_mount_info *cmount, const char *existing,
const char *newname)
{