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

Unified Diff: libraries/nacl-mounts/dev/DevMount.h

Issue 10377102: Added simplest device mount implementation (includes NullDevice and RandomDevice) (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/dev/DevMount.h
===================================================================
--- libraries/nacl-mounts/dev/DevMount.h (revision 0)
+++ libraries/nacl-mounts/dev/DevMount.h (revision 0)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012 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.
+ */
+#ifndef PACKAGES_LIBRARIES_NACL_MOUNTS_DEV_DEVMOUNT_H_
+#define PACKAGES_LIBRARIES_NACL_MOUNTS_DEV_DEVMOUNT_H_
+
+#include <map>
+#include <string>
+#include "../base/BaseMount.h"
+#include "../dev/Device.h"
+#include "../util/macros.h"
+
+// DevMount
+class DevMount: public BaseMount {
+ public:
+ DevMount() {}
+ virtual ~DevMount() {}
+
+ int Creat(const std::string& path, mode_t mode, struct stat* st);
+ int GetNode(const std::string& path, struct stat* st);
+
+ int Stat(ino_t node, struct stat *buf);
+ ssize_t Read(ino_t node, off_t offset, void *buf, size_t count);
+ ssize_t Write(ino_t node, off_t offset, const void *buf, size_t count);
+ int Isatty(ino_t node) { return 0; }
+
+ private:
+ std::map<int, std::string> inode_to_path;
+ std::map<int, Device*> inode_to_dev;
+ std::map<int, int> inode_to_ref;
+ std::map<std::string, int> path_to_inode;
+ int max_inode;
+ void Attach(std::string path, Device* device);
+
+ DISALLOW_COPY_AND_ASSIGN(DevMount);
+};
+
+#endif // PACKAGES_LIBRARIES_NACL_MOUNTS_DEV_DEVMOUNT_H_
+

Powered by Google App Engine
This is Rietveld 408576698