summaryrefslogtreecommitdiffhomepage
path: root/test/util/fuse_util.cc
diff options
context:
space:
mode:
authorCraig Chi <craigchi@google.com>2020-08-28 11:25:19 -0700
committerAndrei Vagin <avagin@gmail.com>2020-09-16 12:19:30 -0700
commite63abd82ddfbaeb35c1dfc7c553db3d78207b037 (patch)
tree20c3d2a94390b7a01e8f4ffed9d5dd1e41c15035 /test/util/fuse_util.cc
parent98faed55e682cf34bb713c37b063a7d1da5e8352 (diff)
Add default attr in fuse_util
fuse_util provides utilities for fuse testing. Add a function to return a stub fuse_attr struct with specified mode and nodeid.
Diffstat (limited to 'test/util/fuse_util.cc')
-rw-r--r--test/util/fuse_util.cc52
1 files changed, 28 insertions, 24 deletions
diff --git a/test/util/fuse_util.cc b/test/util/fuse_util.cc
index 5b10a9e45..4db053335 100644
--- a/test/util/fuse_util.cc
+++ b/test/util/fuse_util.cc
@@ -22,35 +22,39 @@
namespace gvisor {
namespace testing {
-// Create response body with specified mode and nodeID.
-fuse_entry_out DefaultEntryOut(mode_t mode, uint64_t node_id) {
+// Create a default FuseAttr struct with specified mode and inode.
+fuse_attr DefaultFuseAttr(mode_t mode, uint64_t inode) {
const int time_sec = 1595436289;
const int time_nsec = 134150844;
+ return (struct fuse_attr){
+ .ino = inode,
+ .size = 512,
+ .blocks = 4,
+ .atime = time_sec,
+ .mtime = time_sec,
+ .ctime = time_sec,
+ .atimensec = time_nsec,
+ .mtimensec = time_nsec,
+ .ctimensec = time_nsec,
+ .mode = mode,
+ .nlink = 2,
+ .uid = 1234,
+ .gid = 4321,
+ .rdev = 12,
+ .blksize = 4096,
+ };
+}
+
+// Create response body with specified mode and nodeID.
+fuse_entry_out DefaultEntryOut(mode_t mode, uint64_t node_id) {
struct fuse_entry_out default_entry_out = {
.nodeid = node_id,
.generation = 0,
- .entry_valid = time_sec,
- .attr_valid = time_sec,
- .entry_valid_nsec = time_nsec,
- .attr_valid_nsec = time_nsec,
- .attr =
- (struct fuse_attr){
- .ino = node_id,
- .size = 512,
- .blocks = 4,
- .atime = time_sec,
- .mtime = time_sec,
- .ctime = time_sec,
- .atimensec = time_nsec,
- .mtimensec = time_nsec,
- .ctimensec = time_nsec,
- .mode = mode,
- .nlink = 2,
- .uid = 1234,
- .gid = 4321,
- .rdev = 12,
- .blksize = 4096,
- },
+ .entry_valid = 0,
+ .attr_valid = 0,
+ .entry_valid_nsec = 0,
+ .attr_valid_nsec = 0,
+ .attr = DefaultFuseAttr(mode, node_id),
};
return default_entry_out;
};