| 13461 | } |
| 13462 | |
| 13463 | int Client::_getcwd(string& dir, const UserPerm& perms) |
| 13464 | { |
| 13465 | filepath path; |
| 13466 | ldout(cct, 10) << __func__ << " " << *cwd << dendl; |
| 13467 | |
| 13468 | auto in = cwd; |
| 13469 | while (in != root) { |
| 13470 | ceph_assert(in->dentries.size() < 2); // dirs can't be hard-linked |
| 13471 | |
| 13472 | // A cwd or ancester is unlinked |
| 13473 | if (in->dentries.empty()) { |
| 13474 | return -ENOENT; |
| 13475 | } |
| 13476 | |
| 13477 | Dentry *dn = in->get_first_parent(); |
| 13478 | |
| 13479 | if (!dn) { |
| 13480 | // look it up |
| 13481 | ldout(cct, 10) << __func__ << " looking up parent for " << *in << dendl; |
| 13482 | MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPNAME); |
| 13483 | req->set_filepath(filepath(in->ino)); |
| 13484 | req->set_inode(in); |
| 13485 | int res = make_request(req, perms); |
| 13486 | if (res < 0) |
| 13487 | break; |
| 13488 | |
| 13489 | // start over |
| 13490 | path = filepath(); |
| 13491 | in = cwd; |
| 13492 | continue; |
| 13493 | } |
| 13494 | auto* diri = dn->dir->parent_inode; |
| 13495 | ceph_assert(diri); |
| 13496 | auto dname = _unwrap_name(*diri, dn->name, dn->alternate_name); |
| 13497 | path.push_front_dentry(dname); |
| 13498 | in = InodeRef(diri); |
| 13499 | } |
| 13500 | dir = "/"; |
| 13501 | dir += path.get_path(); |
| 13502 | return 0; |
| 13503 | } |
| 13504 | |
| 13505 | int Client::getcwd(string& dir, const UserPerm& perms) |
| 13506 | { |
nothing calls this directly
no test coverage detected