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

Side by Side Diff: native_client_sdk/src/libraries/nacl_mounts/kernel_proxy.h

Issue 12194030: Rename mount (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix whitespace Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /* Copyright (c) 2012 The Chromium 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 #ifndef LIBRARIES_NACL_MOUNTS_KERNEL_PROXY_H_
6 #define LIBRARIES_NACL_MOUNTS_KERNEL_PROXY_H_
7
8 #include <ppapi/c/pp_instance.h>
9 #include <ppapi/c/ppb.h>
10 #include <pthread.h>
11 #include <map>
12 #include <string>
13 #include <vector>
14
15 #include "nacl_mounts/kernel_object.h"
16 #include "nacl_mounts/mount.h"
17 #include "nacl_mounts/ostypes.h"
18 #include "nacl_mounts/path.h"
19
20 class KernelHandle;
21 class Mount;
22 class MountNode;
23 class PepperInterface;
24
25 // KernelProxy provide one-to-one mapping for libc kernel calls. Calls to the
26 // proxy will result in IO access to the provided Mount and MountNode objects.
27 class KernelProxy : protected KernelObject {
28 public:
29 typedef Mount* (*MountFactory_t)(int, StringMap_t&, PepperInterface*);
30 typedef std::map<std::string, std::string> StringMap_t;
31 typedef std::map<std::string, MountFactory_t> MountFactoryMap_t;
32
33 KernelProxy();
34 virtual ~KernelProxy();
35 // Takes ownership of |ppapi|.
36 // |ppapi| may be NULL. If so, no mount that uses pepper calls can be mounted.
37 virtual void Init(PepperInterface* ppapi);
38
39 // KernelHandle and FD allocation and manipulation functions.
40 virtual int open(const char *path, int oflag);
41 virtual int close(int fd);
42 virtual int dup(int fd);
43 virtual int dup2(int fd, int newfd);
44
45 // System calls handled by KernelProxy (not mount-specific)
46 virtual int chdir(const char* path);
47 virtual char* getcwd(char* buf, size_t size);
48 virtual char* getwd(char* buf);
49 virtual int mount(const char *source, const char *target,
50 const char *filesystemtype, unsigned long mountflags, const void *data);
51 virtual int umount(const char *path);
52
53 // System calls that take a path as an argument:
54 // The kernel proxy will look for the Node associated to the path. To
55 // find the node, the kernel proxy calls the corresponding mount's GetNode()
56 // method. The corresponding method will be called. If the node
57 // cannot be found, errno is set and -1 is returned.
58 virtual int chmod(const char *path, mode_t mode);
59 virtual int mkdir(const char *path, mode_t mode);
60 virtual int rmdir(const char *path);
61 virtual int stat(const char *path, struct stat *buf);
62
63 // System calls that take a file descriptor as an argument:
64 // The kernel proxy will determine to which mount the file
65 // descriptor's corresponding file handle belongs. The
66 // associated mount's function will be called.
67 virtual ssize_t read(int fd, void *buf, size_t nbyte);
68 virtual ssize_t write(int fd, const void *buf, size_t nbyte);
69
70 virtual int fchmod(int fd, int prot);
71 virtual int fstat(int fd, struct stat *buf);
72 virtual int getdents(int fd, void *buf, unsigned int count);
73 virtual int fsync(int fd);
74 virtual int isatty(int fd);
75
76 // lseek() relies on the mount's Stat() to determine whether or not the
77 // file handle corresponding to fd is a directory
78 virtual off_t lseek(int fd, off_t offset, int whence);
79
80 // remove() uses the mount's GetNode() and Stat() to determine whether or
81 // not the path corresponds to a directory or a file. The mount's Rmdir()
82 // or Unlink() is called accordingly.
83 virtual int remove(const char* path);
84 // unlink() is a simple wrapper around the mount's Unlink function.
85 virtual int unlink(const char* path);
86 // access() uses the Mount's Stat().
87 virtual int access(const char* path, int amode);
88
89 virtual int link(const char* oldpath, const char* newpath);
90 virtual int symlink(const char* oldpath, const char* newpath);
91
92 protected:
93 MountFactoryMap_t factories_;
94 int dev_;
95 PepperInterface* ppapi_;
96
97 static KernelProxy *s_instance_;
98
99 DISALLOW_COPY_AND_ASSIGN(KernelProxy);
100 };
101
102 #endif // LIBRARIES_NACL_MOUNTS_KERNEL_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698