<< " got_ino " << got_created_ino
<< " ino " << created_ino
<< dendl;
- r = _do_lookup(d->dir->parent_inode, d->name, &target);
+ r = _do_lookup(d->dir->parent_inode, d->name, &target, uid, gid);
} else {
// if the dentry is not linked, just do our best. see #5021.
assert(0 == "how did this happen? i want logs!");
// ===============================================================
// high level (POSIXy) interface
-int Client::_do_lookup(Inode *dir, const string& name, InodeRef *target)
+int Client::_do_lookup(Inode *dir, const string& name, InodeRef *target,
+ int uid, int gid)
{
int op = dir->snapid == CEPH_SNAPDIR ? CEPH_MDS_OP_LOOKUPSNAP : CEPH_MDS_OP_LOOKUP;
MetaRequest *req = new MetaRequest(op);
req->head.args.getattr.mask = 0;
ldout(cct, 10) << "_do_lookup on " << path << dendl;
- int r = make_request(req, 0, 0, target);
+ int r = make_request(req, uid, gid, target);
ldout(cct, 10) << "_do_lookup res is " << r << dendl;
return r;
}
-int Client::_lookup(Inode *dir, const string& dname, InodeRef *target)
+int Client::_lookup(Inode *dir, const string& dname, InodeRef *target,
+ int uid, int gid)
{
int r = 0;
Dentry *dn = NULL;
}
}
- r = _do_lookup(dir, dname, target);
+ r = _do_lookup(dir, dname, target, uid, gid);
goto done;
hit_dn:
return 0;
}
-int Client::path_walk(const filepath& origpath, InodeRef *end, bool followsym)
+int Client::path_walk(const filepath& origpath, InodeRef *end, bool followsym,
+ int uid, int gid)
{
filepath path = origpath;
InodeRef cur;
ldout(cct, 10) << " " << i << " " << *cur << " " << dname << dendl;
ldout(cct, 20) << " (path is " << path << ")" << dendl;
InodeRef next;
- int r = _lookup(cur.get(), dname, &next);
+ int r = _lookup(cur.get(), dname, &next, uid, gid);
if (r < 0)
return r;
// only follow trailing symlink if followsym. always follow
return _mkdir(dir.get(), name.c_str(), mode);
}
-int Client::mkdirs(const char *relpath, mode_t mode)
+int Client::mkdirs(const char *relpath, mode_t mode, int uid, int gid)
{
Mutex::Locker lock(client_lock);
ldout(cct, 10) << "Client::mkdirs " << relpath << dendl;
InodeRef cur, next;
cur = cwd;
for (i=0; i<path.depth(); ++i) {
- r=_lookup(cur.get(), path[i].c_str(), &next);
- if (r < 0) break;
+ r = _lookup(cur.get(), path[i].c_str(), &next, uid, gid);
+ if (r < 0)
+ break;
cur.swap(next);
}
//check that we have work left to do
r = _mkdir(cur.get(), path[i].c_str(), mode);
//check proper creation/existence
if (r < 0) return r;
- r = _lookup(cur.get(), path[i], &next);
- if(r < 0) {
+ r = _lookup(cur.get(), path[i], &next, uid, gid);
+ if (r < 0) {
ldout(cct, 0) << "mkdirs: successfully created new directory " << path[i]
<< " but can't _lookup it!" << dendl;
return r;
InodeRef in;
int r = 0;
- r = _lookup(parent, dname, &in);
+ r = _lookup(parent, dname, &in, uid, gid);
if (r < 0) {
attr->st_ino = 0;
goto out;
req->dentry_drop = CEPH_CAP_FILE_SHARED;
req->dentry_unless = CEPH_CAP_FILE_EXCL;
- res = _lookup(dir, name, &otherin);
+ res = _lookup(dir, name, &otherin, uid, gid);
if (res < 0)
goto fail;
req->set_other_inode(otherin.get());
int res = get_or_create(dir, name, &de);
if (res < 0)
goto fail;
- res = _lookup(dir, name, &in);
+ res = _lookup(dir, name, &in, uid, gid);
if (res < 0)
goto fail;
if (req->get_op() == CEPH_MDS_OP_RMDIR) {
req->dentry_unless = CEPH_CAP_FILE_EXCL;
InodeRef oldin, otherin;
- res = _lookup(fromdir, fromname, &oldin);
+ res = _lookup(fromdir, fromname, &oldin, uid, gid);
if (res < 0)
goto fail;
req->set_old_inode(oldin.get());
req->old_inode_drop = CEPH_CAP_LINK_SHARED;
- res = _lookup(todir, toname, &otherin);
+ res = _lookup(todir, toname, &otherin, uid, gid);
if (res != 0 && res != -ENOENT) {
goto fail;
} else if (res == 0) {
bool created = false;
InodeRef in;
- int r = _lookup(parent, name, &in);
+ int r = _lookup(parent, name, &in, uid, gid);
if (r == 0 && (flags & O_CREAT) && (flags & O_EXCL))
return -EEXIST;
// path traversal for high-level interface
InodeRef cwd;
- int path_walk(const filepath& fp, InodeRef *end, bool followsym=true);
+ int path_walk(const filepath& fp, InodeRef *end, bool followsym=true,
+ int uid=-1, int gid=-1);
int fill_stat(Inode *in, struct stat *st, frag_info_t *dirstat=0, nest_info_t *rstat=0);
int fill_stat(InodeRef& in, struct stat *st, frag_info_t *dirstat=0, nest_info_t *rstat=0) {
return fill_stat(in.get(), st, dirstat, rstat);
// internal interface
// call these with client_lock held!
- int _do_lookup(Inode *dir, const string& name, InodeRef *target);
- int _lookup(Inode *dir, const string& dname, InodeRef *target);
+ int _do_lookup(Inode *dir, const string& name, InodeRef *target, int uid, int gid);
+ int _lookup(Inode *dir, const string& dname, InodeRef *target, int uid, int gid);
int _link(Inode *in, Inode *dir, const char *name, int uid=-1, int gid=-1, InodeRef *inp = 0);
int _unlink(Inode *dir, const char *name, int uid=-1, int gid=-1);
// dirs
int mkdir(const char *path, mode_t mode);
- int mkdirs(const char *path, mode_t mode);
+ int mkdirs(const char *path, mode_t mode, int uid=-1, int gid=-1);
int rmdir(const char *path);
// symlinks