Project

General

Profile

Bug #4920 ยป 20150127_4920_fixv2_and_unittest.patch

Radoslaw Zarzynski, 01/27/2015 01:56 PM

View differences:

src/client/Client.cc
filepath path(relpath);
Inode *in;
bool created = false;
int r = path_walk(path, &in);
/* O_CREATE with O_EXCL enforces O_NOFOLLOW. */
bool is_nofollow = (flags & O_NOFOLLOW) || ((flags & O_CREAT) && (flags & O_EXCL));
int r = path_walk(path, &in, !is_nofollow);
if (r == 0 && (flags & O_CREAT) && (flags & O_EXCL))
return -EEXIST;
if (r == 0 && in->is_symlink() && (flags & O_NOFOLLOW))
return -ELOOP;
if (r == -ENOENT && (flags & O_CREAT)) {
filepath dirpath = path;
string dname = dirpath.last_dentry();
src/test/libcephfs/test.cc
ASSERT_EQ(ceph_symlink(cmount, test_file, test_symlink), 0);
// test the O_NOFOLLOW case
fd = ceph_open(cmount, test_symlink, O_NOFOLLOW, 0);
ASSERT_EQ(fd, -ELOOP);
// stat the original file
struct stat stbuf_orig;
ASSERT_EQ(ceph_stat(cmount, test_file, &stbuf_orig), 0);
    (1-1/1)