DragonFly BSD
DragonFly kernel List (threaded) for 2003-10
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: splitting fnctl(), ioctl()


From: "David P. Reese, Jr." <daver@xxxxxxxxxxxx>
Date: Sun, 12 Oct 2003 23:29:36 -0700

On Fri, Oct 10, 2003 at 02:10:18PM -0700, Matthew Dillon wrote:
> :Not yet.  However, I expect them to look like:
> :
> :int
> :fcntl_copyin(int cmd, caddr_t arg, caddr_t buf)
> :{
> :	switch (cmd) {
> :	case F_GETFD:
> :		break;
> :[snip]
> :	case F_SETLK:
> :		copyin(uap->arg, buf, sizeof(struct flock);
> :		break;
> :	case F_GETLK:
> :		copyin(uap->arg, buf, sizeof(struct flock);
> :		break;
> :	}
> :}
> :
> :int
> :fcntl_copyout(int cmd, caddr_t arg, caddr_t buf)
> :{
> :	switch (cmd) {
> :	case F_GETFD:
> :		break;
> :[snip]
> :	case F_SETLK:
> :		break;
> :	case F_GETLK:
> :		copyout(buf, uap->arg, sizeof(struct flock);
> :	}
> :}
> :
> :While they get most of the job done, I don't like the fact that this
> :method separates the code.
> :
> :-- 
> :   David P. Reese, Jr.                                     daver@xxxxxxxxxxxx
> 
>     Hmm.  Since the copyin and copyout are going to be overriden by 
>     emulation code, isn't there only going to be (approximately) one
>     call to fcntl_copyin() and fcntl_copyout() over the whole source
>     base?  In that case you might as well do away with fcntl_copyin()
>     and fcntl_copyout() and just embed the work in the fcntl() syscall,
>     with the kern_fcntl() call nestled in between.
> 
>     Then instead of having a 'buf' you could have a union which contains
>     all the structs that might be needed to be copied in and out, which is
>     then passed to kern_fcntl().
> 
> 					-Matt
> 					Matthew Dillon 
> 					<dillon@xxxxxxxxxxxxx>

Now that I'm back in town and had a chance to look at fcntl() again, I agree
that this is a better approach.  The syscall does copyin/copyout's only on
a struct flock.  Thus, I think kern_fcntl() will be prototyped as:

int kern_fcntl(int fd, int cmd, struct flock *fl);

For any cmd that doesn't take a struct flock, I'll just pass a null pointer.

The ioctl() syscall will be an entirely different story.

-- 
   David P. Reese, Jr.                                     daver@xxxxxxxxxxxx
                                               http://www.gomerbud.com/daver/



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]