diff options
author | Michal Jarzabek <stiopa@gmail.com> | 2017-01-12 22:22:20 +0100 |
---|---|---|
committer | Michal Jarzabek <stiopa@gmail.com> | 2017-01-12 22:31:09 +0100 |
commit | 6ed7f2364ae5507bab14c60b582929aa7b0ba400 (patch) | |
tree | 2ae9e37111afdf319084e34237ade8abb724dd7a /src/test/libcephfs/test.cc | |
parent | Merge pull request #12458 from Liuchang0812/add-more-log-for-network-error (diff) | |
download | ceph-6ed7f2364ae5507bab14c60b582929aa7b0ba400.tar.xz ceph-6ed7f2364ae5507bab14c60b582929aa7b0ba400.zip |
client/Client.cc: prevent segfaulting
The segfaulting in the rmdir function is caused by calling
filepath::last_dentry() function.
last_dentry() function assumes that the bits vector has always at
least one element, which is not the case for the the filepath object
created with "/" input.
This commit also fixes other functions affected by this bug:
link, unlink, rename, mkdir, mknod and symlink.
Fixes: http://tracker.ceph.com/issues/9935
Signed-off-by: Michal Jarzabek <stiopa@gmail.com>
Diffstat (limited to 'src/test/libcephfs/test.cc')
-rw-r--r-- | src/test/libcephfs/test.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index 5f43f4ce2e8..baea14fcf35 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -1739,3 +1739,41 @@ TEST(LibCephFS, ClearSetuid) { ceph_shutdown(cmount); } + +TEST(LibCephFS, OperationsOnRoot) +{ + struct ceph_mount_info *cmount; + ASSERT_EQ(ceph_create(&cmount, NULL), 0); + ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0); + ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL)); + ASSERT_EQ(ceph_mount(cmount, "/"), 0); + + char dirname[32]; + sprintf(dirname, "/somedir%x", getpid()); + + ASSERT_EQ(ceph_mkdir(cmount, dirname, 0755), 0); + + ASSERT_EQ(ceph_rmdir(cmount, "/"), -EBUSY); + + ASSERT_EQ(ceph_link(cmount, "/", "/"), -EEXIST); + ASSERT_EQ(ceph_link(cmount, dirname, "/"), -EEXIST); + ASSERT_EQ(ceph_link(cmount, "nonExisitingDir", "/"), -ENOENT); + + ASSERT_EQ(ceph_unlink(cmount, "/"), -EISDIR); + + ASSERT_EQ(ceph_rename(cmount, "/", "/"), -EBUSY); + ASSERT_EQ(ceph_rename(cmount, dirname, "/"), -EBUSY); + ASSERT_EQ(ceph_rename(cmount, "nonExistingDir", "/"), -EBUSY); + ASSERT_EQ(ceph_rename(cmount, "/", dirname), -EBUSY); + ASSERT_EQ(ceph_rename(cmount, "/", "nonExistingDir"), -EBUSY); + + ASSERT_EQ(ceph_mkdir(cmount, "/", 0777), -EEXIST); + + ASSERT_EQ(ceph_mknod(cmount, "/", 0, 0), -EEXIST); + + ASSERT_EQ(ceph_symlink(cmount, "/", "/"), -EEXIST); + ASSERT_EQ(ceph_symlink(cmount, dirname, "/"), -EEXIST); + ASSERT_EQ(ceph_symlink(cmount, "nonExistingDir", "/"), -EEXIST); + + ceph_shutdown(cmount); +} |