// not written yet, but i want to link!
-int Client::chdir(const char *relpath, std::string &new_cwd)
+int Client::chdir(const char *relpath, std::string &new_cwd,
+ const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
tout(cct) << "chdir" << std::endl;
tout(cct) << relpath << std::endl;
filepath path(relpath);
InodeRef in;
- int r = path_walk(path, &in);
+ int r = path_walk(path, &in, perms);
if (r < 0)
return r;
if (cwd != in)
cwd.swap(in);
ldout(cct, 3) << "chdir(" << relpath << ") cwd now " << cwd->ino << dendl;
- getcwd(new_cwd);
+ getcwd(new_cwd, perms);
return 0;
}
-void Client::getcwd(string& dir)
+void Client::getcwd(string& dir, const UserPerm& perms)
{
filepath path;
ldout(cct, 10) << "getcwd " << *cwd << dendl;
filepath path(in->ino);
req->set_filepath(path);
req->set_inode(in);
- UserPerm perms(get_uid(), get_gid()); // FIXME
int res = make_request(req, perms);
if (res < 0)
break;
int statfs(const char *path, struct statvfs *stbuf);
// crap
- int chdir(const char *s, std::string &new_cwd);
- void getcwd(std::string& cwd);
+ int chdir(const char *s, std::string &new_cwd, const UserPerm& perms);
+ void getcwd(std::string& cwd, const UserPerm& perms);
// namespace ops
int opendir(const char *name, dir_result_t **dirpp, const UserPerm& perms);
// Client users should remember their path, but since this
// is just a synthetic client we ignore it.
std::string ignore;
- client->chdir(a, ignore);
+ client->chdir(a, ignore, perms);
} else if (strcmp(op, "statfs") == 0) {
struct statvfs stbuf;
client->statfs("/", &stbuf);
return client;
}
- const char *get_cwd()
+ const char *get_cwd(const UserPerm& perms)
{
- client->getcwd(cwd);
+ client->getcwd(cwd, perms);
return cwd.c_str();
}
- int chdir(const char *to)
+ int chdir(const char *to, const UserPerm& perms)
{
- return client->chdir(to, cwd);
+ return client->chdir(to, cwd, perms);
}
CephContext *get_ceph_context() const {
extern "C" const char* ceph_getcwd(struct ceph_mount_info *cmount)
{
- return cmount->get_cwd();
+ UserPerm perms = cmount->get_client()->pick_my_perms();
+ return cmount->get_cwd(perms);
}
extern "C" int ceph_chdir (struct ceph_mount_info *cmount, const char *s)
{
if (!cmount->is_mounted())
return -ENOTCONN;
- return cmount->chdir(s);
+ UserPerm perms = cmount->get_client()->pick_my_perms();
+ return cmount->chdir(s, perms);
}
extern "C" int ceph_opendir(struct ceph_mount_info *cmount,