Skip to content
Snippets Groups Projects
Commit c67f9ebf authored by Avi Kivity's avatar Avi Kivity
Browse files

file: remove fileops


Everyone is now overriding file's virtual functions; we can make them
pure virtual and remove fileops completely.

Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
parent 57741446
No related branches found
No related tags found
No related merge requests found
......@@ -152,60 +152,14 @@ int fget(int fd, struct file **out_fp)
return 0;
}
file::file(unsigned flags, filetype_t type, void *opaque,
struct fileops *ops)
file::file(unsigned flags, filetype_t type, void *opaque)
: f_flags(flags)
, f_count(1)
, f_ops(ops)
, f_data(opaque)
, f_type(type)
{
auto fp = this;
TAILQ_INIT(&fp->f_poll_list);
if (ops) {
fo_init(fp);
}
}
int file::read(struct uio *uio, int flags)
{
return f_ops->fo_read(this, uio, flags);
}
int file::write(struct uio *uio, int flags)
{
return f_ops->fo_write(this, uio, flags);
}
int file::truncate(off_t len)
{
return f_ops->fo_truncate(this, len);
}
int file::ioctl(u_long com, void *data)
{
return f_ops->fo_ioctl(this, com, data);
}
int file::poll(int events)
{
return f_ops->fo_poll(this, events);
}
int file::stat(struct stat* buf)
{
return f_ops->fo_stat(this, buf);
}
int file::close()
{
return f_ops->fo_close(this);
}
int file::chmod(mode_t mode)
{
return f_ops->fo_chmod(this, mode);
}
void fhold(struct file* fp)
......@@ -252,12 +206,6 @@ void file_setdata(file* fp, void* data)
fp->f_data = data;
}
int
fo_init(struct file *fp)
{
return fp->f_ops->fo_init(fp);
}
int
fo_read(struct file *fp, struct uio *uio, int flags)
{
......
......@@ -62,7 +62,6 @@ typedef enum {
} filetype_t;
struct vnode;
struct fileops;
struct file;
#define FDMAX (0x4000)
......@@ -74,25 +73,23 @@ struct file;
* File structure
*/
struct file {
file(unsigned flags, filetype_t type, void *opaque = nullptr,
struct fileops *ops = nullptr);
file(unsigned flags, filetype_t type, void *opaque = nullptr);
virtual ~file();
void operator delete(void *p) { osv::rcu_dispose(p); }
virtual int read(struct uio *uio, int flags);
virtual int write(struct uio *uio, int flags);
virtual int truncate(off_t len);
virtual int ioctl(u_long com, void *data);
virtual int poll(int events);
virtual int stat(struct stat* buf);
virtual int close();
virtual int chmod(mode_t mode);
virtual int read(struct uio *uio, int flags) = 0;
virtual int write(struct uio *uio, int flags) = 0;
virtual int truncate(off_t len) = 0;
virtual int ioctl(u_long com, void *data) = 0;
virtual int poll(int events) = 0;
virtual int stat(struct stat* buf) = 0;
virtual int close() = 0;
virtual int chmod(mode_t mode) = 0;
int f_flags; /* open flags */
int f_count; /* reference count, see below */
off_t f_offset = 0; /* current position in file */
struct dentry *f_dentry = nullptr; /* dentry */
struct fileops *f_ops; /* file ops abstraction */
void *f_data; /* file descriptor specific data */
filetype_t f_type; /* descriptor type */
TAILQ_HEAD(, poll_link) f_poll_list; /* poll request list */
......@@ -125,18 +122,6 @@ typedef int fo_close_t(struct file *fp);
typedef int fo_chmod_t(struct file *fp, mode_t mode);
struct fileops {
fo_init_t *fo_init;
fo_rdwr_t *fo_read;
fo_rdwr_t *fo_write;
fo_truncate_t *fo_truncate;
fo_ioctl_t *fo_ioctl;
fo_poll_t *fo_poll;
fo_stat_t *fo_stat;
fo_close_t *fo_close;
fo_chmod_t *fo_chmod;
};
/* Alloc an fd for fp */
int _fdalloc(struct file *fp, int *newfd, int min_fd);
int fdalloc(struct file* fp, int *newfd);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment