FreeBSD/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c
/*
 * Wrapper around write(2) to handle partial writes.  For maximum safety of
 * output files and proper error reporting, we continuing writing in the
 * face of partial writes until write(2) fails or 'buf' is completely written.
 * We also record any errno in the specified dtrace_hdl_t as well as 'errno'.
 */
Wrapper around write(2) to handle partial writes.  For maximum safety of
output files and proper error reporting, we continuing writing in the
face of partial writes until write(2) fails or 'buf' is completely written.
We also record any errno in the specified dtrace_hdl_t as well as 'errno'.
Wrapper around write ( 2 ) to handle partial writes . For maximum safety of output files and proper error reporting we continuing writing in the face of partial writes until write ( 2 ) fails or ' buf ' is completely written . We also record any errno in the specified dtrace_hdl_t as well as ' errno ' .
ssize_t
dt_write(dtrace_hdl_t *dtp, int fd, const void *buf, size_t n)
{
	ssize_t resid = n;
	ssize_t len;
	while (resid != 0) {
		if ((len = write(fd, buf, resid)) <= 0)
			break;
		resid -= len;
		buf = (char *)buf + len;
	}
	if (resid == n && n != 0)
		return (dt_set_errno(dtp, errno));
	return (n - resid);
}
ssize_t dt_write ( dtrace_hdl_t * dtp , int fd , const void * buf , size_t n ) { ssize_t resid = n ; ssize_t len ; while ( resid != 0 ) { if ( ( len = write ( fd , buf , resid ) ) <= 0 ) break ; resid -= len ; buf = ( char * ) buf + len ; } if ( resid == n && n != 0 ) return ( dt_set_errno ( dtp , errno ) ) ; return ( n - resid ) ; }
Wrapper around write(2) to handle partial writes.
Wrapper around write ( 2 ) to handle partial writes .