Fix issues with FUSE_ACCESS when default_permissions is disabled

This patch fixes two issues relating to FUSE_ACCESS when the
default_permissions mount option is disabled:

* VOP_ACCESS() calls with VADMIN set should never be sent to a fuse server
  in the form of FUSE_ACCESS operations. The FUSE protocol has no equivalent
  of VADMIN, so we must evaluate such things kernel-side, regardless of the
  default_permissions setting.

* The FUSE protocol only requires FUSE_ACCESS to be sent for two purposes:
  for the access(2) syscall and to check directory permissions for
  searchability during lookup. FreeBSD sends it much more frequently, due to
  differences between our VFS and Linux's, for which FUSE was designed. But
  this patch does eliminate several cases not required by the FUSE protocol:

  * for any FUSE_*XATTR operation
  * when creating a new file
  * when deleting a file
  * when setting timestamps, such as by utimensat(2).

* Additionally, when default_permissions is disabled, this patch removes one
  FUSE_GETATTR operation when deleting a file.

PR:		245689
Reported by:	MooseFS FreeBSD Team <freebsd@moosefs.pro>
Reviewed by:	cem
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24777
This commit is contained in:
Alan Somers 2020-05-22 18:11:17 +00:00
parent 1f29b46c42
commit bfcb817bcd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=361401
9 changed files with 260 additions and 97 deletions

View File

@ -158,6 +158,7 @@ fuse_internal_get_cached_vnode(struct mount* mp, ino_t ino, int flags,
return 0;
}
SDT_PROBE_DEFINE0(fusefs, , internal, access_vadmin);
/* Synchronously send a FUSE_ACCESS operation */
int
fuse_internal_access(struct vnode *vp,
@ -210,10 +211,18 @@ fuse_internal_access(struct vnode *vp,
va.va_gid, mode, cred, NULL);
}
if (mode & VADMIN) {
/*
* The FUSE protocol doesn't have an equivalent of VADMIN, so
* it's a bug if we ever reach this point with that bit set.
*/
SDT_PROBE0(fusefs, , internal, access_vadmin);
}
if (!fsess_isimpl(mp, FUSE_ACCESS))
return 0;
if ((mode & (VWRITE | VAPPEND | VADMIN)) != 0)
if ((mode & (VWRITE | VAPPEND)) != 0)
mask |= W_OK;
if ((mode & VREAD) != 0)
mask |= R_OK;

View File

@ -235,6 +235,7 @@ fuse_extattr_check_cred(struct vnode *vp, int ns, struct ucred *cred,
{
struct mount *mp = vnode_mount(vp);
struct fuse_data *data = fuse_get_mpdata(mp);
int default_permissions = data->dataflags & FSESS_DEFAULT_PERMISSIONS;
/*
* Kernel-invoked always succeeds.
@ -248,12 +249,15 @@ fuse_extattr_check_cred(struct vnode *vp, int ns, struct ucred *cred,
*/
switch (ns) {
case EXTATTR_NAMESPACE_SYSTEM:
if (data->dataflags & FSESS_DEFAULT_PERMISSIONS) {
if (default_permissions) {
return (priv_check_cred(cred, PRIV_VFS_EXTATTR_SYSTEM));
}
/* FALLTHROUGH */
return (0);
case EXTATTR_NAMESPACE_USER:
return (fuse_internal_access(vp, accmode, td, cred));
if (default_permissions) {
return (fuse_internal_access(vp, accmode, td, cred));
}
return (0);
default:
return (EPERM);
}
@ -985,6 +989,8 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
int wantparent = flags & (LOCKPARENT | WANTPARENT);
int islastcn = flags & ISLASTCN;
struct mount *mp = vnode_mount(dvp);
struct fuse_data *data = fuse_get_mpdata(mp);
int default_permissions = data->dataflags & FSESS_DEFAULT_PERMISSIONS;
int err = 0;
int lookup_err = 0;
@ -1108,7 +1114,11 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
if (lookup_err) {
/* Entry not found */
if ((nameiop == CREATE || nameiop == RENAME) && islastcn) {
err = fuse_internal_access(dvp, VWRITE, td, cred);
if (default_permissions)
err = fuse_internal_access(dvp, VWRITE, td,
cred);
else
err = 0;
if (!err) {
/*
* Set the SAVENAME flag to hold onto the
@ -1191,7 +1201,7 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
&fvdat->entry_cache_timeout);
if ((nameiop == DELETE || nameiop == RENAME) &&
islastcn)
islastcn && default_permissions)
{
struct vattr dvattr;
@ -1828,7 +1838,11 @@ fuse_vnop_setattr(struct vop_setattr_args *ap)
if (vfs_isrdonly(mp))
return EROFS;
err = fuse_internal_access(vp, accmode, td, cred);
if (checkperm) {
err = fuse_internal_access(vp, accmode, td, cred);
} else {
err = 0;
}
if (err)
return err;
else

View File

@ -31,6 +31,9 @@
*/
extern "C" {
#include <sys/types.h>
#include <sys/extattr.h>
#include <fcntl.h>
#include <unistd.h>
}
@ -42,10 +45,33 @@ using namespace testing;
class Access: public FuseTest {
public:
virtual void SetUp() {
FuseTest::SetUp();
// Clear the default FUSE_ACCESS expectation
Mock::VerifyAndClearExpectations(m_mock);
}
void expect_lookup(const char *relpath, uint64_t ino)
{
FuseTest::expect_lookup(relpath, ino, S_IFREG | 0644, 0, 1);
}
/*
* Expect tha FUSE_ACCESS will never be called for the given inode, with any
* bits in the supplied access_mask set
*/
void expect_noaccess(uint64_t ino, mode_t access_mask)
{
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
return (in.header.opcode == FUSE_ACCESS &&
in.header.nodeid == ino &&
in.body.access.mask & access_mask);
}, Eq(true)),
_)
).Times(0);
}
};
class RofsAccess: public Access {
@ -56,6 +82,68 @@ virtual void SetUp() {
}
};
/*
* Change the mode of a file.
*
* There should never be a FUSE_ACCESS sent for this operation, except for
* search permissions on the parent directory.
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245689
*/
TEST_F(Access, chmod)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
const uint64_t ino = 42;
const mode_t newmode = 0644;
expect_access(FUSE_ROOT_ID, X_OK, 0);
expect_lookup(RELPATH, ino);
expect_noaccess(ino, 0);
EXPECT_CALL(*m_mock, process(
ResultOf([](auto in) {
return (in.header.opcode == FUSE_SETATTR &&
in.header.nodeid == ino);
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnImmediate([](auto in __unused, auto& out) {
SET_OUT_HEADER_LEN(out, attr);
out.body.attr.attr.ino = ino; // Must match nodeid
out.body.attr.attr.mode = S_IFREG | newmode;
})));
EXPECT_EQ(0, chmod(FULLPATH, newmode)) << strerror(errno);
}
/*
* Create a new file
*
* There should never be a FUSE_ACCESS sent for this operation, except for
* search permissions on the parent directory.
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245689
*/
TEST_F(Access, create)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
mode_t mode = S_IFREG | 0755;
uint64_t ino = 42;
expect_access(FUSE_ROOT_ID, X_OK, 0);
expect_noaccess(FUSE_ROOT_ID, R_OK | W_OK);
EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH)
.WillOnce(Invoke(ReturnErrno(ENOENT)));
expect_noaccess(ino, 0);
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
return (in.header.opcode == FUSE_CREATE);
}, Eq(true)),
_)
).WillOnce(ReturnErrno(EPERM));
EXPECT_EQ(-1, open(FULLPATH, O_CREAT | O_EXCL, mode));
EXPECT_EQ(EPERM, errno);
}
/* The error case of FUSE_ACCESS. */
TEST_F(Access, eaccess)
{
@ -105,6 +193,33 @@ TEST_F(RofsAccess, erofs)
ASSERT_EQ(EROFS, errno);
}
/*
* Lookup an extended attribute
*
* There should never be a FUSE_ACCESS sent for this operation, except for
* search permissions on the parent directory.
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245689
*/
TEST_F(Access, Getxattr)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
uint64_t ino = 42;
char data[80];
int ns = EXTATTR_NAMESPACE_USER;
ssize_t r;
expect_access(FUSE_ROOT_ID, X_OK, 0);
expect_lookup(RELPATH, ino);
expect_noaccess(ino, 0);
expect_getxattr(ino, "user.foo", ReturnErrno(ENOATTR));
r = extattr_get_file(FULLPATH, ns, "foo", data, sizeof(data));
ASSERT_EQ(-1, r);
ASSERT_EQ(ENOATTR, errno);
}
/* The successful case of FUSE_ACCESS. */
TEST_F(Access, ok)
{
@ -119,3 +234,70 @@ TEST_F(Access, ok)
ASSERT_EQ(0, access(FULLPATH, access_mode)) << strerror(errno);
}
/*
* Unlink a file
*
* There should never be a FUSE_ACCESS sent for this operation, except for
* search permissions on the parent directory.
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245689
*/
TEST_F(Access, unlink)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
uint64_t ino = 42;
expect_access(FUSE_ROOT_ID, X_OK, 0);
expect_noaccess(FUSE_ROOT_ID, W_OK | R_OK);
expect_noaccess(ino, 0);
expect_lookup(RELPATH, ino);
expect_unlink(1, RELPATH, EPERM);
ASSERT_NE(0, unlink(FULLPATH));
ASSERT_EQ(EPERM, errno);
}
/*
* Unlink a file whose parent diretory's sticky bit is set
*
* There should never be a FUSE_ACCESS sent for this operation, except for
* search permissions on the parent directory.
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245689
*/
TEST_F(Access, unlink_sticky_directory)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
uint64_t ino = 42;
expect_access(FUSE_ROOT_ID, X_OK, 0);
expect_noaccess(FUSE_ROOT_ID, W_OK | R_OK);
expect_noaccess(ino, 0);
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
return (in.header.opcode == FUSE_GETATTR &&
in.header.nodeid == FUSE_ROOT_ID);
}, Eq(true)),
_)
).WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out)
{
SET_OUT_HEADER_LEN(out, attr);
out.body.attr.attr.ino = FUSE_ROOT_ID;
out.body.attr.attr.mode = S_IFDIR | 01777;
out.body.attr.attr.uid = 0;
out.body.attr.attr_valid = UINT64_MAX;
})));
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
return (in.header.opcode == FUSE_ACCESS &&
in.header.nodeid == ino);
}, Eq(true)),
_)
).Times(0);
expect_lookup(RELPATH, ino);
expect_unlink(FUSE_ROOT_ID, RELPATH, EPERM);
ASSERT_EQ(-1, unlink(FULLPATH));
ASSERT_EQ(EPERM, errno);
}

View File

@ -53,24 +53,6 @@ class Rename: public FuseTest {
FuseTest::TearDown();
}
void expect_getattr(uint64_t ino, mode_t mode)
{
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
return (in.header.opcode == FUSE_GETATTR &&
in.header.nodeid == ino);
}, Eq(true)),
_)
).WillOnce(Invoke(
ReturnImmediate([=](auto i __unused, auto& out) {
SET_OUT_HEADER_LEN(out, attr);
out.body.attr.attr.ino = ino; // Must match nodeid
out.body.attr.attr.mode = mode;
out.body.attr.attr_valid = UINT64_MAX;
})));
}
};
// EINVAL, dst is subdir of src
@ -82,7 +64,6 @@ TEST_F(Rename, einval)
const char RELSRC[] = "src";
uint64_t src_ino = 42;
expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755);
expect_lookup(RELSRC, src_ino, S_IFDIR | 0755, 0, 2);
EXPECT_LOOKUP(src_ino, RELDST).WillOnce(Invoke(ReturnErrno(ENOENT)));
@ -123,7 +104,6 @@ TEST_F(Rename, entry_cache_negative)
*/
struct timespec entry_valid = {.tv_sec = 0, .tv_nsec = 0};
expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755);
expect_lookup(RELSRC, ino, S_IFREG | 0644, 0, 1);
/* LOOKUP returns a negative cache entry for dst */
EXPECT_LOOKUP(FUSE_ROOT_ID, RELDST)
@ -158,7 +138,6 @@ TEST_F(Rename, entry_cache_negative_purge)
uint64_t ino = 42;
struct timespec entry_valid = {.tv_sec = TIME_T_MAX, .tv_nsec = 0};
expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755);
expect_lookup(RELSRC, ino, S_IFREG | 0644, 0, 1);
/* LOOKUP returns a negative cache entry for dst */
EXPECT_LOOKUP(FUSE_ROOT_ID, RELDST)
@ -196,7 +175,6 @@ TEST_F(Rename, exdev)
tmpfd = mkstemp(tmpfile);
ASSERT_LE(0, tmpfd) << strerror(errno);
expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755);
expect_lookup(RELB, b_ino, S_IFREG | 0644, 0, 2);
ASSERT_NE(0, rename(tmpfile, FULLB));
@ -215,7 +193,6 @@ TEST_F(Rename, ok)
uint64_t dst_dir_ino = FUSE_ROOT_ID;
uint64_t ino = 42;
expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755);
expect_lookup(RELSRC, ino, S_IFREG | 0644, 0, 1);
EXPECT_LOOKUP(FUSE_ROOT_ID, RELDST)
.WillOnce(Invoke(ReturnErrno(ENOENT)));
@ -251,7 +228,6 @@ TEST_F(Rename, parent)
struct stat sb;
expect_lookup(RELSRC, ino, S_IFDIR | 0755, 0, 1);
expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755);
EXPECT_LOOKUP(FUSE_ROOT_ID, RELDSTDIR)
.WillRepeatedly(Invoke(ReturnImmediate([=](auto in __unused, auto& out) {
SET_OUT_HEADER_LEN(out, entry);
@ -303,7 +279,6 @@ TEST_F(Rename, overwrite)
uint64_t dst_dir_ino = FUSE_ROOT_ID;
uint64_t ino = 42;
expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755);
expect_lookup(RELSRC, ino, S_IFREG | 0644, 0, 1);
expect_lookup(RELDST, dst_ino, S_IFREG | 0644, 0, 1);
EXPECT_CALL(*m_mock, process(

View File

@ -42,22 +42,6 @@ using namespace testing;
class Rmdir: public FuseTest {
public:
void expect_getattr(uint64_t ino, mode_t mode)
{
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
return (in.header.opcode == FUSE_GETATTR &&
in.header.nodeid == ino);
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
SET_OUT_HEADER_LEN(out, attr);
out.body.attr.attr.ino = ino; // Must match nodeid
out.body.attr.attr.mode = mode;
out.body.attr.attr_valid = UINT64_MAX;
})));
}
void expect_lookup(const char *relpath, uint64_t ino, int times=1)
{
EXPECT_LOOKUP(FUSE_ROOT_ID, relpath)
@ -95,25 +79,34 @@ TEST_F(Rmdir, parent_attr_cache)
struct stat sb;
sem_t sem;
uint64_t ino = 42;
Sequence seq;
ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno);
expect_lookup(RELPATH, ino);
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
return (in.header.opcode == FUSE_RMDIR &&
0 == strcmp(RELPATH, in.body.rmdir) &&
in.header.nodeid == FUSE_ROOT_ID);
}, Eq(true)),
_)
).InSequence(seq)
.WillOnce(Invoke(ReturnErrno(0)));
expect_forget(ino, 1, &sem);
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
return (in.header.opcode == FUSE_GETATTR &&
in.header.nodeid == FUSE_ROOT_ID);
}, Eq(true)),
_)
).Times(2)
).InSequence(seq)
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
SET_OUT_HEADER_LEN(out, attr);
out.body.attr.attr.ino = ino; // Must match nodeid
out.body.attr.attr.ino = FUSE_ROOT_ID;
out.body.attr.attr.mode = S_IFDIR | 0755;
out.body.attr.attr_valid = UINT64_MAX;
})));
expect_lookup(RELPATH, ino);
expect_rmdir(FUSE_ROOT_ID, RELPATH, 0);
expect_forget(ino, 1, &sem);
ASSERT_EQ(0, rmdir(FULLPATH)) << strerror(errno);
EXPECT_EQ(0, stat("mountpoint", &sb)) << strerror(errno);
@ -127,7 +120,6 @@ TEST_F(Rmdir, enotempty)
const char RELPATH[] = "some_dir";
uint64_t ino = 42;
expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755);
expect_lookup(RELPATH, ino);
expect_rmdir(FUSE_ROOT_ID, RELPATH, ENOTEMPTY);
@ -143,7 +135,6 @@ TEST_F(Rmdir, entry_cache)
sem_t sem;
uint64_t ino = 42;
expect_getattr(1, S_IFDIR | 0755);
expect_lookup(RELPATH, ino, 2);
expect_rmdir(FUSE_ROOT_ID, RELPATH, 0);
expect_forget(ino, 1, &sem);
@ -163,7 +154,6 @@ TEST_F(Rmdir, ok)
ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno);
expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755);
expect_lookup(RELPATH, ino);
expect_rmdir(FUSE_ROOT_ID, RELPATH, 0);
expect_forget(ino, 1, &sem);

View File

@ -41,22 +41,6 @@ using namespace testing;
class Unlink: public FuseTest {
public:
void expect_getattr(uint64_t ino, mode_t mode)
{
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
return (in.header.opcode == FUSE_GETATTR &&
in.header.nodeid == ino);
}, Eq(true)),
_)
).WillOnce(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
SET_OUT_HEADER_LEN(out, attr);
out.body.attr.attr.ino = ino; // Must match nodeid
out.body.attr.attr.mode = mode;
out.body.attr.attr_valid = UINT64_MAX;
})));
}
void expect_lookup(const char *relpath, uint64_t ino, int times, int nlink=1)
{
EXPECT_LOOKUP(FUSE_ROOT_ID, relpath)
@ -89,7 +73,6 @@ TEST_F(Unlink, attr_cache)
struct stat sb_old, sb_new;
int fd1;
expect_getattr(1, S_IFDIR | 0755);
expect_lookup(RELPATH0, ino, 1, 2);
expect_lookup(RELPATH1, ino, 1, 2);
expect_open(ino, 0, 1);
@ -117,23 +100,32 @@ TEST_F(Unlink, parent_attr_cache)
const char RELPATH[] = "some_file.txt";
struct stat sb;
uint64_t ino = 42;
Sequence seq;
/* Use nlink=2 so we don't get a FUSE_FORGET */
expect_lookup(RELPATH, ino, 1, 2);
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
return (in.header.opcode == FUSE_UNLINK &&
0 == strcmp(RELPATH, in.body.unlink) &&
in.header.nodeid == FUSE_ROOT_ID);
}, Eq(true)),
_)
).InSequence(seq)
.WillOnce(Invoke(ReturnErrno(0)));
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
return (in.header.opcode == FUSE_GETATTR &&
in.header.nodeid == FUSE_ROOT_ID);
}, Eq(true)),
_)
).Times(2)
).InSequence(seq)
.WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) {
SET_OUT_HEADER_LEN(out, attr);
out.body.attr.attr.ino = ino; // Must match nodeid
out.body.attr.attr.ino = FUSE_ROOT_ID;
out.body.attr.attr.mode = S_IFDIR | 0755;
out.body.attr.attr_valid = UINT64_MAX;
})));
/* Use nlink=2 so we don't get a FUSE_FORGET */
expect_lookup(RELPATH, ino, 1, 2);
expect_unlink(1, RELPATH, 0);
ASSERT_EQ(0, unlink(FULLPATH)) << strerror(errno);
EXPECT_EQ(0, stat("mountpoint", &sb)) << strerror(errno);
@ -145,7 +137,6 @@ TEST_F(Unlink, eperm)
const char RELPATH[] = "some_file.txt";
uint64_t ino = 42;
expect_getattr(1, S_IFDIR | 0755);
expect_lookup(RELPATH, ino, 1);
expect_unlink(1, RELPATH, EPERM);
@ -162,7 +153,6 @@ TEST_F(Unlink, entry_cache)
const char RELPATH[] = "some_file.txt";
uint64_t ino = 42;
expect_getattr(1, S_IFDIR | 0755);
expect_lookup(RELPATH, ino, 2, 2);
expect_unlink(1, RELPATH, 0);
@ -182,7 +172,6 @@ TEST_F(Unlink, multiply_linked)
const char RELPATH1[] = "other_file.txt";
uint64_t ino = 42;
expect_getattr(1, S_IFDIR | 0755);
expect_lookup(RELPATH0, ino, 1, 2);
expect_unlink(1, RELPATH0, 0);
EXPECT_CALL(*m_mock, process(
@ -213,7 +202,6 @@ TEST_F(Unlink, ok)
ASSERT_EQ(0, sem_init(&sem, 0, 0)) << strerror(errno);
expect_getattr(1, S_IFDIR | 0755);
expect_lookup(RELPATH, ino, 1);
expect_unlink(1, RELPATH, 0);
expect_forget(ino, 1, &sem);
@ -233,7 +221,6 @@ TEST_F(Unlink, open_but_deleted)
uint64_t ino = 42;
int fd;
expect_getattr(1, S_IFDIR | 0755);
expect_lookup(RELPATH0, ino, 2);
expect_open(ino, 0, 1);
expect_unlink(1, RELPATH0, 0);

View File

@ -273,6 +273,20 @@ void FuseTest::expect_getattr(uint64_t ino, uint64_t size)
})));
}
void FuseTest::expect_getxattr(uint64_t ino, const char *attr, ProcessMockerT r)
{
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
const char *a = (const char*)in.body.bytes +
sizeof(fuse_getxattr_in);
return (in.header.opcode == FUSE_GETXATTR &&
in.header.nodeid == ino &&
0 == strcmp(attr, a));
}, Eq(true)),
_)
).WillOnce(Invoke(r));
}
void FuseTest::expect_lookup(const char *relpath, uint64_t ino, mode_t mode,
uint64_t size, int times, uint64_t attr_valid, uid_t uid, gid_t gid)
{

View File

@ -132,6 +132,12 @@ class FuseTest : public ::testing::Test {
*/
void expect_getattr(uint64_t ino, uint64_t size);
/*
* Create an expectation that FUSE_GETXATTR will be called once for the
* given inode.
*/
void expect_getxattr(uint64_t ino, const char *attr, ProcessMockerT r);
/*
* Create an expectation that FUSE_LOOKUP will be called for the given
* path exactly times times and cache validity period. It will respond

View File

@ -62,20 +62,6 @@ void* killer(void* target) {
class Xattr: public FuseTest {
public:
void expect_getxattr(uint64_t ino, const char *attr, ProcessMockerT r)
{
EXPECT_CALL(*m_mock, process(
ResultOf([=](auto in) {
const char *a = (const char*)in.body.bytes +
sizeof(fuse_getxattr_in);
return (in.header.opcode == FUSE_GETXATTR &&
in.header.nodeid == ino &&
0 == strcmp(attr, a));
}, Eq(true)),
_)
).WillOnce(Invoke(r));
}
void expect_listxattr(uint64_t ino, uint32_t size, ProcessMockerT r,
Sequence *seq = NULL)
{