tst: memfs-fuse3: testing

This commit is contained in:
Bill Zissimopoulos 2019-10-07 18:32:25 -07:00
parent d3d75bf977
commit ce20747534
No known key found for this signature in database
GPG Key ID: 3D4F95D52C7B3EA3
2 changed files with 15 additions and 7 deletions

View File

@ -22,6 +22,13 @@
#ifndef COMPAT_H_INCLUDED #ifndef COMPAT_H_INCLUDED
#define COMPAT_H_INCLUDED #define COMPAT_H_INCLUDED
#if defined(_WIN32) && defined(FSP_FUSE_SYM)
#include <winfsp/winfsp.h>
#undef fuse_main
#define fuse_main(argc, argv, ops, data)\
(FspLoad(0), fuse_main_real(argc, argv, ops, sizeof *(ops), data))
#endif
#if !defined(_WIN32) && !defined(fuse_stat) #if !defined(_WIN32) && !defined(fuse_stat)
#define fuse_uid_t uid_t #define fuse_uid_t uid_t

View File

@ -29,7 +29,7 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <fuse3/fuse.h> #include <fuse.h>
#include "compat.h" #include "compat.h"
class memfs class memfs
@ -153,7 +153,7 @@ private:
return -ENOENT; return -ENOENT;
if (S_IFLNK != (node->stat.st_mode & S_IFMT)) if (S_IFLNK != (node->stat.st_mode & S_IFMT))
return EINVAL; return EINVAL;
size = std::min(size - 1, node->data.size()); size = (std::min)(size - 1, node->data.size());
std::memcpy(buf, node->data.data(), size); std::memcpy(buf, node->data.data(), size);
buf[size] = '\0'; buf[size] = '\0';
return 0; return 0;
@ -306,7 +306,7 @@ private:
auto node = self->get_node(path, fi); auto node = self->get_node(path, fi);
if (!node) if (!node)
return -ENOENT; return -ENOENT;
fuse_off_t endoff = std::min( fuse_off_t endoff = (std::min)(
off + static_cast<fuse_off_t>(size), static_cast<fuse_off_t>(node->data.size())); off + static_cast<fuse_off_t>(size), static_cast<fuse_off_t>(node->data.size()));
if (off > endoff) if (off > endoff)
return 0; return 0;
@ -335,7 +335,8 @@ private:
static int statfs(const char *path, struct fuse_statvfs *stbuf) static int statfs(const char *path, struct fuse_statvfs *stbuf)
{ {
return -ENOSYS; std::memset(stbuf, 0, sizeof *stbuf);
return 0;
} }
static int flush(const char *path, struct fuse_file_info *fi) static int flush(const char *path, struct fuse_file_info *fi)
@ -450,7 +451,7 @@ private:
filler(buf, ".", &node->stat, 0, FUSE_FILL_DIR_PLUS); filler(buf, ".", &node->stat, 0, FUSE_FILL_DIR_PLUS);
filler(buf, "..", nullptr, 0, FUSE_FILL_DIR_PLUS); filler(buf, "..", nullptr, 0, FUSE_FILL_DIR_PLUS);
for (auto elem : node->childmap) for (auto elem : node->childmap)
if (!filler(buf, elem.first.c_str(), &elem.second->stat, 0, FUSE_FILL_DIR_PLUS)) if (0 != filler(buf, elem.first.c_str(), &elem.second->stat, 0, FUSE_FILL_DIR_PLUS))
break; break;
return 0; return 0;
} }
@ -553,7 +554,7 @@ private:
return -ENOENT; return -ENOENT;
if (!dir && S_IFDIR == (node->stat.st_mode & S_IFMT)) if (!dir && S_IFDIR == (node->stat.st_mode & S_IFMT))
return -EISDIR; return -EISDIR;
if (dir && S_IFDIR == (node->stat.st_mode & S_IFMT)) if (dir && S_IFDIR != (node->stat.st_mode & S_IFMT))
return -ENOTDIR; return -ENOTDIR;
if (0 < node->childmap.size()) if (0 < node->childmap.size())
return -ENOTEMPTY; return -ENOTEMPTY;
@ -570,7 +571,7 @@ private:
return -ENOENT; return -ENOENT;
if (!dir && S_IFDIR == (node->stat.st_mode & S_IFMT)) if (!dir && S_IFDIR == (node->stat.st_mode & S_IFMT))
return -EISDIR; return -EISDIR;
if (dir && S_IFDIR == (node->stat.st_mode & S_IFMT)) if (dir && S_IFDIR != (node->stat.st_mode & S_IFMT))
return -ENOTDIR; return -ENOTDIR;
// A file descriptor is a raw pointer to a shared_ptr. // A file descriptor is a raw pointer to a shared_ptr.
// This has the effect of incrementing the shared_ptr // This has the effect of incrementing the shared_ptr