Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: ports/glibc-compat/src/readv.c

Issue 1289343005: Added Tor (Closed) Base URL: https://chromium.googlesource.com/external/naclports.git@pepper_44
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ports/glibc-compat/src/readv.c
diff --git a/ports/glibc-compat/src/readv.c b/ports/glibc-compat/src/readv.c
new file mode 100644
index 0000000000000000000000000000000000000000..c9433e87b6cd9dd19b7a37ebe464f4cd770c9690
--- /dev/null
+++ b/ports/glibc-compat/src/readv.c
@@ -0,0 +1,30 @@
+/* Copyright 2015 The Native Client Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+#include <sys/uio.h>
+#include <unistd.h> // unix(nacl) standards
+#include <errno.h>
+
+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.
+ if(iovcnt < 0){
binji 2015/08/24 22:28:01 nit: space after if
deepankar-tyagi 2015/08/25 18:14:43 Done.
+ // #TODO(dt) add check for IOV_MAX
+ errno = EINVAL;
+ return -1;
+ }
+ 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.
+ ssize_t bytes_supposed_to_be_read = 0 ;
+ int i;
+ for (i = 0; i < (iovcnt); i++) {
+ 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.
+ bytes_supposed_to_be_read += iov[i].iov_len ;
+ // #TODO(dt) add check for (max) ssize_t allowed
+ if (bytes_read != bytes_supposed_to_be_read){
+ // deliberately not setting errno here as it might override
+ // errno set by read(...)
+ return -1;
+ }
+ }
+ // #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
+ return bytes_read;
+}

Powered by Google App Engine
This is Rietveld 408576698