Subject: Re: struct fileops: why first arg of stat function is void *
To: Luke Mewburn <lukem@wasabisystems.com>
From: Jaromír <jdolecek@netbsd.org>
List: tech-kern
Date: 04/08/2001 18:40:45
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.

Jaromir
-- 
Jaromir Dolecek <jdolecek@NetBSD.org>      http://www.ics.muni.cz/~dolecek/
NetBSD - just plain best OS! -=<>=- Got spare MCA cards or docs? Hand me them!