From: Jeff Layton Date: Mon, 24 Oct 2016 14:03:00 +0000 (-0400) Subject: client: change ceph_ll_mkdir to ceph_statx and UserPerm args X-Git-Tag: v11.1.0~383^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f6148de0b6d95fe1c110c0f5c0b2de1ae5ef1cc7;p=ceph.git client: change ceph_ll_mkdir to ceph_statx and UserPerm args Signed-off-by: Jeff Layton --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 33cf900add9e..c8db94bef4e7 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -11119,6 +11119,42 @@ int Client::ll_mkdir(Inode *parent, const char *name, mode_t mode, return r; } +int Client::ll_mkdirx(Inode *parent, const char *name, mode_t mode, Inode **out, + struct ceph_statx *stx, unsigned want, unsigned flags, + const UserPerm& perms) +{ + Mutex::Locker lock(client_lock); + + vinodeno_t vparent = _get_vino(parent); + + ldout(cct, 3) << "ll_mkdirx " << vparent << " " << name << dendl; + tout(cct) << "ll_mkdirx" << std::endl; + tout(cct) << vparent.ino.val << std::endl; + tout(cct) << name << std::endl; + tout(cct) << mode << std::endl; + + if (!cct->_conf->fuse_default_permissions) { + int r = may_create(parent, perms); + if (r < 0) + return r; + } + + InodeRef in; + int r = _mkdir(parent, name, mode, perms, &in); + if (r == 0) { + fill_statx(in, statx_to_mask(flags, want), stx); + _ll_get(in.get()); + } else { + stx->stx_ino = 0; + stx->stx_mask = 0; + } + tout(cct) << stx->stx_ino << std::endl; + ldout(cct, 3) << "ll_mkdirx " << vparent << " " << name + << " = " << r << " (" << hex << stx->stx_ino << dec << ")" << dendl; + *out = in.get(); + return r; +} + int Client::_symlink(Inode *dir, const char *name, const char *target, const UserPerm& perms, InodeRef *inp) { diff --git a/src/client/Client.h b/src/client/Client.h index 9cc0679f7909..91badbfc45de 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1144,6 +1144,9 @@ public: unsigned flags, const UserPerm& perms); int ll_mkdir(Inode *in, const char *name, mode_t mode, struct stat *attr, Inode **out, const UserPerm& perm); + int ll_mkdirx(Inode *parent, const char *name, mode_t mode, Inode **out, + struct ceph_statx *stx, unsigned want, unsigned flags, + const UserPerm& perms); int ll_symlink(Inode *in, const char *name, const char *value, struct stat *attr, Inode **out, const UserPerm& perms); int ll_unlink(Inode *in, const char *name, const UserPerm& perm); diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index 191d83e9acba..286973ff661f 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -1485,9 +1485,10 @@ int ceph_ll_mknod(struct ceph_mount_info *cmount, Inode *parent, const char *name, mode_t mode, dev_t rdev, Inode **out, struct ceph_statx *stx, unsigned want, unsigned flags, const UserPerm *perms); -int ceph_ll_mkdir(struct ceph_mount_info *cmount, struct Inode *parent, - const char *name, mode_t mode, struct stat *attr, - Inode **out, int uid, int gid); +int ceph_ll_mkdir(struct ceph_mount_info *cmount, Inode *parent, + const char *name, mode_t mode, Inode **out, + struct ceph_statx *stx, unsigned want, + unsigned flags, const UserPerm *perms); int ceph_ll_link(struct ceph_mount_info *cmount, struct Inode *in, struct Inode *newparrent, const char *name, struct stat *attr, int uid, int gid); diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 79ced12d3687..b565065756be 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -1557,13 +1557,13 @@ extern "C" int ceph_ll_mknod(class ceph_mount_info *cmount, Inode *parent, out, stx, want, flags, *perms); } -extern "C" int ceph_ll_mkdir(class ceph_mount_info *cmount, - Inode *parent, const char *name, - mode_t mode, struct stat *attr, Inode **out, - int uid, int gid) +extern "C" int ceph_ll_mkdir(class ceph_mount_info *cmount, Inode *parent, + const char *name, mode_t mode, Inode **out, + struct ceph_statx *stx, unsigned want, + unsigned flags, const UserPerm *perms) { - UserPerm perms(uid, gid); - return (cmount->get_client()->ll_mkdir(parent, name, mode, attr, out, perms)); + return cmount->get_client()->ll_mkdirx(parent, name, mode, out, stx, want, + flags, *perms); } extern "C" int ceph_ll_link(class ceph_mount_info *cmount, diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index edbccf207341..54164e31a634 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -1401,7 +1401,7 @@ TEST(LibCephFS, Nlink) { Fh *fh; UserPerm *perms = ceph_mount_perms(cmount); - ASSERT_EQ(ceph_ll_mkdir(cmount, root, dirname, 0755, &st, &dir, getuid(), getgid()), 0); + ASSERT_EQ(ceph_ll_mkdir(cmount, root, dirname, 0755, &dir, &stx, 0, 0, perms), 0); ASSERT_EQ(ceph_ll_create(cmount, dir, filename, 0666, O_RDWR|O_CREAT|O_EXCL, &file, &fh, &stx, CEPH_STATX_NLINK, 0, perms), 0); ASSERT_EQ(stx.stx_nlink, (nlink_t)1);