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

Unified Diff: libraries/nacl-mounts/net/IOInterfaces.h

Issue 10392070: Socket subsystem implementation (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src/
Patch Set: Created 8 years, 7 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: libraries/nacl-mounts/net/IOInterfaces.h
===================================================================
--- libraries/nacl-mounts/net/IOInterfaces.h (revision 0)
+++ libraries/nacl-mounts/net/IOInterfaces.h (revision 0)
@@ -0,0 +1,77 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef FILE_INTERFACES_H
+#define FILE_INTERFACES_H
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sys/dir.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "../base/nacl_dirent.h"
Dmitry Polukhin 2012/05/31 14:06:45 I think all path should be from root of nacl-mount
vissi 2012/06/01 09:12:57 Maybe, however, there are lots of usages like this
Dmitry Polukhin 2012/06/01 09:52:13 It is really ugly and there is no reason for doing
+
+class FileStream {
+ public:
+ virtual ~FileStream() {}
+
+ virtual void addref() = 0;
+ virtual void release() = 0;
+
+ virtual void close() = 0;
+ virtual int read(char* buf, size_t count, size_t* nread) = 0;
+ virtual int write(const char* buf, size_t count, size_t* nwrote) = 0;
+ virtual int seek(nacl_abi_off_t offset, int whence,
+ nacl_abi_off_t* new_offset) {
+ return ESPIPE;
+ }
+ virtual int fstat(nacl_abi_stat* out) {
+ memset(out, 0, sizeof(nacl_abi_stat));
+ return 0;
+ }
+ virtual int getdents(dirent* buf, size_t count, size_t* nread) {
+ return ENOTDIR;
+ }
+
+ virtual int isatty() {
+ errno = EINVAL;
+ return 0;
+ }
+ virtual int fcntl(int cmd, va_list ap) {
+ errno = EINVAL;
+ return -1;
+ }
+ virtual int ioctl(int request, va_list ap) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ virtual bool is_read_ready() {
+ return true;
+ }
+ virtual bool is_write_ready() {
+ return true;
+ }
+ virtual bool is_exception() {
+ return false;
+ }
+};
+
+class PathHandler {
+ public:
+ virtual ~PathHandler() {}
+
+ virtual void addref() = 0;
+ virtual void release() = 0;
+
+ virtual FileStream* open(int fd, const char* pathname, int oflag) = 0;
+ virtual int stat(const char* pathname, nacl_abi_stat* out) = 0;
+};
+
+#endif // FILE_INTERFACES_H
+

Powered by Google App Engine
This is Rietveld 408576698