On 17/12/2013 12:29 am, Sebastian Huber wrote:
Pass also zero-size buffers to the write handler since they may have side-effects for non-regular files, e.g. sending of an empty message.
I agree regular files should follow the standard with others being unspecified. I do not think this patch does this.
@@ -31,95 +29,31 @@ ssize_t writev( { ssize_t total; int v; - int bytes; rtems_libio_t *iop; - ssize_t old; - bool all_zeros; - rtems_libio_check_fd( fd ); - iop = rtems_libio_iop( fd ); - rtems_libio_check_is_open( iop ); - rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_WRITE, EBADF ); - - /* - * Argument validation on IO vector - */ - if ( !iov ) - rtems_set_errno_and_return_minus_one( EINVAL ); - - if ( iovcnt <= 0 ) - rtems_set_errno_and_return_minus_one( EINVAL ); - - if ( iovcnt > IOV_MAX ) - rtems_set_errno_and_return_minus_one( EINVAL ); - - /* - * OpenGroup says that you are supposed to return EINVAL if the - * sum of the iov_len values in the iov array would overflow a - * ssize_t. - * - * Also we would like to ensure that no IO is performed if there - * are obvious errors in the iovec. So this extra loop ensures - * that we do not do anything if there is an argument error. - * - * In addition,the OpenGroup specification says that if all the - * iov_len entries are zero, then the call has no effect. So - * this loop does that check as well and sets "all-zero" appropriately. - * The variable "all_zero" is used as an early exit point before - * entering the write loop. - */ - all_zeros = true; - for ( old=0, total=0, v=0 ; v < iovcnt ; v++ ) { + total = rtems_libio_iovec_eval( fd, iov, iovcnt, LIBIO_FLAGS_WRITE, &iop ); + if ( total >= 0 ) {
I am not sure about this...
- /* - * A writev with all zeros is supposed to have no effect per OpenGroup. - */ - if ( all_zeros == true ) { - return 0; - }
... as this statement is correct if the file is a regular file. I think a check for a regular file is needed if the total is 0.
Chris _______________________________________________ rtems-devel mailing list rtems-devel@rtems.org http://www.rtems.org/mailman/listinfo/rtems-devel