summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2020-09-20 16:10:50 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2020-09-20 16:10:50 +0100
commita615da850d89ecd785a6a43e07527932637f8a2f (patch)
treea9778d2967510aa22f89e69bb849f90617de492b
parentAdd the MaskUnknown mapper (diff)
downloadnetfs-a615da850d89ecd785a6a43e07527932637f8a2f.tar.bz2
netfs-a615da850d89ecd785a6a43e07527932637f8a2f.tar.xz
netfs-a615da850d89ecd785a6a43e07527932637f8a2f.zip
Common base for mappers
-rw-r--r--netfs/fuse/fuseMappersImpl.cpp23
-rw-r--r--netfs/fuse/fuseMappersImpl.h21
-rw-r--r--netfs/lib/baseMapper.cpp13
-rw-r--r--netfs/lib/baseMapper.h23
-rw-r--r--netfs/lib/defaultMapper.cpp13
-rw-r--r--netfs/lib/defaultMapper.h11
6 files changed, 44 insertions, 60 deletions
diff --git a/netfs/fuse/fuseMappersImpl.cpp b/netfs/fuse/fuseMappersImpl.cpp
index 4aa2789..5bde752 100644
--- a/netfs/fuse/fuseMappersImpl.cpp
+++ b/netfs/fuse/fuseMappersImpl.cpp
@@ -5,18 +5,6 @@ namespace NetFS::Client {
constexpr int MASK_EVERYTHING = ~0;
static_assert(MASK_EVERYTHING == static_cast<int>(0xFFFFFFFF));
- HideUnknownMapperImpl::HideUnknownMapperImpl() : HideUnknownMapperImpl(std::make_shared<UserEntCache>()) { }
-
- HideUnknownMapperImpl::HideUnknownMapperImpl(EntryResolverPtr<User> u) :
- HideUnknownMapperImpl(std::move(u), std::make_shared<GroupEntCache>(u))
- {
- }
-
- HideUnknownMapperImpl::HideUnknownMapperImpl(EntryResolverPtr<User> u, EntryResolverPtr<Group> g) :
- users(std::move(u)), groups(std::move(g))
- {
- }
-
Mapping::FileSystem
HideUnknownMapperImpl::mapTransport(const std::string & un, const std::string & gn)
{
@@ -38,17 +26,6 @@ namespace NetFS::Client {
}
return {u->name, g->name, 0};
}
- MaskUnknownMapperImpl::MaskUnknownMapperImpl() : MaskUnknownMapperImpl(std::make_shared<UserEntCache>()) { }
-
- MaskUnknownMapperImpl::MaskUnknownMapperImpl(EntryResolverPtr<User> u) :
- MaskUnknownMapperImpl(std::move(u), std::make_shared<GroupEntCache>(u))
- {
- }
-
- MaskUnknownMapperImpl::MaskUnknownMapperImpl(EntryResolverPtr<User> u, EntryResolverPtr<Group> g) :
- users(std::move(u)), groups(std::move(g))
- {
- }
Mapping::FileSystem
MaskUnknownMapperImpl::mapTransport(const std::string & un, const std::string & gn)
diff --git a/netfs/fuse/fuseMappersImpl.h b/netfs/fuse/fuseMappersImpl.h
index 41d78b8..2bcf579 100644
--- a/netfs/fuse/fuseMappersImpl.h
+++ b/netfs/fuse/fuseMappersImpl.h
@@ -1,6 +1,7 @@
#ifndef NETFS_MAPPING_CLIENTIMPL_H
#define NETFS_MAPPING_CLIENTIMPL_H
+#include "baseMapper.h"
#include "entries.h"
#include "entryResolver.h"
#include <fuseMappers.h>
@@ -8,32 +9,20 @@
namespace NetFS {
namespace Client {
- class DLL_PUBLIC HideUnknownMapperImpl : public HideUnknownMapper {
+ class DLL_PUBLIC HideUnknownMapperImpl : public HideUnknownMapper, Mapping::BaseMapper {
public:
- HideUnknownMapperImpl();
- HideUnknownMapperImpl(EntryResolverPtr<User> u);
- HideUnknownMapperImpl(EntryResolverPtr<User> u, EntryResolverPtr<Group> g);
+ using BaseMapper::BaseMapper;
Mapping::Transport mapFileSystem(int uid, int gid) override;
Mapping::FileSystem mapTransport(const std::string & un, const std::string & gn) override;
-
- protected:
- EntryResolverPtr<User> users;
- EntryResolverPtr<Group> groups;
};
- class DLL_PUBLIC MaskUnknownMapperImpl : public MaskUnknownMapper {
+ class DLL_PUBLIC MaskUnknownMapperImpl : public MaskUnknownMapper, Mapping::BaseMapper {
public:
- MaskUnknownMapperImpl();
- MaskUnknownMapperImpl(EntryResolverPtr<User> u);
- MaskUnknownMapperImpl(EntryResolverPtr<User> u, EntryResolverPtr<Group> g);
+ using BaseMapper::BaseMapper;
Mapping::Transport mapFileSystem(int uid, int gid) override;
Mapping::FileSystem mapTransport(const std::string & un, const std::string & gn) override;
-
- protected:
- EntryResolverPtr<User> users;
- EntryResolverPtr<Group> groups;
};
}
}
diff --git a/netfs/lib/baseMapper.cpp b/netfs/lib/baseMapper.cpp
new file mode 100644
index 0000000..c3518e4
--- /dev/null
+++ b/netfs/lib/baseMapper.cpp
@@ -0,0 +1,13 @@
+#include "baseMapper.h"
+#include "entCache.h"
+
+namespace NetFS::Mapping {
+ BaseMapper::BaseMapper() : BaseMapper(std::make_shared<UserEntCache>()) { }
+
+ BaseMapper::BaseMapper(EntryResolverPtr<User> u) : BaseMapper(std::move(u), std::make_shared<GroupEntCache>(u)) { }
+
+ BaseMapper::BaseMapper(EntryResolverPtr<User> u, EntryResolverPtr<Group> g) :
+ users(std::move(u)), groups(std::move(g))
+ {
+ }
+}
diff --git a/netfs/lib/baseMapper.h b/netfs/lib/baseMapper.h
new file mode 100644
index 0000000..c3bd46e
--- /dev/null
+++ b/netfs/lib/baseMapper.h
@@ -0,0 +1,23 @@
+#ifndef NETFS_MAPPING_BASEIMPL_H
+#define NETFS_MAPPING_BASEIMPL_H
+
+#include "entries.h"
+#include "entryResolver.h"
+#include <mapper.h>
+
+namespace NetFS {
+ namespace Mapping {
+ class BaseMapper {
+ public:
+ BaseMapper();
+ BaseMapper(EntryResolverPtr<User> users);
+ BaseMapper(EntryResolverPtr<User> users, EntryResolverPtr<Group> groups);
+
+ protected:
+ EntryResolverPtr<User> users;
+ EntryResolverPtr<Group> groups;
+ };
+ }
+}
+
+#endif
diff --git a/netfs/lib/defaultMapper.cpp b/netfs/lib/defaultMapper.cpp
index d20f7ba..c57f340 100644
--- a/netfs/lib/defaultMapper.cpp
+++ b/netfs/lib/defaultMapper.cpp
@@ -1,20 +1,7 @@
#include "defaultMapper.h"
-#include "entCache.h"
#include <exceptions.h>
namespace NetFS::Mapping {
- DefaultMapper::DefaultMapper() : DefaultMapper(std::make_shared<UserEntCache>()) { }
-
- DefaultMapper::DefaultMapper(EntryResolverPtr<User> u) :
- DefaultMapper(std::move(u), std::make_shared<GroupEntCache>(u))
- {
- }
-
- DefaultMapper::DefaultMapper(EntryResolverPtr<User> u, EntryResolverPtr<Group> g) :
- users(std::move(u)), groups(std::move(g))
- {
- }
-
FileSystem
DefaultMapper::mapTransport(const std::string & un, const std::string & gn)
{
diff --git a/netfs/lib/defaultMapper.h b/netfs/lib/defaultMapper.h
index 5a5c335..9f063a8 100644
--- a/netfs/lib/defaultMapper.h
+++ b/netfs/lib/defaultMapper.h
@@ -1,24 +1,19 @@
#ifndef NETFS_MAPPING_DEFAULTIMPL_H
#define NETFS_MAPPING_DEFAULTIMPL_H
+#include "baseMapper.h"
#include "entries.h"
#include "entryResolver.h"
#include <mapper.h>
namespace NetFS {
namespace Mapping {
- class DefaultMapper : public Mapper {
+ class DefaultMapper : public Mapper, BaseMapper {
public:
- DefaultMapper();
- DefaultMapper(EntryResolverPtr<User> users);
- DefaultMapper(EntryResolverPtr<User> users, EntryResolverPtr<Group> groups);
+ using BaseMapper::BaseMapper;
Transport mapFileSystem(int uid, int gid) override;
FileSystem mapTransport(const std::string & un, const std::string & gn) override;
-
- protected:
- EntryResolverPtr<User> users;
- EntryResolverPtr<Group> groups;
};
}
}