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
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
);
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(off_t
* out_size
);
57 virtual Error
Futimens(const struct timespec times
[2]);
58 virtual Error
Fchmod(mode_t mode
);
61 struct fuse_operations
* fuse_ops_
;
62 struct fuse_file_info info_
;
66 class FileFuseFsNode
: public FuseFsNode
{
68 FileFuseFsNode(Filesystem
* filesystem
,
69 struct fuse_operations
* fuse_ops
,
70 struct fuse_file_info
& info
,
71 const std::string
& path
);
74 virtual void Destroy();
77 virtual Error
FSync();
78 virtual Error
FTruncate(off_t length
);
79 virtual Error
Read(const HandleAttr
& attr
,
83 virtual Error
Write(const HandleAttr
& attr
,
90 DISALLOW_COPY_AND_ASSIGN(FileFuseFsNode
);
93 class DirFuseFsNode
: public FuseFsNode
{
95 DirFuseFsNode(Filesystem
* filesystem
,
96 struct fuse_operations
* fuse_ops
,
97 struct fuse_file_info
& info
,
98 const std::string
& path
);
101 virtual void Destroy();
104 virtual Error
FSync();
105 virtual Error
GetDents(size_t offs
,
111 static int FillDirCallback(void* buf
,
113 const struct stat
* stbuf
,
118 DISALLOW_COPY_AND_ASSIGN(DirFuseFsNode
);
121 } // namespace nacl_io
123 #endif // LIBRARIES_NACL_IO_FUSEFS_FUSE_FS_H_