summaryrefslogtreecommitdiffstats
path: root/src/test/libcephfs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2016-10-12 13:04:42 +0200
committerJeff Layton <jlayton@redhat.com>2016-10-12 13:04:42 +0200
commit209e2918139d86e3edc476cb1b12a907bc29bfcc (patch)
tree5b8371345de4f20e4a59783fdbb90db2c6f8ce56 /src/test/libcephfs
parentclient: fix caps handling when calling _ll_getattr (diff)
downloadceph-209e2918139d86e3edc476cb1b12a907bc29bfcc.tar.xz
ceph-209e2918139d86e3edc476cb1b12a907bc29bfcc.zip
client: convert some ceph_stat and ceph_lstat calls to ceph_statx
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'src/test/libcephfs')
-rw-r--r--src/test/libcephfs/acl.cc16
-rw-r--r--src/test/libcephfs/caps.cc4
-rw-r--r--src/test/libcephfs/test.cc73
3 files changed, 46 insertions, 47 deletions
diff --git a/src/test/libcephfs/acl.cc b/src/test/libcephfs/acl.cc
index 54c978d1fb2..3ed57bf3e28 100644
--- a/src/test/libcephfs/acl.cc
+++ b/src/test/libcephfs/acl.cc
@@ -251,11 +251,11 @@ TEST(ACL, DefaultACL) {
// mode and ACL are updated
ASSERT_EQ(ceph_getxattr(cmount, test_dir2, ACL_EA_ACCESS, acl2_buf, acl_buf_size), acl_buf_size);
{
- struct stat stbuf;
- ASSERT_EQ(ceph_stat(cmount, test_dir2, &stbuf), 0);
+ struct ceph_statx stx;
+ ASSERT_EQ(ceph_statx(cmount, test_dir2, &stx, CEPH_STATX_MODE, 0), 0);
// other bits of mode &= acl other perm
- ASSERT_EQ(stbuf.st_mode & 0777, 0750u);
- ASSERT_EQ(check_acl_and_mode(acl2_buf, acl_buf_size, stbuf.st_mode), 0);
+ ASSERT_EQ(stx.stx_mode & 0777u, 0750u);
+ ASSERT_EQ(check_acl_and_mode(acl2_buf, acl_buf_size, stx.stx_mode), 0);
}
char test_file1[256];
@@ -269,11 +269,11 @@ TEST(ACL, DefaultACL) {
// mode and ACL are updated
ASSERT_EQ(ceph_fgetxattr(cmount, fd, ACL_EA_ACCESS, acl2_buf, acl_buf_size), acl_buf_size);
{
- struct stat stbuf;
- ASSERT_EQ(ceph_stat(cmount, test_file1, &stbuf), 0);
+ struct ceph_statx stx;
+ ASSERT_EQ(ceph_statx(cmount, test_file1, &stx, CEPH_STATX_MODE, 0), 0);
// other bits of mode &= acl other perm
- ASSERT_EQ(stbuf.st_mode & 0777, 0660u);
- ASSERT_EQ(check_acl_and_mode(acl2_buf, acl_buf_size, stbuf.st_mode), 0);
+ ASSERT_EQ(stx.stx_mode & 0777u, 0660u);
+ ASSERT_EQ(check_acl_and_mode(acl2_buf, acl_buf_size, stx.stx_mode), 0);
}
free(acl1_buf);
diff --git a/src/test/libcephfs/caps.cc b/src/test/libcephfs/caps.cc
index 33844243027..4af9b418d2e 100644
--- a/src/test/libcephfs/caps.cc
+++ b/src/test/libcephfs/caps.cc
@@ -60,8 +60,8 @@ TEST(Caps, ReadZero) {
ASSERT_EQ(0, ceph_close(cmount, wfd));
- struct stat st;
- ASSERT_EQ(0, ceph_stat(cmount, c_path, &st));
+ struct ceph_statx stx;
+ ASSERT_EQ(0, ceph_statx(cmount, c_path, &stx, CEPH_STATX_MTIME, 0));
caps = ceph_debug_get_file_caps(cmount, c_path);
ASSERT_EQ(expect, caps & expect);
diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc
index ab277b59d8c..2de3336f11c 100644
--- a/src/test/libcephfs/test.cc
+++ b/src/test/libcephfs/test.cc
@@ -272,13 +272,13 @@ TEST(LibCephFS, DirLs) {
ASSERT_EQ(ceph_opendir(cmount, foostr, &ls_dir), -ENOENT);
ASSERT_EQ(ceph_mkdir(cmount, foostr, 0777), 0);
- struct stat stbuf;
- ASSERT_EQ(ceph_stat(cmount, foostr, &stbuf), 0);
- ASSERT_NE(S_ISDIR(stbuf.st_mode), 0);
+ struct ceph_statx stx;
+ ASSERT_EQ(ceph_statx(cmount, foostr, &stx, 0, 0), 0);
+ ASSERT_NE(S_ISDIR(stx.stx_mode), 0);
char barstr[256];
sprintf(barstr, "dir_ls2%d", mypid);
- ASSERT_EQ(ceph_lstat(cmount, barstr, &stbuf), -ENOENT);
+ ASSERT_EQ(ceph_statx(cmount, barstr, &stx, 0, AT_SYMLINK_NOFOLLOW), -ENOENT);
// insert files into directory and test open
char bazstr[256];
@@ -598,9 +598,9 @@ TEST(LibCephFS, LstatSlashdot) {
ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
ASSERT_EQ(ceph_mount(cmount, NULL), 0);
- struct stat stbuf;
- ASSERT_EQ(ceph_lstat(cmount, "/.", &stbuf), 0);
- ASSERT_EQ(ceph_lstat(cmount, ".", &stbuf), 0);
+ struct ceph_statx stx;
+ ASSERT_EQ(ceph_statx(cmount, "/.", &stx, 0, AT_SYMLINK_NOFOLLOW), 0);
+ ASSERT_EQ(ceph_statx(cmount, ".", &stx, 0, AT_SYMLINK_NOFOLLOW), 0);
ceph_shutdown(cmount);
}
@@ -648,9 +648,9 @@ TEST(LibCephFS, DoubleChmod) {
ASSERT_EQ(ceph_chmod(cmount, test_file, 0600), 0);
// ensure perms are correct
- struct stat stbuf;
- ASSERT_EQ(ceph_lstat(cmount, test_file, &stbuf), 0);
- ASSERT_EQ(stbuf.st_mode, 0100600U);
+ struct ceph_statx stx;
+ ASSERT_EQ(ceph_statx(cmount, test_file, &stx, CEPH_STATX_MODE, AT_SYMLINK_NOFOLLOW), 0);
+ ASSERT_EQ(stx.stx_mode, 0100600U);
fd = ceph_open(cmount, test_file, O_RDWR, 0);
ASSERT_GT(fd, 0);
@@ -803,13 +803,13 @@ TEST(LibCephFS, Symlinks) {
ASSERT_EQ(fd, -ELOOP);
// stat the original file
- struct stat stbuf_orig;
- ASSERT_EQ(ceph_stat(cmount, test_file, &stbuf_orig), 0);
+ struct ceph_statx stx_orig;
+ ASSERT_EQ(ceph_statx(cmount, test_file, &stx_orig, CEPH_STATX_ALL_STATS, 0), 0);
// stat the symlink
- struct stat stbuf_symlink_orig;
- ASSERT_EQ(ceph_stat(cmount, test_symlink, &stbuf_symlink_orig), 0);
- // ensure the stat bufs are equal
- ASSERT_TRUE(!memcmp(&stbuf_orig, &stbuf_symlink_orig, sizeof(stbuf_orig)));
+ struct ceph_statx stx_symlink_orig;
+ ASSERT_EQ(ceph_statx(cmount, test_symlink, &stx_symlink_orig, CEPH_STATX_ALL_STATS, 0), 0);
+ // ensure the statx bufs are equal
+ ASSERT_EQ(memcmp(&stx_orig, &stx_symlink_orig, sizeof(stx_orig)), 0);
sprintf(test_file, "/test_symlinks_abs_%d", getpid());
@@ -823,16 +823,15 @@ TEST(LibCephFS, Symlinks) {
ASSERT_EQ(ceph_symlink(cmount, test_file, test_symlink), 0);
// stat the original file
- ASSERT_EQ(ceph_stat(cmount, test_file, &stbuf_orig), 0);
+ ASSERT_EQ(ceph_statx(cmount, test_file, &stx_orig, CEPH_STATX_ALL_STATS, 0), 0);
// stat the symlink
- ASSERT_EQ(ceph_stat(cmount, test_symlink, &stbuf_symlink_orig), 0);
- // ensure the stat bufs are equal
- ASSERT_TRUE(!memcmp(&stbuf_orig, &stbuf_symlink_orig, sizeof(stbuf_orig)));
+ ASSERT_EQ(ceph_statx(cmount, test_symlink, &stx_symlink_orig, CEPH_STATX_ALL_STATS, 0), 0);
+ // ensure the statx bufs are equal
+ ASSERT_TRUE(!memcmp(&stx_orig, &stx_symlink_orig, sizeof(stx_orig)));
// test lstat
- struct stat stbuf_symlink;
- ASSERT_EQ(ceph_lstat(cmount, test_symlink, &stbuf_symlink), 0);
- ASSERT_TRUE(S_ISLNK(stbuf_symlink.st_mode));
+ ASSERT_EQ(ceph_statx(cmount, test_symlink, &stx_orig, CEPH_STATX_ALL_STATS, AT_SYMLINK_NOFOLLOW), 0);
+ ASSERT_TRUE(S_ISLNK(stx_orig.stx_mode));
ceph_shutdown(cmount);
}
@@ -860,11 +859,11 @@ TEST(LibCephFS, DirSyms) {
ASSERT_GT(fd, 0);
ceph_close(cmount, fd);
- struct stat stbuf;
- ASSERT_EQ(ceph_lstat(cmount, test_file, &stbuf), 0);
+ struct ceph_statx stx;
+ ASSERT_EQ(ceph_statx(cmount, test_file, &stx, 0, AT_SYMLINK_NOFOLLOW), 0);
// ensure that its a file not a directory we get back
- ASSERT_TRUE(S_ISREG(stbuf.st_mode));
+ ASSERT_TRUE(S_ISREG(stx.stx_mode));
ceph_shutdown(cmount);
}
@@ -1099,11 +1098,11 @@ TEST(LibCephFS, Rename) {
ASSERT_EQ(0, ceph_rename(cmount, path_src, path_dst));
/* test that dest path exists */
- struct stat st;
- ASSERT_EQ(0, ceph_lstat(cmount, path_dst, &st));
+ struct ceph_statx stx;
+ ASSERT_EQ(0, ceph_statx(cmount, path_dst, &stx, 0, 0));
/* test that src path doesn't exist */
- ASSERT_EQ(-ENOENT, ceph_lstat(cmount, path_src, &st));
+ ASSERT_EQ(-ENOENT, ceph_statx(cmount, path_src, &stx, 0, AT_SYMLINK_NOFOLLOW));
/* rename with non-existent source path */
ASSERT_EQ(-ENOENT, ceph_rename(cmount, path_src, path_dst));
@@ -1134,6 +1133,7 @@ TEST(LibCephFS, UseUnmounted) {
EXPECT_EQ(-ENOTCONN, ceph_readdir_r(cmount, dirp, &rdent));
int stmask;
+ struct ceph_statx stx;
struct stat st;
EXPECT_EQ(-ENOTCONN, ceph_readdirplus_r(cmount, dirp, &rdent, &st, &stmask));
EXPECT_EQ(-ENOTCONN, ceph_getdents(cmount, dirp, NULL, 0));
@@ -1147,8 +1147,7 @@ TEST(LibCephFS, UseUnmounted) {
EXPECT_EQ(-ENOTCONN, ceph_rmdir(cmount, "/path"));
EXPECT_EQ(-ENOTCONN, ceph_readlink(cmount, "/path", NULL, 0));
EXPECT_EQ(-ENOTCONN, ceph_symlink(cmount, "/path", "/path"));
- EXPECT_EQ(-ENOTCONN, ceph_stat(cmount, "/path", &st));
- EXPECT_EQ(-ENOTCONN, ceph_lstat(cmount, "/path", &st));
+ EXPECT_EQ(-ENOTCONN, ceph_statx(cmount, "/path", &stx, 0, 0));
EXPECT_EQ(-ENOTCONN, ceph_setattr(cmount, "/path", &st, 0));
EXPECT_EQ(-ENOTCONN, ceph_getxattr(cmount, "/path", "name", NULL, 0));
EXPECT_EQ(-ENOTCONN, ceph_lgetxattr(cmount, "/path", "name", NULL, 0));
@@ -1417,14 +1416,14 @@ TEST(LibCephFS, SlashDotDot) {
ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
ASSERT_EQ(ceph_mount(cmount, "/"), 0);
- struct stat st;
- ASSERT_EQ(ceph_stat(cmount, "/.", &st), 0);
+ struct ceph_statx stx;
+ ASSERT_EQ(ceph_statx(cmount, "/.", &stx, CEPH_STATX_INO, 0), 0);
- ino_t ino = st.st_ino;
- ASSERT_EQ(ceph_stat(cmount, "/..", &st), 0);
+ ino_t ino = stx.stx_ino;
+ ASSERT_EQ(ceph_statx(cmount, "/..", &stx, CEPH_STATX_INO, 0), 0);
/* At root, "." and ".." should be the same inode */
- ASSERT_EQ(ino, st.st_ino);
+ ASSERT_EQ(ino, stx.stx_ino);
/* Test accessing the parent of an unlinked directory */
char dir1[32], dir2[32];
@@ -1453,7 +1452,7 @@ TEST(LibCephFS, SlashDotDot) {
/* Make sure it works same way when mounting subtree */
ASSERT_EQ(ceph_unmount(cmount), 0);
ASSERT_EQ(ceph_mount(cmount, dir1), 0);
- ASSERT_EQ(ceph_stat(cmount, "/..", &st), 0);
+ ASSERT_EQ(ceph_statx(cmount, "/..", &stx, CEPH_STATX_INO, 0), 0);
/* Test readdir behavior */
ASSERT_EQ(ceph_opendir(cmount, "/", &rdir), 0);