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 1999-11-08 03:25:23 +00:00
parent 6799b6248c
commit c3eff14a6d

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;