mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
tst: memfs-fuse3: testing
This commit is contained in:
parent
d3d75bf977
commit
ce20747534
@ -22,6 +22,13 @@
|
||||
#ifndef 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)
|
||||
|
||||
#define fuse_uid_t uid_t
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <fuse3/fuse.h>
|
||||
#include <fuse.h>
|
||||
#include "compat.h"
|
||||
|
||||
class memfs
|
||||
@ -153,7 +153,7 @@ private:
|
||||
return -ENOENT;
|
||||
if (S_IFLNK != (node->stat.st_mode & S_IFMT))
|
||||
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);
|
||||
buf[size] = '\0';
|
||||
return 0;
|
||||
@ -306,7 +306,7 @@ private:
|
||||
auto node = self->get_node(path, fi);
|
||||
if (!node)
|
||||
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()));
|
||||
if (off > endoff)
|
||||
return 0;
|
||||
@ -335,7 +335,8 @@ private:
|
||||
|
||||
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)
|
||||
@ -450,7 +451,7 @@ private:
|
||||
filler(buf, ".", &node->stat, 0, FUSE_FILL_DIR_PLUS);
|
||||
filler(buf, "..", nullptr, 0, FUSE_FILL_DIR_PLUS);
|
||||
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;
|
||||
return 0;
|
||||
}
|
||||
@ -553,7 +554,7 @@ private:
|
||||
return -ENOENT;
|
||||
if (!dir && S_IFDIR == (node->stat.st_mode & S_IFMT))
|
||||
return -EISDIR;
|
||||
if (dir && S_IFDIR == (node->stat.st_mode & S_IFMT))
|
||||
if (dir && S_IFDIR != (node->stat.st_mode & S_IFMT))
|
||||
return -ENOTDIR;
|
||||
if (0 < node->childmap.size())
|
||||
return -ENOTEMPTY;
|
||||
@ -570,7 +571,7 @@ private:
|
||||
return -ENOENT;
|
||||
if (!dir && S_IFDIR == (node->stat.st_mode & S_IFMT))
|
||||
return -EISDIR;
|
||||
if (dir && S_IFDIR == (node->stat.st_mode & S_IFMT))
|
||||
if (dir && S_IFDIR != (node->stat.st_mode & S_IFMT))
|
||||
return -ENOTDIR;
|
||||
// A file descriptor is a raw pointer to a shared_ptr.
|
||||
// This has the effect of incrementing the shared_ptr
|
||||
|
Loading…
x
Reference in New Issue
Block a user