summaryrefslogtreecommitdiff
path: root/mythfs/service/inodes
diff options
context:
space:
mode:
Diffstat (limited to 'mythfs/service/inodes')
-rw-r--r--mythfs/service/inodes/abstractDynamicDirectory.cpp22
-rw-r--r--mythfs/service/inodes/abstractDynamicDirectory.h18
-rw-r--r--mythfs/service/inodes/allDirectory.cpp20
-rw-r--r--mythfs/service/inodes/allDirectory.h22
-rw-r--r--mythfs/service/inodes/byDateDirectory.h16
-rw-r--r--mythfs/service/inodes/byTitleDirectory.h15
-rw-r--r--mythfs/service/inodes/file.h15
-rw-r--r--mythfs/service/inodes/groupingDirectory.h17
-rw-r--r--mythfs/service/inodes/node.cpp23
-rw-r--r--mythfs/service/inodes/node.h27
-rw-r--r--mythfs/service/inodes/staticDirectory.cpp34
-rw-r--r--mythfs/service/inodes/staticDirectory.h19
-rw-r--r--mythfs/service/inodes/symlink.cpp25
-rw-r--r--mythfs/service/inodes/symlink.h22
14 files changed, 295 insertions, 0 deletions
diff --git a/mythfs/service/inodes/abstractDynamicDirectory.cpp b/mythfs/service/inodes/abstractDynamicDirectory.cpp
new file mode 100644
index 0000000..0a703db
--- /dev/null
+++ b/mythfs/service/inodes/abstractDynamicDirectory.cpp
@@ -0,0 +1,22 @@
+#include "abstractDynamicDirectory.h"
+#include <sys/stat.h>
+#include <exceptions.h>
+
+namespace MythFS {
+ NetFS::Attr
+ AbstractDynamicDirectory::getattr() const
+ {
+ return {
+ 0, 0,
+ S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH | S_IFDIR,
+ 1, "root", "root", 0, 0, 0, 0, 0, 0, 0
+ };
+ }
+
+ Node::PointerType
+ AbstractDynamicDirectory::getChild(const std::string &) const
+ {
+ throw ::NetFS::SystemError(EINVAL);
+ }
+}
+
diff --git a/mythfs/service/inodes/abstractDynamicDirectory.h b/mythfs/service/inodes/abstractDynamicDirectory.h
new file mode 100644
index 0000000..0d62931
--- /dev/null
+++ b/mythfs/service/inodes/abstractDynamicDirectory.h
@@ -0,0 +1,18 @@
+#ifndef MYTHFS_ABSTRACTDYNAMICDIRECTORY_H
+#define MYTHFS_ABSTRACTDYNAMICDIRECTORY_H
+
+#include "node.h"
+
+namespace MythFS {
+ class AbstractDynamicDirectory : public Node {
+ public:
+ NetFS::Attr getattr() const override;
+
+ protected:
+ virtual PointerType getChild(const std::string &) const override = 0;
+ virtual NetFS::NameList getContents() const override = 0;
+ };
+}
+
+#endif
+
diff --git a/mythfs/service/inodes/allDirectory.cpp b/mythfs/service/inodes/allDirectory.cpp
new file mode 100644
index 0000000..d61b8b9
--- /dev/null
+++ b/mythfs/service/inodes/allDirectory.cpp
@@ -0,0 +1,20 @@
+#include "allDirectory.h"
+#include <util.h>
+#include "symlink.h"
+
+namespace MythFS {
+ AllDirectory::AllDirectory(const DBPrx & d) : db(d) { }
+
+ NetFS::NameList
+ AllDirectory::getContents() const
+ {
+ return db->getRecorded() / &Recorded::basename;
+ }
+
+ Node::PointerType
+ AllDirectory::getChild(const std::string & path) const
+ {
+ return new Symlink("/var/store/mythrecordings/" + path);
+ }
+}
+
diff --git a/mythfs/service/inodes/allDirectory.h b/mythfs/service/inodes/allDirectory.h
new file mode 100644
index 0000000..67165ef
--- /dev/null
+++ b/mythfs/service/inodes/allDirectory.h
@@ -0,0 +1,22 @@
+#ifndef MYTHFS_ALLDIRECTORY_H
+#define MYTHFS_ALLDIRECTORY_H
+
+#include "abstractDynamicDirectory.h"
+#include "myth-db.h"
+
+namespace MythFS {
+ class AllDirectory : public AbstractDynamicDirectory {
+ public:
+ AllDirectory(const DBPrx &);
+
+ protected:
+ NetFS::NameList getContents() const override;
+ PointerType getChild(const std::string &) const override;
+
+ private:
+ DBPrx db;
+ };
+}
+
+#endif
+
diff --git a/mythfs/service/inodes/byDateDirectory.h b/mythfs/service/inodes/byDateDirectory.h
new file mode 100644
index 0000000..945a9d0
--- /dev/null
+++ b/mythfs/service/inodes/byDateDirectory.h
@@ -0,0 +1,16 @@
+#ifndef MYTHFS_BYTITLEDIRECTORY_H
+#define MYTHFS_BYTITLEDIRECTORY_H
+
+#include "groupingDirectory.h"
+
+namespace MythFS {
+ class ByDateDirectory : public GroupingDirectory<std::string> {
+
+ protected:
+ virtual std::string attribute(const MythFS::RecordedPtr &) const;
+ };
+}
+
+#endif
+
+
diff --git a/mythfs/service/inodes/byTitleDirectory.h b/mythfs/service/inodes/byTitleDirectory.h
new file mode 100644
index 0000000..e9883d1
--- /dev/null
+++ b/mythfs/service/inodes/byTitleDirectory.h
@@ -0,0 +1,15 @@
+#ifndef MYTHFS_BYTITLEDIRECTORY_H
+#define MYTHFS_BYTITLEDIRECTORY_H
+
+#include "groupingDirectory.h"
+
+namespace MythFS {
+ class ByTitleDirectory : public GroupingDirectory<std::string> {
+
+ protected:
+ virtual std::string attribute(const MythFS::RecordedPtr &) const;
+ };
+}
+
+#endif
+
diff --git a/mythfs/service/inodes/file.h b/mythfs/service/inodes/file.h
new file mode 100644
index 0000000..e71a343
--- /dev/null
+++ b/mythfs/service/inodes/file.h
@@ -0,0 +1,15 @@
+#ifndef MYTHFS_FILE_H
+#define MYTHFS_FILE_H
+
+#include "node.h"
+
+namespace MythFS {
+ class File : public Node {
+ public:
+ NetFS::Attr getattr() const override;
+ PointerType getChild(const std::string &) const override;
+ };
+}
+
+#endif
+
diff --git a/mythfs/service/inodes/groupingDirectory.h b/mythfs/service/inodes/groupingDirectory.h
new file mode 100644
index 0000000..82b3c0c
--- /dev/null
+++ b/mythfs/service/inodes/groupingDirectory.h
@@ -0,0 +1,17 @@
+#ifndef MYTHFS_GROUPINGDIRECTORY_H
+#define MYTHFS_GROUPINGDIRECTORY_H
+
+#include "abstractDynamicDirectory.h"
+
+namespace MythFS {
+ template <typename T>
+ class GroupingDirectory : public AbstractDynamicDirectory {
+ public:
+ protected:
+ virtual T attribute(const MythFS::RecordedPtr &) const = 0;
+ NetFS::NameList getContents() const override;
+ };
+}
+
+#endif
+
diff --git a/mythfs/service/inodes/node.cpp b/mythfs/service/inodes/node.cpp
new file mode 100644
index 0000000..19e4fd3
--- /dev/null
+++ b/mythfs/service/inodes/node.cpp
@@ -0,0 +1,23 @@
+#include "node.h"
+#include <exceptions.h>
+
+namespace MythFS {
+ Node::PointerType
+ Node::getChild(const std::string &) const
+ {
+ throw ::NetFS::SystemError(ENOTDIR);
+ }
+
+ std::string
+ Node::readlink() const
+ {
+ throw ::NetFS::SystemError(EINVAL);
+ }
+
+ NetFS::NameList
+ Node::getContents() const
+ {
+ throw NetFS::SystemError(ENOTDIR);
+ }
+}
+
diff --git a/mythfs/service/inodes/node.h b/mythfs/service/inodes/node.h
new file mode 100644
index 0000000..b88e403
--- /dev/null
+++ b/mythfs/service/inodes/node.h
@@ -0,0 +1,27 @@
+#ifndef MYTHFS_NODE_H
+#define MYTHFS_NODE_H
+
+#include <map>
+#include <string>
+#include <IceUtil/Handle.h>
+#include <Ice/Object.h>
+#include <types.h>
+
+namespace MythFS {
+ class Node;
+
+ typedef std::map<std::string, IceUtil::Handle<Node>> Contents;
+
+ class Node : public virtual Ice::Object {
+ public:
+ typedef IceUtil::Handle<Node> PointerType;
+
+ virtual NetFS::Attr getattr() const = 0;
+ virtual std::string readlink() const;
+ virtual PointerType getChild(const std::string &) const;
+ virtual NetFS::NameList getContents() const;
+ };
+}
+
+#endif
+
diff --git a/mythfs/service/inodes/staticDirectory.cpp b/mythfs/service/inodes/staticDirectory.cpp
new file mode 100644
index 0000000..31cc4fa
--- /dev/null
+++ b/mythfs/service/inodes/staticDirectory.cpp
@@ -0,0 +1,34 @@
+#include "staticDirectory.h"
+#include <sys/stat.h>
+#include <safeMapFind.h>
+#include <exceptions.h>
+#include <util.h>
+
+namespace MythFS {
+ NetFS::Attr
+ StaticDirectory::getattr() const
+ {
+ return {
+ 0, 0,
+ S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH | S_IFDIR,
+ 1, "root", "root", 0, 0, 0, 0, 0, 0, 0};
+ }
+
+ class NoSuchFileOrDirectory : public ::NetFS::SystemError {
+ public:
+ NoSuchFileOrDirectory(const std::string &) : ::NetFS::SystemError(ENOENT) {}
+ };
+
+ Node::PointerType
+ StaticDirectory::getChild(const std::string & path) const
+ {
+ return AdHoc::safeMapLookup<NoSuchFileOrDirectory>(contents, path);
+ }
+
+ NetFS::NameList
+ StaticDirectory::getContents() const
+ {
+ return contents / &Contents::value_type::first;
+ }
+}
+
diff --git a/mythfs/service/inodes/staticDirectory.h b/mythfs/service/inodes/staticDirectory.h
new file mode 100644
index 0000000..0ebb585
--- /dev/null
+++ b/mythfs/service/inodes/staticDirectory.h
@@ -0,0 +1,19 @@
+#ifndef MYTHFS_STATICDIRECTORY_H
+#define MYTHFS_STATICDIRECTORY_H
+
+#include "node.h"
+
+namespace MythFS {
+ class StaticDirectory : public Node {
+ public:
+ NetFS::Attr getattr() const override;
+ PointerType getChild(const std::string &) const override;
+ NetFS::NameList getContents() const override;
+
+ protected:
+ Contents contents;
+ };
+}
+
+#endif
+
diff --git a/mythfs/service/inodes/symlink.cpp b/mythfs/service/inodes/symlink.cpp
new file mode 100644
index 0000000..8dcc0df
--- /dev/null
+++ b/mythfs/service/inodes/symlink.cpp
@@ -0,0 +1,25 @@
+#include "symlink.h"
+#include <sys/stat.h>
+
+namespace MythFS {
+ Symlink::Symlink(const std::string & t) :
+ target(t)
+ {
+
+ }
+
+ NetFS::Attr
+ Symlink::getattr() const
+ {
+ return {
+ 0, 0,
+ S_IRUSR | S_IRGRP | S_IROTH | S_IFLNK,
+ 1,"root","root",0,0,0,0,0,0,0};
+ }
+
+ std::string
+ Symlink::readlink() const
+ {
+ return target;
+ }
+}
diff --git a/mythfs/service/inodes/symlink.h b/mythfs/service/inodes/symlink.h
new file mode 100644
index 0000000..227d2bd
--- /dev/null
+++ b/mythfs/service/inodes/symlink.h
@@ -0,0 +1,22 @@
+#ifndef MYTHFS_SYMLINK_H
+#define MYTHFS_SYMLINK_H
+
+#include <types.h>
+#include "node.h"
+
+namespace MythFS {
+ class Symlink : public Node {
+ public:
+ Symlink(const std::string &);
+
+ NetFS::Attr getattr() const override;
+ std::string readlink() const override;
+
+ private:
+ const std::string target;
+
+ };
+}
+
+#endif
+