Create a fileops fo_stat() entry point. This will enable collection

of a bunch of duplicated code that breaks (read: panic) when a new
file type is added and some switch/case entries are missed.
This commit is contained in:
Peter Wemm 1999-11-08 03:25:23 +00:00
parent db8cd7ce1f
commit a2eec8ee15
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=52981

View File

@ -45,6 +45,7 @@
#ifdef KERNEL
#include <sys/queue.h>
struct stat;
struct proc;
struct uio;
@ -75,6 +76,8 @@ struct file {
caddr_t data, struct proc *p));
int (*fo_poll) __P((struct file *fp, int events,
struct ucred *cred, struct proc *p));
int (*fo_stat) __P((struct file *fp, struct stat *sb,
struct proc *p));
int (*fo_close) __P((struct file *fp, struct proc *p));
} *f_ops;
int f_seqcount; /*
@ -119,6 +122,8 @@ static __inline int fo_ioctl __P((struct file *fp, u_long com, caddr_t data,
struct proc *p));
static __inline int fo_poll __P((struct file *fp, int events,
struct ucred *cred, struct proc *p));
static __inline int fo_stat __P((struct file *fp, struct stat *sb,
struct proc *p));
static __inline int fo_close __P((struct file *fp, struct proc *p));
static __inline int
@ -183,6 +188,20 @@ fo_poll(fp, events, cred, p)
return (error);
}
static __inline int
fo_stat(fp, sb, p)
struct file *fp;
struct stat *sb;
struct proc *p;
{
int error;
fhold(fp);
error = (*fp->f_ops->fo_stat)(fp, sb, p);
fdrop(fp, p);
return (error);
}
static __inline int
fo_close(fp, p)
struct file *fp;