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

Re: iovec_copyin() helper function


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 6 Oct 2003 18:37:14 -0700 (PDT)

:I'd like to create an iovec_copyin() function to cut the length of the
:socket syscall code.  This could be used in the emulation code and
:other syscall code (eg. writev(), readv()).
:
:int iovec_copyin(struct iovec *uiov, struct iovec **kiov, struct iovec *siov,
:	size_t iov_cnt, size_t *iov_len);
:
:Where:
:   o uiov is a pointer to the userspace iovec structure.
:   o kiov returns a pointer to the populated kernel space iovec structure.
:   o siov is a pointer to a kernel space iovec structure of length
:     UIO_SMALLIOV.
:   o iov_cnt is the length of the desired iovec structure array.
:   o iov_len is a pointer used to return the lenght of the data in bytes,
:     useful for populating the uio_resid field in uio structures.
:
:In the parent function, one must remember to check the address of kiov
:against siov and FREE(kiov, M_IOV) if they differ.
:
:Would something like this belong in kern/kern_subr.c with the uio*()
:functions?
:
:-- 
:   David P. Reese, Jr.                                     daver@xxxxxxxxxxxx
:                                               http://www.gomerbud.com/daver/

    Even better, also provide iovec_free(kiov, siov), which could be an inline
    function, so callers do not get polluted with having to know that the
    allocation was conditional.

    kern/kern_subr.c is as good a place as any.

    In anycase, it's a great idea, go for it!  There are something like
    6 places where that mess is duplicated in kern/sys_generic.c,
    kern/uipc_syscalls.c, and kern/vfs_syscalls.c

					-Matt
					Matthew Dillon 
					<dillon@xxxxxxxxxxxxx>



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