MCPcopy Create free account
hub / github.com/MemNixFS/MemNixFS / lmpfs_readdir

Function lmpfs_readdir

src/mount/fuse_mount.cpp:130–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128
129#if FUSE_USE_VERSION >= 30
130int lmpfs_readdir(const char* path, void* buf, fuse_fill_dir_t filler,
131 off_t, struct fuse_file_info*,
132 enum fuse_readdir_flags) {
133#else
134int lmpfs_readdir(const char* path, void* buf, fuse_fill_dir_t filler,
135 off_t, struct fuse_file_info*) {
136#endif
137 try {
138 auto node = resolve_node(path);
139 if (!node) return -ENOENT;
140 if (!node->is_dir()) return -ENOTDIR;
141#if FUSE_USE_VERSION >= 30
142 filler(buf, ".", nullptr, 0, static_cast<fuse_fill_dir_flags>(0));
143 filler(buf, "..", nullptr, 0, static_cast<fuse_fill_dir_flags>(0));
144#else
145 filler(buf, ".", nullptr, 0);
146 filler(buf, "..", nullptr, 0);
147#endif
148 for (const auto& e : node->list()) {
149 struct stat st {};
150 fill_stat(e.node, &st, true);
151#if FUSE_USE_VERSION >= 30
152 if (filler(buf, e.name.c_str(), &st, 0,
153 static_cast<fuse_fill_dir_flags>(0)) != 0)
154 break;
155#else
156 if (filler(buf, e.name.c_str(), &st, 0) != 0)
157 break;
158#endif
159 }
160 return 0;
161 } catch (const std::exception&) {
162 return -ENOENT;
163 }
164}
165
166int lmpfs_statfs(const char*, struct statvfs* stbuf) {
167 std::memset(stbuf, 0, sizeof(*stbuf));
168 stbuf->f_bsize = 4096;
169 stbuf->f_frsize = 4096;
170 stbuf->f_blocks = (16ULL * 1024 * 1024 * 1024) / 4096;
171 stbuf->f_bfree = 0;
172 stbuf->f_bavail = 0;
173 stbuf->f_files = 1024 * 1024;
174 stbuf->f_ffree = 0;
175 stbuf->f_namemax = 255;
176 return 0;
177}
178
179fuse_operations make_ops() {
180 fuse_operations ops {};
181 ops.getattr = lmpfs_getattr;
182 ops.open = lmpfs_open;
183 ops.read = lmpfs_read;
184 ops.readdir = lmpfs_readdir;
185 ops.statfs = lmpfs_statfs;
186 return ops;
187}

Callers

nothing calls this directly

Calls 4

resolve_nodeFunction · 0.85
fill_statFunction · 0.85
is_dirMethod · 0.80
listMethod · 0.80

Tested by

no test coverage detected