Remove libfuse abstraction in prep for adding request data

This commit is contained in:
Antonio SJ Musumeci 2022-11-12 22:26:26 -05:00
parent 629806e896
commit 7606430188
7 changed files with 1009 additions and 1623 deletions

View file

@ -25,6 +25,7 @@
#include "extern_c.h"
#include "fuse_common.h"
#include "fuse_kernel.h"
#include <fcntl.h>
#include <stdint.h>
@ -117,12 +118,6 @@ struct fuse_ctx
mode_t umask;
};
struct fuse_forget_data
{
uint64_t ino;
uint64_t nlookup;
};
/* ----------------------------------------------------------- *
* Request methods and replies *
* ----------------------------------------------------------- */
@ -183,7 +178,8 @@ struct fuse_lowlevel_ops
* @param parent inode number of the parent directory
* @param name the name to look up
*/
void (*lookup)(fuse_req_t req, uint64_t parent, const char *name);
void (*lookup)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Forget about an inode
@ -221,7 +217,8 @@ struct fuse_lowlevel_ops
* @param ino the inode number
* @param nlookup the number of lookups to forget
*/
void (*forget)(fuse_req_t req, uint64_t ino, uint64_t nlookup);
void (*forget)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Get file attributes
@ -229,12 +226,9 @@ struct fuse_lowlevel_ops
* Valid replies:
* fuse_reply_attr
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param fi for future use, currently always NULL
*/
void (*getattr)(fuse_req_t req, uint64_t ino, fuse_file_info_t *fi);
void (*getattr)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Set file attributes
@ -263,8 +257,8 @@ struct fuse_lowlevel_ops
* Changed in version 2.5:
* file information filled in for ftruncate
*/
void (*setattr)(fuse_req_t req, uint64_t ino, struct stat *attr,
int to_set, fuse_file_info_t *fi);
void (*setattr)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Read symbolic link
@ -276,7 +270,8 @@ struct fuse_lowlevel_ops
* @param req request handle
* @param ino the inode number
*/
void (*readlink)(fuse_req_t req, uint64_t ino);
void (*readlink)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Create file node
@ -294,8 +289,8 @@ struct fuse_lowlevel_ops
* @param mode file type and mode with which to create the new file
* @param rdev the device number (only valid if created file is a device)
*/
void (*mknod)(fuse_req_t req, uint64_t parent, const char *name,
mode_t mode, dev_t rdev);
void (*mknod)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Create a directory
@ -309,8 +304,8 @@ struct fuse_lowlevel_ops
* @param name to create
* @param mode with which to create the new file
*/
void (*mkdir)(fuse_req_t req, uint64_t parent, const char *name,
mode_t mode);
void (*mkdir)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Remove a file
@ -327,7 +322,8 @@ struct fuse_lowlevel_ops
* @param parent inode number of the parent directory
* @param name to remove
*/
void (*unlink)(fuse_req_t req, uint64_t parent, const char *name);
void (*unlink)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Remove a directory
@ -344,7 +340,8 @@ struct fuse_lowlevel_ops
* @param parent inode number of the parent directory
* @param name to remove
*/
void (*rmdir)(fuse_req_t req, uint64_t parent, const char *name);
void (*rmdir)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Create a symbolic link
@ -358,8 +355,8 @@ struct fuse_lowlevel_ops
* @param parent inode number of the parent directory
* @param name to create
*/
void (*symlink)(fuse_req_t req, const char *link, uint64_t parent,
const char *name);
void (*symlink)(fuse_req_t req,
struct fuse_in_header *hdr);
/** Rename a file
*
@ -378,8 +375,8 @@ struct fuse_lowlevel_ops
* @param newparent inode number of the new parent directory
* @param newname new name
*/
void (*rename)(fuse_req_t req, uint64_t parent, const char *name,
uint64_t newparent, const char *newname);
void (*rename)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Create a hard link
@ -393,8 +390,8 @@ struct fuse_lowlevel_ops
* @param newparent inode number of the new parent directory
* @param newname new name to create
*/
void (*link)(fuse_req_t req, uint64_t ino, uint64_t newparent,
const char *newname);
void (*link)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Open a file
@ -421,8 +418,8 @@ struct fuse_lowlevel_ops
* @param ino the inode number
* @param fi file information
*/
void (*open)(fuse_req_t req, uint64_t ino,
fuse_file_info_t *fi);
void (*open)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Read data
@ -449,8 +446,8 @@ struct fuse_lowlevel_ops
* @param off offset to read from
* @param fi file information
*/
void (*read)(fuse_req_t req, uint64_t ino, size_t size, off_t off,
fuse_file_info_t *fi);
void (*read)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Write data
@ -475,8 +472,8 @@ struct fuse_lowlevel_ops
* @param off offset to write to
* @param fi file information
*/
void (*write)(fuse_req_t req, uint64_t ino, const char *buf,
size_t size, off_t off, fuse_file_info_t *fi);
void (*write)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Flush method
@ -507,8 +504,8 @@ struct fuse_lowlevel_ops
* @param ino the inode number
* @param fi file information
*/
void (*flush)(fuse_req_t req, uint64_t ino,
fuse_file_info_t *fi);
void (*flush)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Release an open file
@ -534,8 +531,8 @@ struct fuse_lowlevel_ops
* @param ino the inode number
* @param fi file information
*/
void (*release)(fuse_req_t req, uint64_t ino,
fuse_file_info_t *fi);
void (*release)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Synchronize file contents
@ -551,8 +548,8 @@ struct fuse_lowlevel_ops
* @param datasync flag indicating if only data should be flushed
* @param fi file information
*/
void (*fsync)(fuse_req_t req, uint64_t ino, int datasync,
fuse_file_info_t *fi);
void (*fsync)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Open a directory
@ -575,8 +572,8 @@ struct fuse_lowlevel_ops
* @param ino the inode number
* @param fi file information
*/
void (*opendir)(fuse_req_t req, uint64_t ino,
fuse_file_info_t *fi);
void (*opendir)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Read directory
@ -599,12 +596,11 @@ struct fuse_lowlevel_ops
* @param off offset to continue reading the directory stream
* @param fi file information
*/
void (*readdir)(fuse_req_t req, uint64_t ino, size_t size, off_t off,
fuse_file_info_t *llffi);
void (*readdir)(fuse_req_t req,
struct fuse_in_header *hdr);
void (*readdir_plus)(fuse_req_t req, uint64_t ino,
size_t size, off_t off,
fuse_file_info_t *ffi);
void (*readdir_plus)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Release an open directory
@ -622,8 +618,8 @@ struct fuse_lowlevel_ops
* @param ino the inode number
* @param fi file information
*/
void (*releasedir)(fuse_req_t req, uint64_t ino,
fuse_file_info_t *fi);
void (*releasedir)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Synchronize directory contents
@ -642,8 +638,8 @@ struct fuse_lowlevel_ops
* @param datasync flag indicating if only data should be flushed
* @param fi file information
*/
void (*fsyncdir)(fuse_req_t req, uint64_t ino, int datasync,
fuse_file_info_t *fi);
void (*fsyncdir)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Get file system statistics
@ -655,7 +651,8 @@ struct fuse_lowlevel_ops
* @param req request handle
* @param ino the inode number, zero means "undefined"
*/
void (*statfs)(fuse_req_t req, uint64_t ino);
void (*statfs)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Set an extended attribute
@ -663,8 +660,8 @@ struct fuse_lowlevel_ops
* Valid replies:
* fuse_reply_err
*/
void (*setxattr)(fuse_req_t req, uint64_t ino, const char *name,
const char *value, size_t size, int flags);
void (*setxattr)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Get an extended attribute
@ -689,8 +686,8 @@ struct fuse_lowlevel_ops
* @param name of the extended attribute
* @param size maximum size of the value to send
*/
void (*getxattr)(fuse_req_t req, uint64_t ino, const char *name,
size_t size);
void (*getxattr)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* List extended attribute names
@ -715,7 +712,8 @@ struct fuse_lowlevel_ops
* @param ino the inode number
* @param size maximum size of the list to send
*/
void (*listxattr)(fuse_req_t req, uint64_t ino, size_t size);
void (*listxattr)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Remove an extended attribute
@ -727,7 +725,8 @@ struct fuse_lowlevel_ops
* @param ino the inode number
* @param name of the extended attribute
*/
void (*removexattr)(fuse_req_t req, uint64_t ino, const char *name);
void (*removexattr)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Check file access permissions
@ -747,7 +746,8 @@ struct fuse_lowlevel_ops
* @param ino the inode number
* @param mask requested access mode
*/
void (*access)(fuse_req_t req, uint64_t ino, int mask);
void (*access)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Create and open a file
@ -782,8 +782,8 @@ struct fuse_lowlevel_ops
* @param mode file type and mode with which to create the new file
* @param fi file information
*/
void (*create)(fuse_req_t req, uint64_t parent, const char *name,
mode_t mode, fuse_file_info_t *fi);
void (*create)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Test for a POSIX file lock
@ -799,9 +799,8 @@ struct fuse_lowlevel_ops
* @param fi file information
* @param lock the region/type to test
*/
void (*getlk)(fuse_req_t req, uint64_t ino,
fuse_file_info_t *fi, struct flock *lock);
void (*getlk)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Acquire, modify or release a POSIX file lock
*
@ -847,8 +846,8 @@ struct fuse_lowlevel_ops
* @param blocksize unit of block index
* @param idx block index within file
*/
void (*bmap)(fuse_req_t req, uint64_t ino, size_t blocksize,
uint64_t idx);
void (*bmap)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Ioctl
@ -877,9 +876,8 @@ struct fuse_lowlevel_ops
* @param in_bufsz number of fetched bytes
* @param out_bufsz maximum size of output data
*/
void (*ioctl)(fuse_req_t req, uint64_t ino, unsigned long cmd, void *arg,
fuse_file_info_t *fi, unsigned flags,
const void *in_buf, uint32_t in_bufsz, uint32_t out_bufsz);
void (*ioctl)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Poll for IO readiness
@ -907,40 +905,8 @@ struct fuse_lowlevel_ops
* @param fi file information
* @param ph poll handle to be used for notification
*/
void (*poll)(fuse_req_t req,
uint64_t ino,
fuse_file_info_t *fi,
fuse_pollhandle_t *ph);
/**
* Write data made available in a buffer
*
* This is a more generic version of the ->write() method. If
* FUSE_CAP_SPLICE_READ is set in fuse_conn_info.want and the
* kernel supports splicing from the fuse device, then the
* data will be made available in pipe for supporting zero
* copy data transfer.
*
* buf->count is guaranteed to be one (and thus buf->idx is
* always zero). The write_buf handler must ensure that
* bufv->off is correctly updated (reflecting the number of
* bytes read from bufv->buf[0]).
*
* Introduced in version 2.9
*
* Valid replies:
* fuse_reply_write
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param bufv buffer containing the data
* @param off offset to write to
* @param fi file information
*/
void (*write_buf)(fuse_req_t req, uint64_t ino,
struct fuse_bufvec *bufv, off_t off,
fuse_file_info_t *fi);
void (*poll)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Callback function for the retrieve request
@ -974,8 +940,8 @@ struct fuse_lowlevel_ops
*
* @param req request handle
*/
void (*forget_multi)(fuse_req_t req, size_t count,
struct fuse_forget_data *forgets);
void (*forget_multi)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Acquire, modify or release a BSD file lock
@ -1014,8 +980,8 @@ struct fuse_lowlevel_ops
* @param mode determines the operation to be performed on the given range,
* see fallocate(2)
*/
void (*fallocate)(fuse_req_t req, uint64_t ino, int mode,
off_t offset, off_t length, fuse_file_info_t *fi);
void (*fallocate)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Copy a range of data from one file to another
@ -1053,15 +1019,8 @@ struct fuse_lowlevel_ops
* @param len maximum size of the data to copy
* @param flags passed along with the copy_file_range() syscall
*/
void (*copy_file_range)(fuse_req_t req,
uint64_t ino_in,
off_t off_in,
fuse_file_info_t *fi_in,
uint64_t ino_out,
off_t off_out,
fuse_file_info_t *fi_out,
size_t len,
int flags);
void (*copy_file_range)(fuse_req_t req,
const struct fuse_in_header *hdr);
};
/**
@ -1164,7 +1123,8 @@ int fuse_reply_readlink(fuse_req_t req, const char *link);
* @param fi file information
* @return zero for success, -errno for failure to send reply
*/
int fuse_reply_open(fuse_req_t req, const fuse_file_info_t *fi);
int fuse_reply_open(fuse_req_t req,
const fuse_file_info_t *fi);
/**
* Reply with number of bytes written