splitting fnctl(), ioctl()

Matthew Dillon dillon at apollo.backplane.com
Fri Oct 10 14:12:28 PDT 2003


: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 at 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 at xxxxxxxxxxxxx>





More information about the Kernel mailing list