Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / fusefs / fuse_fs.h
blob609714395a4e71770a095aef51e8d2885bd9756a
1 // Copyright 2013 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.
5 #ifndef LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_H_
6 #define LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_H_
8 #include <map>
10 #include "nacl_io/filesystem.h"
11 #include "nacl_io/fuse.h"
12 #include "nacl_io/node.h"
14 namespace nacl_io {
16 class FuseFs : public Filesystem {
17 protected:
18 FuseFs();
20 virtual Error Init(const FsInitArgs& args);
21 virtual void Destroy();
23 public:
24 virtual Error OpenWithMode(const Path& path, int open_flags, mode_t mode,
25 ScopedNode* out_node);
26 virtual Error Unlink(const Path& path);
27 virtual Error Mkdir(const Path& path, int perm);
28 virtual Error Rmdir(const Path& path);
29 virtual Error Remove(const Path& path);
30 virtual Error Rename(const Path& path, const Path& newpath);
32 private:
33 struct fuse_operations* fuse_ops_;
34 void* fuse_user_data_;
36 friend class FuseFsNode;
37 friend class FuseFsFactory;
38 DISALLOW_COPY_AND_ASSIGN(FuseFs);
41 class FuseFsNode : public Node {
42 protected:
43 FuseFsNode(Filesystem* filesystem,
44 struct fuse_operations* fuse_ops,
45 struct fuse_file_info& info,
46 const std::string& path);
48 public:
49 virtual bool CanOpen(int open_flags);
50 virtual Error GetStat(struct stat* stat);
51 virtual Error VIoctl(int request, va_list args);
52 virtual Error Tcflush(int queue_selector);
53 virtual Error Tcgetattr(struct termios* termios_p);
54 virtual Error Tcsetattr(int optional_actions,
55 const struct termios* termios_p);
56 virtual Error GetSize(off_t* out_size);
57 virtual Error Futimens(const struct timespec times[2]);
58 virtual Error Fchmod(mode_t mode);
60 protected:
61 struct fuse_operations* fuse_ops_;
62 struct fuse_file_info info_;
63 std::string path_;
66 class FileFuseFsNode : public FuseFsNode {
67 public:
68 FileFuseFsNode(Filesystem* filesystem,
69 struct fuse_operations* fuse_ops,
70 struct fuse_file_info& info,
71 const std::string& path);
73 protected:
74 virtual void Destroy();
76 public:
77 virtual Error FSync();
78 virtual Error FTruncate(off_t length);
79 virtual Error Read(const HandleAttr& attr,
80 void* buf,
81 size_t count,
82 int* out_bytes);
83 virtual Error Write(const HandleAttr& attr,
84 const void* buf,
85 size_t count,
86 int* out_bytes);
88 private:
89 friend class FuseFs;
90 DISALLOW_COPY_AND_ASSIGN(FileFuseFsNode);
93 class DirFuseFsNode : public FuseFsNode {
94 public:
95 DirFuseFsNode(Filesystem* filesystem,
96 struct fuse_operations* fuse_ops,
97 struct fuse_file_info& info,
98 const std::string& path);
100 protected:
101 virtual void Destroy();
103 public:
104 virtual Error FSync();
105 virtual Error GetDents(size_t offs,
106 struct dirent* pdir,
107 size_t count,
108 int* out_bytes);
110 private:
111 static int FillDirCallback(void* buf,
112 const char* name,
113 const struct stat* stbuf,
114 off_t off);
116 private:
117 friend class FuseFs;
118 DISALLOW_COPY_AND_ASSIGN(DirFuseFsNode);
121 } // namespace nacl_io
123 #endif // LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_H_