Subject: Re: struct fileops: why first arg of stat function is void *
To: =?iso-8859-1?Q?Jarom=EDr_Dolecek?= <jdolecek@netbsd.org>
From: Luke Mewburn <lukem@wasabisystems.com>
List: tech-kern
Date: 04/09/2001 15:40:53
On Sun, Apr 08, 2001 at 06:40:45PM +0200, Jaromír Dolecek wrote:
> Luke Mewburn wrote:
> > > Log Message:
> > > Add new 'stat' fileop and call the stat function via f_ops rather
> > > than directly.
> > > For compat syscalls, also add necessary FILE_USE()/FILE_UNUSE().
> > > Now that soo_stat() gets a proc arg, pass it on to usrreq function.
> > 
> > Hi Jaromir.
> > 
> > I notice that FreeBSD had done this a while ago.
> > 
> > One question; is there any reason why fo_stat is declared as:
> > 	int (*fo_stat)	(void *fdata, struct stat *sp, struct proc *p);
> > instead of
> > 	int (*fo_stat)	(struct file *fp, struct stat *sp, struct proc *p);
> > ?
> > 
> > I.e, why is the first argument `void *' instead of `struct file *',
> > which is what all the other struct fileops {} items have (and is also
> > the way FreeBSD implements fo_stat)?
> 
> The primary reason being that vn_stat() is used outside of fileops
> context couple of times (like in other *stat(2) calls) and it didn't
> seem right to push a struct file * there.

so why not follow what freebsd did and put a vn_statfile() in as the
fileops fo_stat function, which is a wrapper to vn_stat()?

as it appears that we were inspired by freebsd for this change, i
can't see why we're gratuitiously incompatible...

also, every other fo_* function takes a struct file * as the first
arg, so it's consistent there too...