Imported Upstream version 1.5.1
This commit is contained in:
31
cpp/include/fuse/cached_directory_entries.h
Normal file
31
cpp/include/fuse/cached_directory_entries.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2011 by Michael Berlin, Zuse Institute Berlin
|
||||
*
|
||||
* Licensed under the BSD License, see LICENSE file for details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CPP_INCLUDE_FUSE_CACHED_DIRECTORY_ENTRIES_H_
|
||||
#define CPP_INCLUDE_FUSE_CACHED_DIRECTORY_ENTRIES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
namespace xtreemfs {
|
||||
|
||||
namespace pbrpc {
|
||||
|
||||
class DirectoryEntries;
|
||||
|
||||
} // namespace pbrpc
|
||||
|
||||
struct CachedDirectoryEntries {
|
||||
uint64_t offset;
|
||||
xtreemfs::pbrpc::DirectoryEntries* dir_entries;
|
||||
boost::mutex mutex;
|
||||
};
|
||||
|
||||
} // namespace xtreemfs
|
||||
|
||||
#endif // CPP_INCLUDE_FUSE_CACHED_DIRECTORY_ENTRIES_H_
|
||||
160
cpp/include/fuse/fuse_adapter.h
Normal file
160
cpp/include/fuse/fuse_adapter.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (c) 2011 by Michael Berlin, Zuse Institute Berlin
|
||||
*
|
||||
* Licensed under the BSD License, see LICENSE file for details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CPP_INCLUDE_FUSE_FUSE_ADAPTER_H_
|
||||
#define CPP_INCLUDE_FUSE_FUSE_ADAPTER_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#define FUSE_USE_VERSION 26
|
||||
#include <fuse.h>
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "libxtreemfs/system_user_mapping_unix.h"
|
||||
#include "xtfsutil/xtfsutil_server.h"
|
||||
#include "xtreemfs/GlobalTypes.pb.h"
|
||||
|
||||
namespace xtreemfs {
|
||||
class Client;
|
||||
class FuseOptions;
|
||||
class UserMapping;
|
||||
class Volume;
|
||||
|
||||
namespace pbrpc {
|
||||
class Stat;
|
||||
class UserCredentials;
|
||||
} // namespace pbrpc
|
||||
|
||||
/** Uses fuse_interrupted() to check if an operation was cancelled by the user
|
||||
* and stops retrying to execute the request then.
|
||||
*
|
||||
* Always returns 0, if called from a non-Fuse thread. */
|
||||
int CheckIfOperationInterrupted();
|
||||
|
||||
class FuseAdapter {
|
||||
public:
|
||||
/** Creates a new instance of FuseAdapter, but does not create any libxtreemfs
|
||||
* Client yet.
|
||||
*
|
||||
* Use Start() to actually create the client and mount the volume given in
|
||||
* options. May modify options.
|
||||
*/
|
||||
explicit FuseAdapter(FuseOptions* options);
|
||||
|
||||
~FuseAdapter();
|
||||
|
||||
/** Create client, open volume and start needed threads.
|
||||
* @return Returns a list of additional "-o<option>" Fuse options which may be
|
||||
* generated after processing the "options" parameter and have to be
|
||||
* considered before starting Fuse.
|
||||
* @remark Ownership of the list elements is transferred to the caller. */
|
||||
void Start(std::list<char*>* required_fuse_options);
|
||||
|
||||
/** Shutdown threads, close Volume and Client and blocks until all threads are
|
||||
* stopped. */
|
||||
void Stop();
|
||||
|
||||
/** After successfully executing fuse_new, tell libxtreemfs to use
|
||||
* fuse_interrupted() if a request was cancelled by the user. */
|
||||
void SetInterruptQueryFunction() const;
|
||||
|
||||
void GenerateUserCredentials(
|
||||
uid_t uid,
|
||||
gid_t gid,
|
||||
pid_t pid,
|
||||
xtreemfs::pbrpc::UserCredentials* user_credentials);
|
||||
|
||||
/** Generate UserCredentials using information from fuse context or the
|
||||
* current process (in that case set fuse_context to NULL). */
|
||||
void GenerateUserCredentials(
|
||||
struct fuse_context* fuse_context,
|
||||
xtreemfs::pbrpc::UserCredentials* user_credentials);
|
||||
|
||||
/** Fill a Fuse stat object with information from an XtreemFS stat. */
|
||||
void ConvertXtreemFSStatToFuse(const xtreemfs::pbrpc::Stat& xtreemfs_stat,
|
||||
struct stat* fuse_stat);
|
||||
|
||||
/** Converts given UNIX file handle flags into XtreemFS symbols. */
|
||||
xtreemfs::pbrpc::SYSTEM_V_FCNTL ConvertFlagsUnixToXtreemFS(int flags);
|
||||
|
||||
/** Converts from XtreemFS error codes to the system ones. */
|
||||
int ConvertXtreemFSErrnoToFuse(xtreemfs::pbrpc::POSIXErrno xtreemfs_errno);
|
||||
|
||||
// Fuse operations as called by placeholder functions in fuse_operations.h. */
|
||||
int statfs(const char *path, struct statvfs *statv);
|
||||
int getattr(const char *path, struct stat *statbuf);
|
||||
int getxattr(const char *path, const char *name, char *value, size_t size);
|
||||
|
||||
/** Creates CachedDirectoryEntries struct and let fi->fh point to it. */
|
||||
int opendir(const char *path, struct fuse_file_info *fi);
|
||||
|
||||
/** Uses the Fuse readdir offset approach to handle readdir requests in chunks
|
||||
* instead of one large request. */
|
||||
int readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset,
|
||||
struct fuse_file_info *fi);
|
||||
|
||||
/** Deletes CachedDirectoryEntries struct which is hold by fi->fh. */
|
||||
int releasedir(const char *path, struct fuse_file_info *fi);
|
||||
|
||||
int utime(const char *path, struct utimbuf *ubuf);
|
||||
int utimens(const char *path, const struct timespec tv[2]);
|
||||
int create(const char *path, mode_t mode, struct fuse_file_info *fi);
|
||||
int mknod(const char *path, mode_t mode, dev_t device);
|
||||
int mkdir(const char *path, mode_t mode);
|
||||
int open(const char *path, struct fuse_file_info *fi);
|
||||
int truncate(const char *path, off_t newsize);
|
||||
int ftruncate(const char *path, off_t offset, struct fuse_file_info *fi);
|
||||
int write(const char *path, const char *buf, size_t size, off_t offset,
|
||||
struct fuse_file_info *fi);
|
||||
int flush(const char *path, struct fuse_file_info *fi);
|
||||
int read(const char *path, char *buf, size_t size, off_t offset,
|
||||
struct fuse_file_info *fi);
|
||||
int access(const char *path, int mask);
|
||||
int unlink(const char *path);
|
||||
int fgetattr(const char *path, struct stat *statbuf,
|
||||
struct fuse_file_info *fi);
|
||||
int release(const char *path, struct fuse_file_info *fi);
|
||||
|
||||
int readlink(const char *path, char *buf, size_t size);
|
||||
int rmdir(const char *path);
|
||||
int symlink(const char *path, const char *link);
|
||||
int rename(const char *path, const char *newpath);
|
||||
int link(const char *path, const char *newpath);
|
||||
int chmod(const char *path, mode_t mode);
|
||||
int chown(const char *path, uid_t uid, gid_t gid);
|
||||
|
||||
int setxattr(const char *path, const char *name, const char *value,
|
||||
size_t size, int flags);
|
||||
int listxattr(const char *path, char *list, size_t size);
|
||||
int removexattr(const char *path, const char *name);
|
||||
|
||||
int lock(const char* path, struct fuse_file_info *fi, int cmd,
|
||||
struct flock* flock);
|
||||
|
||||
private:
|
||||
/** Contains all needed options to mount the requested volume. */
|
||||
FuseOptions* options_;
|
||||
|
||||
/** Translates between local and remote usernames and groups. */
|
||||
SystemUserMappingUnix system_user_mapping_;
|
||||
|
||||
/** Created libxtreemfs Client. */
|
||||
boost::scoped_ptr<Client> client_;
|
||||
|
||||
/** Opened libxtreemfs Volume. */
|
||||
Volume* volume_;
|
||||
|
||||
/** Server for processing commands sent from the xtfsutil tool
|
||||
via xctl files. */
|
||||
XtfsUtilServer xctl_;
|
||||
};
|
||||
|
||||
} // namespace xtreemfs
|
||||
|
||||
#endif // CPP_INCLUDE_FUSE_FUSE_ADAPTER_H_
|
||||
106
cpp/include/fuse/fuse_operations.h
Normal file
106
cpp/include/fuse/fuse_operations.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2011 by Michael Berlin, Zuse Institute Berlin
|
||||
*
|
||||
* Licensed under the BSD License, see LICENSE file for details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CPP_INCLUDE_FUSE_FUSE_OPERATIONS_H_
|
||||
#define CPP_INCLUDE_FUSE_FUSE_OPERATIONS_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define FUSE_USE_VERSION 26
|
||||
#include <fuse.h>
|
||||
|
||||
namespace xtreemfs {
|
||||
class FuseAdapter;
|
||||
}
|
||||
|
||||
/** Contains functions which are passed into fuse_operations struct.
|
||||
* @file
|
||||
*
|
||||
* The functions in this file are merely placeholders which call the actual
|
||||
* functions of the FuseAdapter instance pointed to by fuse_adapter.
|
||||
*/
|
||||
|
||||
/** Points to the FuseAdapter instance created by mount.xtreemfs.cpp. */
|
||||
extern xtreemfs::FuseAdapter* fuse_adapter;
|
||||
|
||||
extern "C" int xtreemfs_fuse_getattr(const char *path, struct stat *statbuf);
|
||||
extern "C" int xtreemfs_fuse_readlink(const char *path, char *link,
|
||||
size_t size);
|
||||
extern "C" int xtreemfs_fuse_mknod(const char *path, mode_t mode, dev_t dev);
|
||||
extern "C" int xtreemfs_fuse_mkdir(const char *path, mode_t mode);
|
||||
extern "C" int xtreemfs_fuse_unlink(const char *path);
|
||||
extern "C" int xtreemfs_fuse_rmdir(const char *path);
|
||||
extern "C" int xtreemfs_fuse_symlink(const char *path, const char *link);
|
||||
extern "C" int xtreemfs_fuse_rename(const char *path, const char *newpath);
|
||||
extern "C" int xtreemfs_fuse_link(const char *path, const char *newpath);
|
||||
extern "C" int xtreemfs_fuse_chmod(const char *path, mode_t mode);
|
||||
extern "C" int xtreemfs_fuse_chown(const char *path, uid_t uid, gid_t gid);
|
||||
extern "C" int xtreemfs_fuse_truncate(const char *path, off_t new_file_size);
|
||||
extern "C" int xtreemfs_fuse_utime(const char *path, struct utimbuf *ubuf);
|
||||
extern "C" int xtreemfs_fuse_lock(const char *, struct fuse_file_info *,
|
||||
int cmd, struct flock *);
|
||||
extern "C" int xtreemfs_fuse_utimens(const char *path,
|
||||
const struct timespec tv[2]);
|
||||
extern "C" int xtreemfs_fuse_open(const char *path, struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_read(const char *path, char *buf, size_t size,
|
||||
off_t offset, struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_write(
|
||||
const char *path,
|
||||
const char *buf,
|
||||
size_t size,
|
||||
off_t offset,
|
||||
struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_statfs(const char *path, struct statvfs *statv);
|
||||
extern "C" int xtreemfs_fuse_flush(const char *path, struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_release(const char *path,
|
||||
struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_fsync(const char *path, int datasync,
|
||||
struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_setxattr(
|
||||
const char *path,
|
||||
const char *name,
|
||||
const char *value,
|
||||
size_t size,
|
||||
int flags
|
||||
#ifdef __APPLE__
|
||||
, uint32_t position
|
||||
#endif
|
||||
);
|
||||
extern "C" int xtreemfs_fuse_getxattr(const char *path, const char *name,
|
||||
char *value, size_t size
|
||||
#ifdef __APPLE__
|
||||
, uint32_t position
|
||||
#endif
|
||||
);
|
||||
extern "C" int xtreemfs_fuse_listxattr(const char *path, char *list,
|
||||
size_t size);
|
||||
extern "C" int xtreemfs_fuse_removexattr(const char *path, const char *name);
|
||||
extern "C" int xtreemfs_fuse_opendir(const char *path,
|
||||
struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_readdir(
|
||||
const char *path,
|
||||
void *buf,
|
||||
fuse_fill_dir_t filler,
|
||||
off_t offset,
|
||||
struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_releasedir(const char *path,
|
||||
struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_fsyncdir(const char *path, int datasync,
|
||||
struct fuse_file_info *fi);
|
||||
extern "C" void *xtreemfs_fuse_init(struct fuse_conn_info *conn);
|
||||
extern "C" void xtreemfs_fuse_destroy(void *userdata);
|
||||
extern "C" int xtreemfs_fuse_access(const char *path, int mask);
|
||||
extern "C" int xtreemfs_fuse_create(const char *path, mode_t mode,
|
||||
struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_ftruncate(const char *path, off_t new_file_size,
|
||||
struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_fgetattr(const char *path, struct stat *statbuf,
|
||||
struct fuse_file_info *fi);
|
||||
extern "C" int xtreemfs_fuse_lock(const char* path, struct fuse_file_info *fi,
|
||||
int cmd, struct flock* flock_);
|
||||
|
||||
#endif // CPP_INCLUDE_FUSE_FUSE_OPERATIONS_H_
|
||||
70
cpp/include/fuse/fuse_options.h
Normal file
70
cpp/include/fuse/fuse_options.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2011 by Michael Berlin, Zuse Institute Berlin
|
||||
*
|
||||
* Licensed under the BSD License, see LICENSE file for details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CPP_INCLUDE_FUSE_FUSE_OPTIONS_H_
|
||||
#define CPP_INCLUDE_FUSE_FUSE_OPTIONS_H_
|
||||
|
||||
#include "libxtreemfs/options.h"
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace xtreemfs {
|
||||
|
||||
class FuseOptions : public Options {
|
||||
public:
|
||||
/** Sets the default values. */
|
||||
FuseOptions();
|
||||
|
||||
/** Set options parsed from command line which must contain at least the URL
|
||||
* to a XtreemFS volume and a mount point.
|
||||
*
|
||||
* Calls Options::ParseCommandLine() to parse general options.
|
||||
*
|
||||
* @throws InvalidCommandLineParametersException
|
||||
* @throws InvalidURLException */
|
||||
void ParseCommandLine(int argc, char** argv);
|
||||
|
||||
/** Shows only the minimal help text describing the usage of mount.xtreemfs.*/
|
||||
std::string ShowCommandLineUsage();
|
||||
|
||||
/** Outputs usage of the command line parameters. */
|
||||
virtual std::string ShowCommandLineHelp();
|
||||
|
||||
// Fuse options.
|
||||
/** Execute extended attributes operations? */
|
||||
bool enable_xattrs;
|
||||
/** If -o default_permissions is passed to Fuse, there are no extra permission
|
||||
* checks needed. */
|
||||
bool use_fuse_permission_checks;
|
||||
/** If requested by the user, do not pass -o default_permissions to Fuse. */
|
||||
bool fuse_permission_checks_explicitly_disabled;
|
||||
/** Run the adapter program in foreground or send it to background? */
|
||||
bool foreground;
|
||||
/** Fuse options specified by -o. */
|
||||
std::vector<std::string> fuse_options;
|
||||
#ifdef __APPLE__
|
||||
/** Assumed (or if specified the set) timeout of a blocked operation after
|
||||
* which MacFuse will on a) Tiger show a dialog if the user will still wait
|
||||
* for the operation or b) >=Leopard just kill our Fuse implementation and
|
||||
* call fuse_destroy.
|
||||
*/
|
||||
int daemon_timeout;
|
||||
#endif // __APPLE__
|
||||
|
||||
private:
|
||||
/** Contains all available Fuse options and its descriptions. */
|
||||
boost::program_options::options_description fuse_descriptions_;
|
||||
|
||||
/** Brief help text if there are no command line arguments. */
|
||||
std::string helptext_usage_;
|
||||
};
|
||||
|
||||
} // namespace xtreemfs
|
||||
|
||||
#endif // CPP_INCLUDE_FUSE_FUSE_OPTIONS_H_
|
||||
Reference in New Issue
Block a user