Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* Copyright 2015 The Native Client Authors. All rights reserved. | |
| 2 * Use of this source code is governed by a BSD-style license that can be | |
| 3 * found in the LICENSE file. */ | |
| 4 | |
| 5 #include <sys/uio.h> | |
| 6 #include <unistd.h> // unix(nacl) standards | |
| 7 #include <errno.h> | |
| 8 | |
| 9 ssize_t readv(int fd, const struct iovec *iov, int iovcnt){ | |
|
binji
2015/08/24 22:28:00
nit: add space between ) and {
here and elsewhere
deepankar-tyagi
2015/08/25 18:14:43
Done.
| |
| 10 if(iovcnt < 0){ | |
|
binji
2015/08/24 22:28:01
nit: space after if
deepankar-tyagi
2015/08/25 18:14:43
Done.
| |
| 11 // #TODO(dt) add check for IOV_MAX | |
| 12 errno = EINVAL; | |
| 13 return -1; | |
| 14 } | |
| 15 ssize_t bytes_read = 0 ; | |
|
binji
2015/08/24 22:28:01
nit: remove space before ;
deepankar-tyagi
2015/08/25 18:14:43
Done.
| |
| 16 ssize_t bytes_supposed_to_be_read = 0 ; | |
| 17 int i; | |
| 18 for (i = 0; i < (iovcnt); i++) { | |
| 19 bytes_read += read(fd, iov[i].iov_base, iov[i].iov_len); | |
|
binji
2015/08/24 22:28:00
nit: remove double space
deepankar-tyagi
2015/08/25 18:14:43
Done.
| |
| 20 bytes_supposed_to_be_read += iov[i].iov_len ; | |
| 21 // #TODO(dt) add check for (max) ssize_t allowed | |
| 22 if (bytes_read != bytes_supposed_to_be_read){ | |
| 23 // deliberately not setting errno here as it might override | |
| 24 // errno set by read(...) | |
| 25 return -1; | |
| 26 } | |
| 27 } | |
| 28 // #TODO(dt) (mark for)update st_atime if required. | |
|
binji
2015/08/24 22:28:00
shouldn't be necessary -- call to read(...) above
deepankar-tyagi
2015/08/25 18:14:43
haven't looked at read(...) implementation yet, fo
| |
| 29 return bytes_read; | |
| 30 } | |
| OLD | NEW |