DragonFly kernel List (threaded) for 2003-10
Re: iovec_copyin() helper function
: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);
: 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
: 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*()
: David P. Reese, Jr. daver@xxxxxxxxxxxx
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