2019-03-01 23:53:05 +00:00
|
|
|
/*-
|
2019-03-11 19:10:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2019-03-01 23:53:05 +00:00
|
|
|
* Copyright (c) 2019 The FreeBSD Foundation
|
|
|
|
*
|
|
|
|
* This software was developed by BFF Storage Systems, LLC under sponsorship
|
|
|
|
* from the FreeBSD Foundation.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
2019-08-13 15:49:40 +00:00
|
|
|
*
|
|
|
|
* $FreeBSD$
|
2019-03-01 23:53:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
#include "fuse_kernel.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <gmock/gmock.h>
|
|
|
|
|
2019-03-06 00:38:10 +00:00
|
|
|
#define TIME_T_MAX (std::numeric_limits<time_t>::max())
|
|
|
|
|
2019-03-13 22:16:00 +00:00
|
|
|
/*
|
|
|
|
* A pseudo-fuse errno used indicate that a fuse operation should have no
|
|
|
|
* response, at least not immediately
|
|
|
|
*/
|
|
|
|
#define FUSE_NORESPONSE 9999
|
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
#define SET_OUT_HEADER_LEN(out, variant) { \
|
2019-05-27 17:08:16 +00:00
|
|
|
(out).header.len = (sizeof((out).header) + \
|
|
|
|
sizeof((out).body.variant)); \
|
2019-03-01 23:53:05 +00:00
|
|
|
}
|
|
|
|
|
2019-03-05 03:27:32 +00:00
|
|
|
/*
|
|
|
|
* Create an expectation on FUSE_LOOKUP and return it so the caller can set
|
|
|
|
* actions.
|
|
|
|
*
|
|
|
|
* This must be a macro instead of a method because EXPECT_CALL returns a type
|
|
|
|
* with a deleted constructor.
|
|
|
|
*/
|
2019-03-05 21:40:08 +00:00
|
|
|
#define EXPECT_LOOKUP(parent, path) \
|
2019-03-05 03:27:32 +00:00
|
|
|
EXPECT_CALL(*m_mock, process( \
|
|
|
|
ResultOf([=](auto in) { \
|
2019-05-27 17:08:16 +00:00
|
|
|
return (in.header.opcode == FUSE_LOOKUP && \
|
|
|
|
in.header.nodeid == (parent) && \
|
|
|
|
strcmp(in.body.lookup, (path)) == 0); \
|
2019-03-05 03:27:32 +00:00
|
|
|
}, Eq(true)), \
|
|
|
|
_) \
|
|
|
|
)
|
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
extern int verbosity;
|
|
|
|
|
2020-12-24 06:03:06 +00:00
|
|
|
/*
|
|
|
|
* The maximum that a test case can set max_write, limited by the buffer
|
|
|
|
* supplied when reading from /dev/fuse. This limitation is imposed by
|
|
|
|
* fusefs-libs, but not by the FUSE protocol.
|
|
|
|
*/
|
|
|
|
const uint32_t max_max_write = 0x20000;
|
|
|
|
|
|
|
|
|
2019-03-04 22:07:33 +00:00
|
|
|
/* This struct isn't defined by fuse_kernel.h or libfuse, but it should be */
|
|
|
|
struct fuse_create_out {
|
|
|
|
struct fuse_entry_out entry;
|
|
|
|
struct fuse_open_out open;
|
|
|
|
};
|
|
|
|
|
2019-05-16 17:24:11 +00:00
|
|
|
/* Protocol 7.8 version of struct fuse_attr */
|
|
|
|
struct fuse_attr_7_8
|
|
|
|
{
|
2019-06-21 04:37:11 +00:00
|
|
|
uint64_t ino;
|
|
|
|
uint64_t size;
|
|
|
|
uint64_t blocks;
|
|
|
|
uint64_t atime;
|
|
|
|
uint64_t mtime;
|
|
|
|
uint64_t ctime;
|
|
|
|
uint32_t atimensec;
|
|
|
|
uint32_t mtimensec;
|
|
|
|
uint32_t ctimensec;
|
|
|
|
uint32_t mode;
|
|
|
|
uint32_t nlink;
|
|
|
|
uint32_t uid;
|
|
|
|
uint32_t gid;
|
|
|
|
uint32_t rdev;
|
2019-05-16 17:24:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Protocol 7.8 version of struct fuse_attr_out */
|
|
|
|
struct fuse_attr_out_7_8
|
|
|
|
{
|
2019-06-21 04:37:11 +00:00
|
|
|
uint64_t attr_valid;
|
|
|
|
uint32_t attr_valid_nsec;
|
|
|
|
uint32_t dummy;
|
2019-05-16 17:24:11 +00:00
|
|
|
struct fuse_attr_7_8 attr;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Protocol 7.8 version of struct fuse_entry_out */
|
|
|
|
struct fuse_entry_out_7_8 {
|
2019-06-21 04:37:11 +00:00
|
|
|
uint64_t nodeid; /* Inode ID */
|
|
|
|
uint64_t generation; /* Inode generation: nodeid:gen must
|
2019-05-16 17:24:11 +00:00
|
|
|
be unique for the fs's lifetime */
|
2019-06-21 04:37:11 +00:00
|
|
|
uint64_t entry_valid; /* Cache timeout for the name */
|
|
|
|
uint64_t attr_valid; /* Cache timeout for the attributes */
|
|
|
|
uint32_t entry_valid_nsec;
|
|
|
|
uint32_t attr_valid_nsec;
|
2019-05-16 17:24:11 +00:00
|
|
|
struct fuse_attr_7_8 attr;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Output struct for FUSE_CREATE for protocol 7.8 servers */
|
|
|
|
struct fuse_create_out_7_8 {
|
|
|
|
struct fuse_entry_out_7_8 entry;
|
|
|
|
struct fuse_open_out open;
|
|
|
|
};
|
|
|
|
|
2019-06-21 04:57:23 +00:00
|
|
|
/* Output struct for FUSE_INIT for protocol 7.22 and earlier servers */
|
|
|
|
struct fuse_init_out_7_22 {
|
|
|
|
uint32_t major;
|
|
|
|
uint32_t minor;
|
|
|
|
uint32_t max_readahead;
|
|
|
|
uint32_t flags;
|
|
|
|
uint16_t max_background;
|
|
|
|
uint16_t congestion_threshold;
|
|
|
|
uint32_t max_write;
|
|
|
|
};
|
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
union fuse_payloads_in {
|
2019-03-05 18:53:28 +00:00
|
|
|
fuse_access_in access;
|
2019-06-20 17:08:21 +00:00
|
|
|
fuse_bmap_in bmap;
|
2020-12-24 06:03:06 +00:00
|
|
|
/*
|
|
|
|
* In fusefs-libs 3.4.2 and below the buffer size is fixed at 0x21000
|
|
|
|
* minus the header sizes. fusefs-libs 3.4.3 (and FUSE Protocol 7.29)
|
|
|
|
* add a FUSE_MAX_PAGES option that allows it to be greater.
|
|
|
|
*
|
|
|
|
* See fuse_kern_chan.c in fusefs-libs 2.9.9 and below, or
|
|
|
|
* FUSE_DEFAULT_MAX_PAGES_PER_REQ in fusefs-libs 3.4.3 and above.
|
|
|
|
*/
|
|
|
|
uint8_t bytes[
|
|
|
|
max_max_write + 0x1000 - sizeof(struct fuse_in_header)
|
|
|
|
];
|
2020-12-28 18:25:21 -07:00
|
|
|
fuse_copy_file_range_in copy_file_range;
|
2019-05-29 16:39:52 +00:00
|
|
|
fuse_create_in create;
|
2019-03-08 23:07:51 +00:00
|
|
|
fuse_flush_in flush;
|
2019-03-11 22:29:56 +00:00
|
|
|
fuse_fsync_in fsync;
|
|
|
|
fuse_fsync_in fsyncdir;
|
2019-03-01 23:53:05 +00:00
|
|
|
fuse_forget_in forget;
|
2019-08-14 20:45:00 +00:00
|
|
|
fuse_getattr_in getattr;
|
2019-03-13 22:16:00 +00:00
|
|
|
fuse_interrupt_in interrupt;
|
|
|
|
fuse_lk_in getlk;
|
2019-03-14 23:05:59 +00:00
|
|
|
fuse_getxattr_in getxattr;
|
2019-03-01 23:53:05 +00:00
|
|
|
fuse_init_in init;
|
2019-03-05 21:40:08 +00:00
|
|
|
fuse_link_in link;
|
2019-03-14 23:05:59 +00:00
|
|
|
fuse_listxattr_in listxattr;
|
2019-03-01 23:53:05 +00:00
|
|
|
char lookup[0];
|
2020-12-28 17:26:31 -07:00
|
|
|
fuse_lseek_in lseek;
|
2019-03-05 18:53:28 +00:00
|
|
|
fuse_mkdir_in mkdir;
|
2019-03-05 00:27:54 +00:00
|
|
|
fuse_mknod_in mknod;
|
2019-03-04 22:07:33 +00:00
|
|
|
fuse_open_in open;
|
2019-03-12 22:25:59 +00:00
|
|
|
fuse_open_in opendir;
|
2019-03-08 19:01:31 +00:00
|
|
|
fuse_read_in read;
|
2019-03-12 22:25:59 +00:00
|
|
|
fuse_read_in readdir;
|
2019-03-08 19:01:31 +00:00
|
|
|
fuse_release_in release;
|
2019-03-13 13:41:05 +00:00
|
|
|
fuse_release_in releasedir;
|
2019-03-05 21:40:08 +00:00
|
|
|
fuse_rename_in rename;
|
2019-03-06 00:38:10 +00:00
|
|
|
char rmdir[0];
|
2019-03-02 15:32:20 +00:00
|
|
|
fuse_setattr_in setattr;
|
2019-03-14 23:05:59 +00:00
|
|
|
fuse_setxattr_in setxattr;
|
2019-03-13 22:16:00 +00:00
|
|
|
fuse_lk_in setlk;
|
2019-03-15 16:16:50 +00:00
|
|
|
fuse_lk_in setlkw;
|
2019-03-06 00:38:10 +00:00
|
|
|
char unlink[0];
|
2019-03-08 19:01:31 +00:00
|
|
|
fuse_write_in write;
|
2019-03-01 23:53:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mockfs_buf_in {
|
|
|
|
fuse_in_header header;
|
|
|
|
union fuse_payloads_in body;
|
|
|
|
};
|
|
|
|
|
|
|
|
union fuse_payloads_out {
|
|
|
|
fuse_attr_out attr;
|
2019-05-16 17:24:11 +00:00
|
|
|
fuse_attr_out_7_8 attr_7_8;
|
2019-06-20 17:08:21 +00:00
|
|
|
fuse_bmap_out bmap;
|
2019-03-04 22:07:33 +00:00
|
|
|
fuse_create_out create;
|
2019-05-16 17:24:11 +00:00
|
|
|
fuse_create_out_7_8 create_7_8;
|
2019-05-27 17:08:16 +00:00
|
|
|
/*
|
|
|
|
* The protocol places no limits on the size of bytes. Choose
|
|
|
|
* a size big enough for anything we'll test.
|
|
|
|
*/
|
|
|
|
uint8_t bytes[0x20000];
|
2019-03-04 22:07:33 +00:00
|
|
|
fuse_entry_out entry;
|
2019-05-16 17:24:11 +00:00
|
|
|
fuse_entry_out_7_8 entry_7_8;
|
2019-03-13 22:16:00 +00:00
|
|
|
fuse_lk_out getlk;
|
2019-03-14 23:05:59 +00:00
|
|
|
fuse_getxattr_out getxattr;
|
2019-03-04 22:07:33 +00:00
|
|
|
fuse_init_out init;
|
2019-06-21 04:57:23 +00:00
|
|
|
fuse_init_out_7_22 init_7_22;
|
2020-12-28 17:26:31 -07:00
|
|
|
fuse_lseek_out lseek;
|
2019-06-01 00:11:19 +00:00
|
|
|
/* The inval_entry structure should be followed by the entry's name */
|
|
|
|
fuse_notify_inval_entry_out inval_entry;
|
2019-06-03 17:34:01 +00:00
|
|
|
fuse_notify_inval_inode_out inval_inode;
|
2019-06-20 23:32:25 +00:00
|
|
|
/* The store structure should be followed by the data to store */
|
|
|
|
fuse_notify_store_out store;
|
2019-03-14 23:05:59 +00:00
|
|
|
fuse_listxattr_out listxattr;
|
2019-03-04 22:07:33 +00:00
|
|
|
fuse_open_out open;
|
2019-03-06 00:38:10 +00:00
|
|
|
fuse_statfs_out statfs;
|
2019-03-04 22:07:33 +00:00
|
|
|
/*
|
|
|
|
* The protocol places no limits on the length of the string. This is
|
|
|
|
* merely convenient for testing.
|
|
|
|
*/
|
|
|
|
char str[80];
|
2019-03-08 19:01:31 +00:00
|
|
|
fuse_write_out write;
|
2019-03-01 23:53:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mockfs_buf_out {
|
|
|
|
fuse_out_header header;
|
|
|
|
union fuse_payloads_out body;
|
2019-03-14 17:20:24 +00:00
|
|
|
|
|
|
|
/* Default constructor: zero everything */
|
|
|
|
mockfs_buf_out() {
|
|
|
|
memset(this, 0, sizeof(*this));
|
|
|
|
}
|
2019-03-01 23:53:05 +00:00
|
|
|
};
|
|
|
|
|
2019-03-08 19:01:31 +00:00
|
|
|
/* A function that can be invoked in place of MockFS::process */
|
2019-05-27 17:08:16 +00:00
|
|
|
typedef std::function<void (const mockfs_buf_in& in,
|
|
|
|
std::vector<std::unique_ptr<mockfs_buf_out>> &out)>
|
2019-03-08 19:01:31 +00:00
|
|
|
ProcessMockerT;
|
|
|
|
|
2019-03-05 03:27:32 +00:00
|
|
|
/*
|
|
|
|
* Helper function used for setting an error expectation for any fuse operation.
|
|
|
|
* The operation will return the supplied error
|
|
|
|
*/
|
2019-03-08 19:01:31 +00:00
|
|
|
ProcessMockerT ReturnErrno(int error);
|
2019-03-05 03:27:32 +00:00
|
|
|
|
2019-03-06 00:38:10 +00:00
|
|
|
/* Helper function used for returning negative cache entries for LOOKUP */
|
2019-03-14 17:20:24 +00:00
|
|
|
ProcessMockerT ReturnNegativeCache(const struct timespec *entry_valid);
|
|
|
|
|
|
|
|
/* Helper function used for returning a single immediate response */
|
|
|
|
ProcessMockerT ReturnImmediate(
|
2019-05-27 17:08:16 +00:00
|
|
|
std::function<void(const mockfs_buf_in& in,
|
|
|
|
struct mockfs_buf_out &out)> f);
|
2019-03-06 00:38:10 +00:00
|
|
|
|
2019-05-12 15:27:18 +00:00
|
|
|
/* How the daemon should check /dev/fuse for readiness */
|
|
|
|
enum poll_method {
|
|
|
|
BLOCKING,
|
|
|
|
SELECT,
|
|
|
|
POLL,
|
|
|
|
KQ
|
|
|
|
};
|
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
/*
|
|
|
|
* Fake FUSE filesystem
|
|
|
|
*
|
|
|
|
* "Mounts" a filesystem to a temporary directory and services requests
|
|
|
|
* according to the programmed expectations.
|
|
|
|
*
|
2019-03-21 00:11:43 +00:00
|
|
|
* Operates directly on the fusefs(4) kernel API, not the libfuse(3) user api.
|
2019-03-01 23:53:05 +00:00
|
|
|
*/
|
|
|
|
class MockFS {
|
2019-03-06 00:38:10 +00:00
|
|
|
/*
|
|
|
|
* thread id of the fuse daemon thread
|
|
|
|
*
|
|
|
|
* It must run in a separate thread so it doesn't deadlock with the
|
|
|
|
* client test code.
|
|
|
|
*/
|
2019-03-01 23:53:05 +00:00
|
|
|
pthread_t m_daemon_id;
|
|
|
|
|
|
|
|
/* file descriptor of /dev/fuse control device */
|
|
|
|
int m_fuse_fd;
|
|
|
|
|
2019-05-16 17:24:11 +00:00
|
|
|
/* The minor version of the kernel API that this mock daemon targets */
|
|
|
|
uint32_t m_kernel_minor_version;
|
|
|
|
|
2019-05-12 15:27:18 +00:00
|
|
|
int m_kq;
|
|
|
|
|
2019-06-14 18:14:51 +00:00
|
|
|
/* The max_readahead file system option */
|
2019-03-11 18:28:20 +00:00
|
|
|
uint32_t m_maxreadahead;
|
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
/* pid of the test process */
|
|
|
|
pid_t m_pid;
|
|
|
|
|
2021-06-17 18:04:59 -06:00
|
|
|
/* The unique value of the header of the last received operation */
|
|
|
|
uint64_t m_last_unique;
|
|
|
|
|
2019-05-12 15:27:18 +00:00
|
|
|
/* Method the daemon should use for I/O to and from /dev/fuse */
|
|
|
|
enum poll_method m_pm;
|
|
|
|
|
2019-06-26 02:09:22 +00:00
|
|
|
/* Timestamp granularity in nanoseconds */
|
|
|
|
unsigned m_time_gran;
|
|
|
|
|
2019-09-11 19:29:40 +00:00
|
|
|
void audit_request(const mockfs_buf_in &in, ssize_t buflen);
|
|
|
|
void debug_request(const mockfs_buf_in&, ssize_t buflen);
|
2019-06-01 00:11:19 +00:00
|
|
|
void debug_response(const mockfs_buf_out&);
|
2019-05-29 16:39:52 +00:00
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
/* Initialize a session after mounting */
|
2019-03-13 22:16:00 +00:00
|
|
|
void init(uint32_t flags);
|
2019-03-01 23:53:05 +00:00
|
|
|
|
2019-03-08 19:01:31 +00:00
|
|
|
/* Is pid from a process that might be involved in the test? */
|
|
|
|
bool pid_ok(pid_t pid);
|
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
/* Default request handler */
|
2019-05-27 17:08:16 +00:00
|
|
|
void process_default(const mockfs_buf_in&,
|
|
|
|
std::vector<std::unique_ptr<mockfs_buf_out>>&);
|
2019-03-01 23:53:05 +00:00
|
|
|
|
|
|
|
/* Entry point for the daemon thread */
|
|
|
|
static void* service(void*);
|
|
|
|
|
2019-09-11 19:29:40 +00:00
|
|
|
/*
|
|
|
|
* Read, but do not process, a single request from the kernel
|
|
|
|
*
|
|
|
|
* @param in Return storage for the FUSE request
|
|
|
|
* @param res Return value of read(2). If positive, the amount of
|
|
|
|
* data read from the fuse device.
|
|
|
|
*/
|
|
|
|
void read_request(mockfs_buf_in& in, ssize_t& res);
|
2019-03-01 23:53:05 +00:00
|
|
|
|
2019-05-12 15:27:18 +00:00
|
|
|
/* Write a single response back to the kernel */
|
2019-05-27 17:08:16 +00:00
|
|
|
void write_response(const mockfs_buf_out &out);
|
2019-05-12 15:27:18 +00:00
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
public:
|
2019-03-21 19:56:33 +00:00
|
|
|
/* pid of child process, for two-process test cases */
|
|
|
|
pid_t m_child_pid;
|
|
|
|
|
2019-03-08 19:01:31 +00:00
|
|
|
/* Maximum size of a FUSE_WRITE write */
|
2019-06-14 18:14:51 +00:00
|
|
|
uint32_t m_maxwrite;
|
2019-03-08 19:01:31 +00:00
|
|
|
|
2019-05-12 15:27:18 +00:00
|
|
|
/*
|
|
|
|
* Number of events that were available from /dev/fuse after the last
|
|
|
|
* kevent call. Only valid when m_pm = KQ.
|
|
|
|
*/
|
|
|
|
int m_nready;
|
|
|
|
|
2019-05-10 16:58:05 +00:00
|
|
|
/* Tell the daemon to shut down ASAP */
|
|
|
|
bool m_quit;
|
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
/* Create a new mockfs and mount it to a tempdir */
|
2019-03-21 19:56:33 +00:00
|
|
|
MockFS(int max_readahead, bool allow_other,
|
2019-04-05 15:33:43 +00:00
|
|
|
bool default_permissions, bool push_symlinks_in, bool ro,
|
2019-05-16 17:24:11 +00:00
|
|
|
enum poll_method pm, uint32_t flags,
|
2019-06-17 22:01:23 +00:00
|
|
|
uint32_t kernel_minor_version, uint32_t max_write, bool async,
|
2019-07-18 17:55:13 +00:00
|
|
|
bool no_clusterr, unsigned time_gran, bool nointr);
|
2019-05-16 17:24:11 +00:00
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
virtual ~MockFS();
|
|
|
|
|
2019-03-06 00:38:10 +00:00
|
|
|
/* Kill the filesystem daemon without unmounting the filesystem */
|
|
|
|
void kill_daemon();
|
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
/* Process FUSE requests endlessly */
|
|
|
|
void loop();
|
|
|
|
|
2019-06-01 00:11:19 +00:00
|
|
|
/*
|
|
|
|
* Send an asynchronous notification to invalidate a directory entry.
|
|
|
|
* Similar to libfuse's fuse_lowlevel_notify_inval_entry
|
|
|
|
*
|
|
|
|
* This method will block until the client has responded, so it should
|
|
|
|
* generally be run in a separate thread from request processing.
|
|
|
|
*
|
|
|
|
* @param parent Parent directory's inode number
|
|
|
|
* @param name name of dirent to invalidate
|
|
|
|
* @param namelen size of name, including the NUL
|
|
|
|
*/
|
|
|
|
int notify_inval_entry(ino_t parent, const char *name, size_t namelen);
|
|
|
|
|
2019-06-03 17:34:01 +00:00
|
|
|
/*
|
|
|
|
* Send an asynchronous notification to invalidate an inode's cached
|
|
|
|
* data and/or attributes. Similar to libfuse's
|
|
|
|
* fuse_lowlevel_notify_inval_inode.
|
|
|
|
*
|
|
|
|
* This method will block until the client has responded, so it should
|
|
|
|
* generally be run in a separate thread from request processing.
|
|
|
|
*
|
|
|
|
* @param ino File's inode number
|
|
|
|
* @param off offset at which to begin invalidation. A
|
|
|
|
* negative offset means to invalidate attributes
|
|
|
|
* only.
|
|
|
|
* @param len Size of region of data to invalidate. 0 means
|
|
|
|
* to invalidate all cached data.
|
|
|
|
*/
|
|
|
|
int notify_inval_inode(ino_t ino, off_t off, ssize_t len);
|
|
|
|
|
2019-06-20 23:32:25 +00:00
|
|
|
/*
|
|
|
|
* Send an asynchronous notification to store data directly into an
|
|
|
|
* inode's cache. Similar to libfuse's fuse_lowlevel_notify_store.
|
|
|
|
*
|
|
|
|
* This method will block until the client has responded, so it should
|
|
|
|
* generally be run in a separate thread from request processing.
|
|
|
|
*
|
|
|
|
* @param ino File's inode number
|
|
|
|
* @param off Offset at which to store data
|
|
|
|
* @param data Pointer to the data to cache
|
|
|
|
* @param len Size of data
|
|
|
|
*/
|
2019-07-20 05:21:13 +00:00
|
|
|
int notify_store(ino_t ino, off_t off, const void* data, ssize_t size);
|
2019-06-20 23:32:25 +00:00
|
|
|
|
2019-03-01 23:53:05 +00:00
|
|
|
/*
|
|
|
|
* Request handler
|
|
|
|
*
|
2019-03-14 17:20:24 +00:00
|
|
|
* This method is expected to provide the responses to each FUSE
|
|
|
|
* operation. For an immediate response, push one buffer into out.
|
|
|
|
* For a delayed response, push nothing. For an immediate response
|
|
|
|
* plus a delayed response to an earlier operation, push two bufs.
|
|
|
|
* Test cases must define each response using Googlemock expectations
|
2019-03-01 23:53:05 +00:00
|
|
|
*/
|
2019-05-27 17:08:16 +00:00
|
|
|
MOCK_METHOD2(process, void(const mockfs_buf_in&,
|
|
|
|
std::vector<std::unique_ptr<mockfs_buf_out>>&));
|
2019-03-01 23:53:05 +00:00
|
|
|
|
|
|
|
/* Gracefully unmount */
|
|
|
|
void unmount();
|
|
|
|
};
|