diff --git a/fs/vfs/kern_descrip.cc b/fs/vfs/kern_descrip.cc index 28b03aa3176e33590ae521aa75b72684cfec7f69..6983bcf6eb85b88ceb293b92ec41ac9d0fff42e7 100644 --- a/fs/vfs/kern_descrip.cc +++ b/fs/vfs/kern_descrip.cc @@ -152,14 +152,15 @@ int fget(int fd, struct file **out_fp) return 0; } -static void finit(struct file *fp, unsigned flags, filetype_t type, void *opaque, - struct fileops *ops) +file::file(unsigned flags, filetype_t type, void *opaque, + struct fileops *ops) + : f_flags(flags) + , f_count(1) + , f_ops(ops) + , f_data(opaque) + , f_type(type) { - fp->f_flags = flags; - fp->f_type = type; - fp->f_data = opaque; - fp->f_ops = ops; - fp->f_count = 1; + auto fp = this; TAILQ_INIT(&fp->f_poll_list); fo_init(fp); @@ -168,11 +169,10 @@ static void finit(struct file *fp, unsigned flags, filetype_t type, void *opaque fileref make_file(unsigned flags, filetype_t type, void *opaque, struct fileops *ops) { - file* fp = new (std::nothrow) file; + file* fp = new (std::nothrow) file(flags, type, opaque, ops); if (!fp) { throw ENOMEM; } - finit(fp, flags, type, opaque, ops); return fileref(fp, false); } diff --git a/include/osv/file.h b/include/osv/file.h index 38ec0cf97c397fe2c5862d500e182a808c17f922..7e7a9cc62ca5fa14bde7911c4621d62a98e82be4 100755 --- a/include/osv/file.h +++ b/include/osv/file.h @@ -74,6 +74,8 @@ struct file; * File structure */ struct file { + file(unsigned flags, filetype_t type, void *opaque, + struct fileops *ops); ~file(); void operator delete(void *p) { osv::rcu_dispose(p); } int f_flags; /* open flags */