return _fsync(dirp->inode.get(), false);
}
-int Client::ll_open(Inode *in, int flags, Fh **fhp, int uid, int gid)
+int Client::ll_open(Inode *in, int flags, Fh **fhp, const UserPerm& perms)
{
assert(!(flags & O_CREAT));
tout(cct) << flags << std::endl;
int r;
- if (uid < 0) {
- uid = get_uid();
- gid = get_gid();
- }
if (!cct->_conf->fuse_default_permissions) {
- r = may_open(in, flags, uid, gid);
+ r = may_open(in, flags, perms);
if (r < 0)
goto out;
}
- r = _open(in, flags, 0, fhp /* may be NULL */, uid, gid);
+ r = _open(in, flags, 0, fhp /* may be NULL */, perms);
out:
Fh *fhptr = fhp ? *fhp : NULL;
int Client::ll_create(Inode *parent, const char *name, mode_t mode,
int flags, struct stat *attr, Inode **outp, Fh **fhp,
- int uid, int gid)
+ const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
vinodeno_t vparent = _get_vino(parent);
ldout(cct, 3) << "ll_create " << vparent << " " << name << " 0" << oct <<
- mode << dec << " " << flags << ", uid " << uid << ", gid " << gid << dendl;
+ mode << dec << " " << flags << ", uid " << perms.uid()
+ << ", gid " << perms.gid() << dendl;
tout(cct) << "ll_create" << std::endl;
tout(cct) << vparent.ino.val << std::endl;
tout(cct) << name << std::endl;
bool created = false;
InodeRef in;
- int r = _lookup(parent, name, CEPH_STAT_CAP_INODE_ALL, &in, uid, gid);
+ int r = _lookup(parent, name, CEPH_STAT_CAP_INODE_ALL, &in, perms);
if (r == 0 && (flags & O_CREAT) && (flags & O_EXCL))
return -EEXIST;
if (r == -ENOENT && (flags & O_CREAT)) {
if (!cct->_conf->fuse_default_permissions) {
- r = may_create(parent, uid, gid);
+ r = may_create(parent, perms);
if (r < 0)
goto out;
}
r = _create(parent, name, flags, mode, &in, fhp /* may be NULL */,
- 0, 0, 0, NULL, &created, uid, gid);
+ 0, 0, 0, NULL, &created, perms);
if (r < 0)
goto out;
}
ldout(cct, 20) << "ll_create created = " << created << dendl;
if (!created) {
if (!cct->_conf->fuse_default_permissions) {
- r = may_open(in.get(), flags, uid, gid);
+ r = may_open(in.get(), flags, perms);
if (r < 0) {
if (fhp && *fhp) {
int release_r = _release_fh(*fhp);
}
}
if (fhp && (*fhp == NULL)) {
- r = _open(in.get(), flags, mode, fhp, uid, gid);
+ r = _open(in.get(), flags, mode, fhp, perms);
if (r < 0)
goto out;
}
const char *newname, const UserPerm& perm);
int ll_link(Inode *in, Inode *newparent, const char *newname,
struct stat *attr, const UserPerm& perm);
- int ll_open(Inode *in, int flags, Fh **fh, int uid = -1, int gid = -1);
+ int ll_open(Inode *in, int flags, Fh **fh, const UserPerm& perms);
int ll_create(Inode *parent, const char *name, mode_t mode, int flags,
- struct stat *attr, Inode **out, Fh **fhp, int uid = -1,
- int gid = -1);
+ struct stat *attr, Inode **out, Fh **fhp,
+ const UserPerm& perms);
int ll_read_block(Inode *in, uint64_t blockid, char *buf, uint64_t offset,
uint64_t length, file_layout_t* layout);
Fh *fhp;
if (ll_inos.count(i)) {
i1 = client->ll_get_inode(vinodeno_t(ll_inos[i],CEPH_NOSNAP));
- if (client->ll_open(i1, f, &fhp) == 0)
+ if (client->ll_open(i1, f, &fhp, perms) == 0)
ll_files[r] = fhp;
client->ll_put(i1);
}
if (ll_inos.count(i)) {
Fh *fhp;
i1 = client->ll_get_inode(vinodeno_t(ll_inos[i],CEPH_NOSNAP));
- if (client->ll_create(i1, n, m, f, &attr, NULL, &fhp) == 0) {
+ if (client->ll_create(i1, n, m, f, &attr, NULL, &fhp, perms) == 0) {
ll_inos[ri] = attr.st_ino;
ll_files[r] = fhp;
}
const struct fuse_ctx *ctx = fuse_req_ctx(req);
Inode *in = cfuse->iget(ino);
Fh *fh = NULL;
+ UserPerm perms(ctx->uid, ctx->gid);
- int r = cfuse->client->ll_open(in, fi->flags, &fh, ctx->uid, ctx->gid);
+ int r = cfuse->client->ll_open(in, fi->flags, &fh, perms);
if (r == 0) {
fi->fh = (uint64_t)fh;
#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8)
Inode *i1 = cfuse->iget(parent), *i2;
struct fuse_entry_param fe;
Fh *fh = NULL;
+ UserPerm perms(ctx->uid, ctx->gid);
memset(&fe, 0, sizeof(fe));
// pass &i2 for the created inode so that ll_create takes an initial ll_ref
int r = cfuse->client->ll_create(i1, name, mode, fi->flags, &fe.attr, &i2,
- &fh, ctx->uid, ctx->gid);
+ &fh, perms);
if (r == 0) {
fi->fh = (uint64_t)fh;
fe.ino = cfuse->make_fake_ino(fe.attr.st_ino, fe.attr.st_dev);
extern "C" int ceph_ll_open(class ceph_mount_info *cmount, Inode *in,
int flags, Fh **fh, int uid, int gid)
{
- return (cmount->get_client()->ll_open(in, flags, fh, uid, gid));
+ UserPerm perms(uid, gid);
+ return (cmount->get_client()->ll_open(in, flags, fh, perms));
}
extern "C" int ceph_ll_read(class ceph_mount_info *cmount, Fh* filehandle,
mode_t mode, int flags, struct stat *attr,
struct Inode **out, Fh **fhp, int uid, int gid)
{
+ UserPerm perms(uid, gid);
return (cmount->get_client())->ll_create(parent, name, mode, flags,
- attr, out, fhp, uid, gid);
+ attr, out, fhp, perms);
}
extern "C" int ceph_ll_mknod(class ceph_mount_info *cmount,