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_
10 #include "nacl_io/filesystem.h"
11 #include "nacl_io/fuse.h"
12 #include "nacl_io/node.h"
16 class FuseFs : public Filesystem {
20 virtual Error Init(const FsInitArgs& args);
21 virtual void Destroy();
24 virtual Error Access(const Path& path, int a_mode);
25 virtual Error Open(const Path& path, int mode, 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);
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 {
43 FuseFsNode(Filesystem* filesystem,
44 struct fuse_operations* fuse_ops,
45 struct fuse_file_info& info,
46 const std::string& path);
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(size_t* out_size);
59 struct fuse_operations* fuse_ops_;
60 struct fuse_file_info info_;
64 class FileFuseFsNode : public FuseFsNode {
66 FileFuseFsNode(Filesystem* filesystem,
67 struct fuse_operations* fuse_ops,
68 struct fuse_file_info& info,
69 const std::string& path);
72 virtual void Destroy();
75 virtual Error FSync();
76 virtual Error FTruncate(off_t length);
77 virtual Error Read(const HandleAttr& attr,
81 virtual Error Write(const HandleAttr& attr,
88 DISALLOW_COPY_AND_ASSIGN(FileFuseFsNode);
91 class DirFuseFsNode : public FuseFsNode {
93 DirFuseFsNode(Filesystem* filesystem,
94 struct fuse_operations* fuse_ops,
95 struct fuse_file_info& info,
96 const std::string& path);
99 virtual void Destroy();
102 virtual Error FSync();
103 virtual Error GetDents(size_t offs,
109 static int FillDirCallback(void* buf,
111 const struct stat* stbuf,
116 DISALLOW_COPY_AND_ASSIGN(DirFuseFsNode);
119 } // namespace nacl_io
121 #endif // LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_H_