]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/test/libcephfs/access.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / test / libcephfs / access.cc
index 7338739fa9566082b9d64cc08ecca43b1b30a16e..57b1a89faa131035eda812daf6f95d72922f4fd2 100644 (file)
@@ -17,6 +17,7 @@
 #include "include/buffer.h"
 #include "include/stringify.h"
 #include "include/cephfs/libcephfs.h"
+#include "include/fs_types.h"
 #include "include/rados/librados.h"
 #include <errno.h>
 #include <fcntl.h>
@@ -29,6 +30,8 @@
 #include <vector>
 #include "json_spirit/json_spirit.h"
 
+#include "include/fs_types.h"
+
 #ifdef __linux__
 #include <limits.h>
 #include <sys/xattr.h>
@@ -61,7 +64,7 @@ int do_mon_command(string s, string *key)
     std::cout << "key: " << *key << std::endl;
     free(outbuf);
   } else {
-    return -EINVAL;
+    return -CEPHFS_EINVAL;
   }
   if (outs_len) {
     string s(outs, outs_len);
@@ -180,9 +183,9 @@ TEST(AccessTest, Path) {
   ASSERT_EQ(ceph_rename(admin, string(good + "/renameme").c_str(),
                        string(bad + "/asdf").c_str()), 0);
   ASSERT_GE(ceph_write(cmount, fd, "foo", 3, 0), 0);
-  ASSERT_GE(ceph_fchmod(cmount, fd, 0777), -EACCES);
-  ASSERT_GE(ceph_ftruncate(cmount, fd, 0), -EACCES);
-  ASSERT_GE(ceph_fsetxattr(cmount, fd, "user.any", "bar", 3, 0), -EACCES);
+  ASSERT_GE(ceph_fchmod(cmount, fd, 0777), -CEPHFS_EACCES);
+  ASSERT_GE(ceph_ftruncate(cmount, fd, 0), -CEPHFS_EACCES);
+  ASSERT_GE(ceph_fsetxattr(cmount, fd, "user.any", "bar", 3, 0), -CEPHFS_EACCES);
   ceph_close(cmount, fd);
 
   ceph_shutdown(cmount);
@@ -265,7 +268,7 @@ TEST(AccessTest, User) {
   ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL));
   ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
   ASSERT_EQ(0, ceph_conf_set(cmount, "key", key.c_str()));
-  ASSERT_EQ(-EACCES, ceph_mount(cmount, "/"));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_mount(cmount, "/"));
   ASSERT_EQ(0, ceph_init(cmount));
 
   UserPerm *perms = ceph_userperm_new(123, 456, 0, NULL);
@@ -281,35 +284,35 @@ TEST(AccessTest, User) {
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 123, 456));
   ASSERT_EQ(0, ceph_mkdir(cmount, string(dir + "/u1").c_str(), 0755));
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 1, 456));
-  ASSERT_EQ(-EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
 
   // group bits
   ASSERT_EQ(0, ceph_chmod(admin, dir.c_str(), 0770));
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 1, 456));
   ASSERT_EQ(0, ceph_mkdir(cmount, string(dir + "/u2").c_str(), 0755));
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 1, 2));
-  ASSERT_EQ(-EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
 
   // user overrides group
   ASSERT_EQ(0, ceph_chmod(admin, dir.c_str(), 0470));
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 123, 456));
-  ASSERT_EQ(-EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
 
   // other
   ASSERT_EQ(0, ceph_chmod(admin, dir.c_str(), 0777));
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 1, 1));
   ASSERT_EQ(0, ceph_mkdir(cmount, string(dir + "/u3").c_str(), 0755));
   ASSERT_EQ(0, ceph_chmod(admin, dir.c_str(), 0770));
-  ASSERT_EQ(-EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
 
   // user and group overrides other
   ASSERT_EQ(0, ceph_chmod(admin, dir.c_str(), 07));
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 1, 456));
-  ASSERT_EQ(-EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 123, 1));
-  ASSERT_EQ(-EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 123, 456));
-  ASSERT_EQ(-EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_mkdir(cmount, string(dir + "/no").c_str(), 0755));
 
   // chown and chgrp
   ASSERT_EQ(0, ceph_chmod(admin, dir.c_str(), 0700));
@@ -319,18 +322,18 @@ TEST(AccessTest, User) {
   ASSERT_EQ(0, ceph_chown(cmount, dir.c_str(), 123, 456));
   // ASSERT_EQ(0, ceph_chown(cmount, dir.c_str(), -1, 789));
   ASSERT_EQ(0, ceph_chown(cmount, dir.c_str(), -1, 456));
-  ASSERT_EQ(-EACCES, ceph_chown(cmount, dir.c_str(), 123, 1));
-  ASSERT_EQ(-EACCES, ceph_chown(cmount, dir.c_str(), 1, 456));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_chown(cmount, dir.c_str(), 123, 1));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_chown(cmount, dir.c_str(), 1, 456));
 
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 1, 1));
-  ASSERT_EQ(-EACCES, ceph_chown(cmount, dir.c_str(), 123, 456));
-  ASSERT_EQ(-EACCES, ceph_chown(cmount, dir.c_str(), 123, -1));
-  ASSERT_EQ(-EACCES, ceph_chown(cmount, dir.c_str(), -1, 456));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_chown(cmount, dir.c_str(), 123, 456));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_chown(cmount, dir.c_str(), 123, -1));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_chown(cmount, dir.c_str(), -1, 456));
 
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 1, 456));
-  ASSERT_EQ(-EACCES, ceph_chown(cmount, dir.c_str(), 123, 456));
-  ASSERT_EQ(-EACCES, ceph_chown(cmount, dir.c_str(), 123, -1));
-  ASSERT_EQ(-EACCES, ceph_chown(cmount, dir.c_str(), -1, 456));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_chown(cmount, dir.c_str(), 123, 456));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_chown(cmount, dir.c_str(), 123, -1));
+  ASSERT_EQ(-CEPHFS_EACCES, ceph_chown(cmount, dir.c_str(), -1, 456));
 
   ASSERT_EQ(0, ceph_chown(admin, dir.c_str(), 123, 1));
   ASSERT_EQ(0, ceph_chown(cmount, dir.c_str(), -1, 456));