From: Jeff Layton Date: Mon, 24 Oct 2016 14:03:00 +0000 (-0400) Subject: client: convert ceph_ll_rename and ceph_ll_unlink to UserPerm X-Git-Tag: v11.1.0~383^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1df52938024ee3e04eecd8111523537db82f0f15;p=ceph.git client: convert ceph_ll_rename and ceph_ll_unlink to UserPerm Signed-off-by: Jeff Layton --- diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index 746c5c797006..5d5f8a068618 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -1498,9 +1498,9 @@ int ceph_ll_releasedir(struct ceph_mount_info *cmount, struct ceph_dir_result* dir); int ceph_ll_rename(struct ceph_mount_info *cmount, struct Inode *parent, const char *name, struct Inode *newparent, - const char *newname, int uid, int gid); + const char *newname, const UserPerm *perms); int ceph_ll_unlink(struct ceph_mount_info *cmount, struct Inode *in, - const char *name, int uid, int gid); + const char *name, const UserPerm *perms); int ceph_ll_statfs(struct ceph_mount_info *cmount, struct Inode *in, struct statvfs *stbuf); int ceph_ll_readlink(struct ceph_mount_info *cmount, struct Inode *in, diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 664fb809fd8e..97cfc6b551d2 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -1592,19 +1592,16 @@ extern "C" int ceph_ll_releasedir(class ceph_mount_info *cmount, extern "C" int ceph_ll_rename(class ceph_mount_info *cmount, Inode *parent, const char *name, Inode *newparent, const char *newname, - int uid, int gid) + const UserPerm *perms) { - UserPerm perms(uid, gid); - return (cmount->get_client()->ll_rename(parent, name, - newparent, newname, perms)); + return cmount->get_client()->ll_rename(parent, name, newparent, + newname, *perms); } -extern "C" int ceph_ll_unlink(class ceph_mount_info *cmount, - Inode *in, const char *name, - int uid, int gid) +extern "C" int ceph_ll_unlink(class ceph_mount_info *cmount, Inode *in, + const char *name, const UserPerm *perms) { - UserPerm perms(uid, gid); - return (cmount->get_client()->ll_unlink(in, name, perms)); + return cmount->get_client()->ll_unlink(in, name, *perms); } extern "C" int ceph_ll_statfs(class ceph_mount_info *cmount, diff --git a/src/test/libcephfs/recordlock.cc b/src/test/libcephfs/recordlock.cc index 8ba1cb5bf011..7f852ef3f469 100644 --- a/src/test/libcephfs/recordlock.cc +++ b/src/test/libcephfs/recordlock.cc @@ -83,6 +83,7 @@ TEST(LibCephFS, BasicRecordLocking) { struct ceph_statx stx; int rc; struct flock lock1, lock2; + UserPerm *perms = ceph_mount_perms(cmount); // Get the root inode rc = ceph_ll_lookup_root(cmount, &root); @@ -90,7 +91,7 @@ TEST(LibCephFS, BasicRecordLocking) { // Get the inode and Fh corresponding to c_file rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT, - &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount)); + &inode, &fh, &stx, 0, 0, perms); ASSERT_EQ(rc, 0); // write lock twice @@ -228,7 +229,7 @@ TEST(LibCephFS, BasicRecordLocking) { ASSERT_EQ(lock2.l_pid, getpid()); ASSERT_EQ(0, ceph_ll_close(cmount, fh)); - ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, 0, 0)); + ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, perms)); CLEANUP_CEPH(); } @@ -376,6 +377,7 @@ TEST(LibCephFS, ConcurrentRecordLocking) { struct ceph_statx stx; struct flock lock1; int rc; + UserPerm *perms = ceph_mount_perms(cmount); // Get the root inode rc = ceph_ll_lookup_root(cmount, &root); @@ -383,7 +385,7 @@ TEST(LibCephFS, ConcurrentRecordLocking) { // Get the inode and Fh corresponding to c_file rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT, - &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount)); + &inode, &fh, &stx, 0, 0, perms); ASSERT_EQ(rc, 0); // Lock @@ -502,7 +504,7 @@ TEST(LibCephFS, ConcurrentRecordLocking) { ASSERT_EQ(NULL, retval); s.sem_destroy(); ASSERT_EQ(0, ceph_ll_close(cmount, fh)); - ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, 0, 0)); + ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, perms)); CLEANUP_CEPH(); } @@ -518,6 +520,7 @@ TEST(LibCephFS, ThreesomeRecordLocking) { struct ceph_statx stx; struct flock lock1; int rc; + UserPerm *perms = ceph_mount_perms(cmount); // Get the root inode rc = ceph_ll_lookup_root(cmount, &root); @@ -525,7 +528,7 @@ TEST(LibCephFS, ThreesomeRecordLocking) { // Get the inode and Fh corresponding to c_file rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT, - &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount)); + &inode, &fh, &stx, 0, 0, perms); ASSERT_EQ(rc, 0); // Lock @@ -648,7 +651,7 @@ TEST(LibCephFS, ThreesomeRecordLocking) { ASSERT_EQ(NULL, retval); s.sem_destroy(); ASSERT_EQ(0, ceph_ll_close(cmount, fh)); - ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, 0, 0)); + ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, perms)); CLEANUP_CEPH(); } @@ -782,6 +785,7 @@ TEST(LibCephFS, DISABLED_InterProcessRecordLocking) { struct timespec ts; struct ceph_mount_info *cmount; STARTUP_CEPH(); + UserPerm *perms = ceph_mount_perms(cmount); // Get the root inode rc = ceph_ll_lookup_root(cmount, &root); @@ -789,7 +793,7 @@ TEST(LibCephFS, DISABLED_InterProcessRecordLocking) { // Get the inode and Fh corresponding to c_file rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT, - &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount)); + &inode, &fh, &stx, 0, 0, perms); ASSERT_EQ(rc, 0); // Lock @@ -906,7 +910,7 @@ TEST(LibCephFS, DISABLED_InterProcessRecordLocking) { s.sem_destroy(); ASSERT_EQ(0, munmap(shs, sizeof(*shs))); ASSERT_EQ(0, ceph_ll_close(cmount, fh)); - ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, 0, 0)); + ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, perms)); CLEANUP_CEPH(); } @@ -956,8 +960,9 @@ TEST(LibCephFS, DISABLED_ThreesomeInterProcessRecordLocking) { ASSERT_EQ(rc, 0); // Get the inode and Fh corresponding to c_file + UserPerm *perms = ceph_mount_perms(cmount); rc = ceph_ll_create(cmount, root, c_file, fileMode, O_RDWR | O_CREAT, - &inode, &fh, &stx, 0, 0, ceph_mount_perms(cmount)); + &inode, &fh, &stx, 0, 0, perms); ASSERT_EQ(rc, 0); // Lock @@ -1077,6 +1082,6 @@ TEST(LibCephFS, DISABLED_ThreesomeInterProcessRecordLocking) { s.sem_destroy(); ASSERT_EQ(0, munmap(shs, sizeof(*shs))); ASSERT_EQ(0, ceph_ll_close(cmount, fh)); - ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, 0, 0)); + ASSERT_EQ(0, ceph_ll_unlink(cmount, root, c_file, perms)); CLEANUP_CEPH(); } diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index 385ac98d7a12..bcadc73d3f4d 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -1409,7 +1409,7 @@ TEST(LibCephFS, Nlink) { ASSERT_EQ(ceph_ll_getattr(cmount, file, &stx, CEPH_STATX_NLINK, 0, perms), 0); ASSERT_EQ(stx.stx_nlink, (nlink_t)2); - ASSERT_EQ(ceph_ll_unlink(cmount, dir, linkname, getuid(), getgid()), 0); + ASSERT_EQ(ceph_ll_unlink(cmount, dir, linkname, perms), 0); ASSERT_EQ(ceph_ll_lookup(cmount, dir, filename, &file, &stx, CEPH_STATX_NLINK, 0, perms), 0); ASSERT_EQ(stx.stx_nlink, (nlink_t)1); @@ -1571,7 +1571,7 @@ TEST(LibCephFS, LazyStatx) { UserPerm *perms2 = ceph_mount_perms(cmount2); ASSERT_EQ(ceph_ll_lookup_root(cmount1, &root1), 0); - ceph_ll_unlink(cmount1, root1, filename, getuid(), getgid()); + ceph_ll_unlink(cmount1, root1, filename, perms1); ASSERT_EQ(ceph_ll_create(cmount1, root1, filename, 0666, O_RDWR|O_CREAT|O_EXCL, &file1, &fh, &stx, 0, 0, perms1), 0);