[PATCH 1/3] libcsupport: Add and use rtems_libio_iovec_eval()

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Dec 17 07:50:45 UTC 2013


On 2013-12-17 02:52, Chris Johns wrote:
> 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...

Ok, I will change this into "if ( total > 0 ) {" since I don't need the total 
== 0 case currently.

Is the rest ok?

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list