diff options
author | randomdan <randomdan@localhost> | 2014-03-20 21:07:25 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2014-03-20 21:07:25 +0000 |
commit | 5780e0d6b8fb5c4269d224b865365a1c59afd38b (patch) | |
tree | 2fdef12c4a975d2b412b78d75654db6fab471379 /netfs/ice | |
parent | Fix slice scanner and split .ice files back into logical blocks (diff) | |
download | netfs-5780e0d6b8fb5c4269d224b865365a1c59afd38b.tar.bz2 netfs-5780e0d6b8fb5c4269d224b865365a1c59afd38b.tar.xz netfs-5780e0d6b8fb5c4269d224b865365a1c59afd38b.zip |
Modularized interfaces for netfs
Diffstat (limited to 'netfs/ice')
-rw-r--r-- | netfs/ice/Jamfile.jam | 16 | ||||
-rw-r--r-- | netfs/ice/directory.ice | 17 | ||||
-rw-r--r-- | netfs/ice/exceptions.ice | 18 | ||||
-rw-r--r-- | netfs/ice/file.ice | 22 | ||||
-rw-r--r-- | netfs/ice/service.ice | 16 | ||||
-rw-r--r-- | netfs/ice/typeConvert.cpp | 70 | ||||
-rw-r--r-- | netfs/ice/typeConvert.h | 29 | ||||
-rw-r--r-- | netfs/ice/types.ice | 46 | ||||
-rw-r--r-- | netfs/ice/volume.ice | 42 |
9 files changed, 276 insertions, 0 deletions
diff --git a/netfs/ice/Jamfile.jam b/netfs/ice/Jamfile.jam new file mode 100644 index 0000000..a227478 --- /dev/null +++ b/netfs/ice/Jamfile.jam @@ -0,0 +1,16 @@ +lib Ice ; +lib IceUtil ; +lib pthread ; + +lib netfsComms : + [ glob *.cpp *.ice ] : + <library>Ice + <library>IceUtil + <library>pthread + : : + <include>. + <library>Ice + <library>IceUtil + <library>pthread + ; + diff --git a/netfs/ice/directory.ice b/netfs/ice/directory.ice new file mode 100644 index 0000000..7468503 --- /dev/null +++ b/netfs/ice/directory.ice @@ -0,0 +1,17 @@ +#ifndef _DIRECTORY +#define _DIRECTORY + +#include "exceptions.ice" +#include "types.ice" + +module NetFS { + interface Directory { + void close() throws AuthError, SystemError; + + idempotent NameList readdir() throws AuthError, SystemError; + }; + +}; + +#endif + diff --git a/netfs/ice/exceptions.ice b/netfs/ice/exceptions.ice new file mode 100644 index 0000000..9d5b970 --- /dev/null +++ b/netfs/ice/exceptions.ice @@ -0,0 +1,18 @@ +#ifndef _EXCEPTIONS +#define _EXCEPTIONS + +module NetFS { + // Exceptions + exception SystemError { + int syserrno; + }; + + exception AuthError { + }; + + exception ConfigError { + }; +}; + +#endif + diff --git a/netfs/ice/file.ice b/netfs/ice/file.ice new file mode 100644 index 0000000..bbfb2d5 --- /dev/null +++ b/netfs/ice/file.ice @@ -0,0 +1,22 @@ +#ifndef _FILES +#define _FILES + +#include "exceptions.ice" +#include "types.ice" + +module NetFS { + interface ReadOnlyFile { + void close() throws AuthError, SystemError; + + idempotent Attr fgetattr(ReqEnv env) throws AuthError, SystemError; + idempotent Buffer read(long offset, long size) throws AuthError, SystemError; + }; + + interface File extends ReadOnlyFile { + idempotent void ftruncate(ReqEnv env, long size) throws AuthError, SystemError; + idempotent void write(long offset, long size, Buffer data) throws AuthError, SystemError; + }; +}; + +#endif + diff --git a/netfs/ice/service.ice b/netfs/ice/service.ice new file mode 100644 index 0000000..d691ae2 --- /dev/null +++ b/netfs/ice/service.ice @@ -0,0 +1,16 @@ +#ifndef _SERVICE +#define _SERVICE + +#include "exceptions.ice" +#include "types.ice" +#include "volume.ice" + +module NetFS { + interface Service { + // NameList volumes() throws ConfigError; + Volume * connect(string volume, string auth) throws AuthError, ConfigError; + }; +}; + +#endif + diff --git a/netfs/ice/typeConvert.cpp b/netfs/ice/typeConvert.cpp new file mode 100644 index 0000000..538b894 --- /dev/null +++ b/netfs/ice/typeConvert.cpp @@ -0,0 +1,70 @@ +#include "typeConvert.h" + +void +operator<<(struct stat & s, const AttrSource & a) +{ + s.st_dev = a.attr.dev; + s.st_ino = a.attr.inode; + s.st_mode = a.attr.mode; + s.st_nlink = a.attr.links; + s.st_uid = a.user(a.attr.uid); + s.st_gid = a.group(a.attr.gid); + s.st_rdev = a.attr.rdev; + s.st_size = a.attr.size; + s.st_blksize = a.attr.blockSize; + s.st_blocks = a.attr.blocks; + s.st_atime = a.attr.atime; + s.st_mtime = a.attr.mtime; + s.st_ctime = a.attr.ctime; +} + +void +operator<<(struct statvfs & vfs, const NetFS::VFS & v) +{ + vfs.f_bsize = v.blockSize; + vfs.f_frsize = v.fragmentSize; + vfs.f_blocks = v.blocks; + vfs.f_bfree = v.freeBlocks; + vfs.f_bavail = v.availBlocks; + vfs.f_files = v.files; + vfs.f_ffree = v.freeFiles; + vfs.f_favail = v.availFiles; + vfs.f_fsid = v.FSID; + vfs.f_flag = v.flags; + vfs.f_namemax = v.maxNameLen; +} + +void +operator<<(NetFS::Attr & a, const struct StatSource & s) +{ + a.dev = s.stat.st_dev; + a.inode = s.stat.st_ino; + a.mode = s.stat.st_mode; + a.links = s.stat.st_nlink; + a.uid = s.user(s.stat.st_uid); + a.gid = s.group(s.stat.st_gid); + a.rdev = s.stat.st_rdev; + a.size = s.stat.st_size; + a.blockSize = s.stat.st_blksize; + a.blocks = s.stat.st_blocks; + a.atime = s.stat.st_atime; + a.mtime = s.stat.st_mtime; + a.ctime = s.stat.st_ctime; +} + +void +operator<<(NetFS::VFS & t, const struct statvfs & s) +{ + t.blockSize = s.f_bsize; + t.fragmentSize = s.f_frsize; + t.blocks = s.f_blocks; + t.freeBlocks = s.f_bfree; + t.availBlocks = s.f_bavail; + t.files = s.f_files; + t.freeFiles = s.f_ffree; + t.availFiles = s.f_favail; + t.FSID = s.f_fsid; + t.flags = s.f_flag; + t.maxNameLen = s.f_namemax; +} + diff --git a/netfs/ice/typeConvert.h b/netfs/ice/typeConvert.h new file mode 100644 index 0000000..dd56a3f --- /dev/null +++ b/netfs/ice/typeConvert.h @@ -0,0 +1,29 @@ +#include <types.h> +#include <sys/stat.h> +#include <sys/statvfs.h> +#include <boost/function.hpp> + +typedef boost::function<uid_t(const std::string &)> UserIdLookup; +typedef boost::function<gid_t(const std::string &)> GroupIdLookup; + +typedef boost::function<std::string(uid_t)> UserNameLookup; +typedef boost::function<std::string(gid_t)> GroupNameLookup; + +struct AttrSource { + const NetFS::Attr & attr; + const UserIdLookup & user; + const GroupIdLookup & group; +}; + +struct StatSource { + const struct stat & stat; + const UserNameLookup & user; + const GroupNameLookup & group; +}; + +void operator<<(struct stat &, const AttrSource &); +void operator<<(struct statvfs &, const NetFS::VFS &); + +void operator<<(NetFS::Attr &, const struct StatSource &); +void operator<<(NetFS::VFS &, const struct statvfs &); + diff --git a/netfs/ice/types.ice b/netfs/ice/types.ice new file mode 100644 index 0000000..74f48ce --- /dev/null +++ b/netfs/ice/types.ice @@ -0,0 +1,46 @@ +#ifndef _TYPES +#define _TYPES + +module NetFS { + struct VFS { + long blockSize; + long fragmentSize; + long blocks; + long freeBlocks; + long availBlocks; + long files; + long freeFiles; + long availFiles; + long FSID; + long flags; + long maxNameLen; + }; + + struct Attr { + int dev; + long inode; + int mode; + int links; + string uid; + string gid; + int rdev; + long size; + long blockSize; + long blocks; + long atime; + long mtime; + long ctime; + }; + + struct ReqEnv { + string user; + string grp; + }; + + sequence<byte> Buffer; + + sequence<string> NameList; +}; + +#endif + diff --git a/netfs/ice/volume.ice b/netfs/ice/volume.ice new file mode 100644 index 0000000..7b0e3e0 --- /dev/null +++ b/netfs/ice/volume.ice @@ -0,0 +1,42 @@ +#ifndef _VOLUME +#define _VOLUME + +#include "exceptions.ice" +#include "types.ice" +#include "file.ice" +#include "directory.ice" + +module NetFS { + interface ReadOnlyVolume { + void disconnect() throws AuthError; + + ReadOnlyFile * openReadOnly(ReqEnv env, string path, int flags) throws AuthError, SystemError; + Directory * opendir(ReqEnv env, string path) throws AuthError, SystemError; + + idempotent VFS statfs(ReqEnv env, string path) throws AuthError, SystemError; + idempotent int access(ReqEnv env, string path, int mode) throws AuthError, SystemError; + idempotent Attr getattr(ReqEnv env, string path) throws AuthError, SystemError; + idempotent string readlink(ReqEnv env, string path) throws AuthError, SystemError; + }; + + interface Volume extends ReadOnlyVolume { + File * open(ReqEnv env, string path, int flags) throws AuthError, SystemError; + File * create(ReqEnv env, string path, int flags, int mode) throws AuthError, SystemError; + + idempotent void truncate(ReqEnv env, string path, long size) throws AuthError, SystemError; + void unlink(ReqEnv env, string path) throws AuthError, SystemError; + + void mkdir(ReqEnv env, string path, int mode) throws AuthError, SystemError; + void rmdir(ReqEnv env, string path) throws AuthError, SystemError; + + void symlink(ReqEnv env, string path1, string path2) throws AuthError, SystemError; + void link(ReqEnv env, string path1, string path2) throws AuthError, SystemError; + void rename(ReqEnv env, string from, string to) throws AuthError, SystemError; + idempotent void chmod(ReqEnv env, string path, int mode) throws AuthError, SystemError; + idempotent void chown(ReqEnv env, string path, int uid, int gid) throws AuthError, SystemError; + idempotent void utimens(ReqEnv env, string path, long atime, long atimens, long mtime, long mtimens) throws AuthError, SystemError; + }; +}; + +#endif + |