From a2eec8ee15eeabb3c1d32dd9fe4571b1369246dd Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Mon, 8 Nov 1999 03:25:23 +0000 Subject: [PATCH] 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. --- sys/sys/file.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sys/sys/file.h b/sys/sys/file.h index 47557d40661..014a2931b67 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -45,6 +45,7 @@ #ifdef KERNEL #include +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;