]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: convert ceph_ll_rename and ceph_ll_unlink to UserPerm
authorJeff Layton <jlayton@redhat.com>
Mon, 24 Oct 2016 14:03:00 +0000 (10:03 -0400)
committerJeff Layton <jlayton@redhat.com>
Tue, 25 Oct 2016 17:06:29 +0000 (13:06 -0400)
Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/include/cephfs/libcephfs.h
src/libcephfs.cc
src/test/libcephfs/recordlock.cc
src/test/libcephfs/test.cc

index 746c5c797006ce43ae54744c05752a014565a737..5d5f8a06861840f62fd64f8013d24672ffe4f479 100644 (file)
@@ -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,
index 664fb809fd8e24779a5e87f12bf6ef46fc7fd92f..97cfc6b551d2e7b7f9fefabf2ef29ae21b5b40fe 100644 (file)
@@ -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,
index 8ba1cb5bf011d2ccf5dddedaee0f533a9827e584..7f852ef3f4694379103331f51cb9d37f6a0f2332 100644 (file)
@@ -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();
 }
index 385ac98d7a12fd2c6572502ce98b77415bf2f793..bcadc73d3f4d4cda7d87d496774706674165cf61 100644 (file)
@@ -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);