kernel/fs: Reorder fd_ops and add readv/writev hooks.

* Put close/free at the beginning since all FDs must implement that.
   (Most of the function declarations inline were already in this order.)

 * Add readv/writev hooks. Not used yet, but this will allow for
   more than just files to implement them. All declarations updated
   to have NULL for the hooks for the moment.
This commit is contained in:
Augustin Cavalier
2024-07-23 16:55:30 -04:00
parent 65a86bce72
commit 22b7491d3c
4 changed files with 46 additions and 43 deletions
+11 -2
View File
@@ -21,27 +21,36 @@ struct selectsync;
struct select_info;
struct fd_ops {
status_t (*fd_close)(struct file_descriptor *);
void (*fd_free)(struct file_descriptor *);
status_t (*fd_read)(struct file_descriptor *, off_t pos, void *buffer,
size_t *length);
status_t (*fd_write)(struct file_descriptor *, off_t pos,
const void *buffer, size_t *length);
ssize_t (*fd_readv)(struct file_descriptor *, off_t pos,
const struct iovec *vecs, int count);
ssize_t (*fd_writev)(struct file_descriptor *, off_t pos,
const struct iovec *vecs, int count);
off_t (*fd_seek)(struct file_descriptor *, off_t pos, int seekType);
status_t (*fd_ioctl)(struct file_descriptor *, ulong op, void *buffer,
size_t length);
status_t (*fd_set_flags)(struct file_descriptor *, int flags);
status_t (*fd_select)(struct file_descriptor *, uint8 event,
struct selectsync *sync);
status_t (*fd_deselect)(struct file_descriptor *, uint8 event,
struct selectsync *sync);
status_t (*fd_read_dir)(struct io_context* ioContext,
struct file_descriptor *, struct dirent *buffer,
size_t bufferSize, uint32 *_count);
status_t (*fd_rewind_dir)(struct file_descriptor *);
status_t (*fd_read_stat)(struct file_descriptor *, struct stat *);
status_t (*fd_write_stat)(struct file_descriptor *, const struct stat *,
int statMask);
status_t (*fd_close)(struct file_descriptor *);
void (*fd_free)(struct file_descriptor *);
};
struct file_descriptor {