MCPcopy Create free account
hub / github.com/ceph/ceph / _getcwd

Method _getcwd

src/client/Client.cc:13463–13503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13461}
13462
13463int 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
13505int Client::getcwd(string& dir, const UserPerm& perms)
13506{

Callers

nothing calls this directly

Calls 9

get_first_parentMethod · 0.80
set_inodeMethod · 0.80
push_front_dentryMethod · 0.80
filepathClass · 0.70
make_requestFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45
set_filepathMethod · 0.45
get_pathMethod · 0.45

Tested by

no test coverage detected