| 16360 | } |
| 16361 | |
| 16362 | int Client::_unlink(Inode *dir, const char *name, const UserPerm& perm) |
| 16363 | { |
| 16364 | ldout(cct, 8) << "_unlink(" << dir->ino << " " << name |
| 16365 | << " uid " << perm.uid() << " gid " << perm.gid() |
| 16366 | << ")" << dendl; |
| 16367 | |
| 16368 | walk_dentry_result wdr; |
| 16369 | if (int rc = path_walk(dir, filepath(name), &wdr, perm, {.followsym = false}); rc < 0) { |
| 16370 | return rc; |
| 16371 | } |
| 16372 | |
| 16373 | if (should_check_perms()) { |
| 16374 | if (int rc = may_delete(wdr, perm); rc < 0) { |
| 16375 | return rc; |
| 16376 | } |
| 16377 | } |
| 16378 | |
| 16379 | if (wdr.diri->snapid != CEPH_NOSNAP) { |
| 16380 | return -EROFS; |
| 16381 | } |
| 16382 | |
| 16383 | MetaRequest *req = new MetaRequest(CEPH_MDS_OP_UNLINK); |
| 16384 | |
| 16385 | req->set_filepath(wdr.getpath()); |
| 16386 | req->set_dentry(wdr.dn); |
| 16387 | req->dentry_drop = CEPH_CAP_FILE_SHARED; |
| 16388 | req->dentry_unless = CEPH_CAP_FILE_EXCL; |
| 16389 | |
| 16390 | auto& in = wdr.target; |
| 16391 | req->set_other_inode(in); |
| 16392 | in->break_all_delegs(); |
| 16393 | req->other_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; |
| 16394 | |
| 16395 | req->set_inode(wdr.diri); |
| 16396 | |
| 16397 | int res = make_request(req, perm); |
| 16398 | |
| 16399 | trim_cache(); |
| 16400 | ldout(cct, 8) << "unlink(" << wdr.getpath() << ") = " << res << dendl; |
| 16401 | return res; |
| 16402 | } |
| 16403 | |
| 16404 | int Client::ll_unlink(Inode *in, const char *name, const UserPerm& perm) |
| 16405 | { |
nothing calls this directly
no test coverage detected