return r;
}
-// not written yet, but i want to link!
-
-int Client::chdir(const char *relpath, std::string &new_cwd,
- const UserPerm& perms)
+int Client::chdir(const char *relpath, const UserPerm& perms)
{
RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
if (!mref_reader.is_state_satisfied())
return rc;
}
- if (!(in.get()->is_dir()))
+ if (!in->is_dir())
return -ENOTDIR;
- if (cwd != in)
- cwd.swap(in);
+ cwd = std::move(in);
+
ldout(cct, 3) << "chdir(" << relpath << ") cwd now " << cwd->ino << dendl;
- _getcwd(new_cwd, perms);
return 0;
}
-void Client::_getcwd(string& dir, const UserPerm& perms)
+int Client::_getcwd(string& dir, const UserPerm& perms)
{
filepath path;
ldout(cct, 10) << __func__ << " " << *cwd << dendl;
// A cwd or ancester is unlinked
if (in->dentries.empty()) {
- return;
+ return -ENOENT;
}
Dentry *dn = in->get_first_parent();
}
dir = "/";
dir += path.get_path();
+ return 0;
}
-void Client::getcwd(string& dir, const UserPerm& perms)
+int Client::getcwd(string& dir, const UserPerm& perms)
{
RWRef_t mref_reader(mount_state, CLIENT_MOUNTING);
if (!mref_reader.is_state_satisfied())
- return;
+ return -ENOTCONN;
std::scoped_lock l(client_lock);
-
- _getcwd(dir, perms);
+ return _getcwd(dir, perms);
}
int Client::statfs(const char *path, struct statvfs *stbuf,
// these should (more or less) mirror the actual system calls.
int statfs(const char *path, struct statvfs *stbuf, const UserPerm& perms);
- // crap
- int chdir(const char *s, std::string &new_cwd, const UserPerm& perms);
- void _getcwd(std::string& cwd, const UserPerm& perms);
- void getcwd(std::string& cwd, const UserPerm& perms);
+ int chdir(const char *path, const UserPerm& perms);
+ int _getcwd(std::string& cwd, const UserPerm& perms);
+ int getcwd(std::string& cwd, const UserPerm& perms);
// namespace ops
int opendir(const char *name, dir_result_t **dirpp, const UserPerm& perms);
const char *a = t.get_string(buf, p);
// Client users should remember their path, but since this
// is just a synthetic client we ignore it.
- std::string ignore;
- client->chdir(a, ignore, perms);
+ client->chdir(a, perms);
} else if (strcmp(op, "statfs") == 0) {
struct statvfs stbuf;
client->statfs("/", &stbuf, perms);
int chdir(const char *to, const UserPerm& perms)
{
- return client->chdir(to, cwd, perms);
+ return client->chdir(to, perms);
}
CephContext *get_ceph_context() const {