2010-11-13 23:59:23 +00:00
|
|
|
#ifndef S3FS_S3_H_
|
|
|
|
#define S3FS_S3_H_
|
|
|
|
|
|
|
|
#define FUSE_USE_VERSION 26
|
|
|
|
|
2011-02-17 17:31:43 +00:00
|
|
|
#define MULTIPART_SIZE 10485760 // 10MB
|
|
|
|
|
2010-11-13 23:59:23 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2011-02-15 23:32:27 +00:00
|
|
|
#include <vector>
|
2010-11-13 23:59:23 +00:00
|
|
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <fuse.h>
|
|
|
|
#include <openssl/bio.h>
|
|
|
|
#include <openssl/buffer.h>
|
|
|
|
#include <openssl/evp.h>
|
|
|
|
#include <openssl/hmac.h>
|
|
|
|
#include <openssl/md5.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
2010-12-19 22:27:56 +00:00
|
|
|
#define YIKES(result) if (true) { \
|
2010-11-13 23:59:23 +00:00
|
|
|
syslog(LOG_ERR, "%d###result=%d", __LINE__, result); \
|
|
|
|
return result; \
|
|
|
|
}
|
|
|
|
|
2011-03-01 19:35:55 +00:00
|
|
|
long connect_timeout = 10;
|
|
|
|
time_t readwrite_timeout = 30;
|
2010-11-13 23:59:23 +00:00
|
|
|
|
2011-03-01 19:35:55 +00:00
|
|
|
int retries = 2;
|
2010-11-13 23:59:23 +00:00
|
|
|
|
2011-06-26 00:37:52 +00:00
|
|
|
bool debug = 0;
|
|
|
|
bool foreground = 0;
|
2011-06-27 02:21:38 +00:00
|
|
|
bool nomultipart = false;
|
2011-06-26 00:37:52 +00:00
|
|
|
bool service_validated = false;
|
|
|
|
static std::string host = "http://s3.amazonaws.com";
|
|
|
|
static std::string service_path = "/";
|
|
|
|
std::string bucket = "";
|
|
|
|
std::string mount_prefix = "";
|
2011-02-25 17:35:12 +00:00
|
|
|
static std::string mountpoint;
|
2011-03-01 19:35:55 +00:00
|
|
|
std::string program_name;
|
2011-02-25 17:35:12 +00:00
|
|
|
static std::string AWSAccessKeyId;
|
|
|
|
static std::string AWSSecretAccessKey;
|
2010-11-13 23:59:23 +00:00
|
|
|
static mode_t root_mode = 0;
|
2011-02-25 17:35:12 +00:00
|
|
|
static std::string passwd_file = "";
|
2010-12-30 03:13:21 +00:00
|
|
|
static bool utility_mode = 0;
|
2011-02-25 17:35:12 +00:00
|
|
|
unsigned long max_stat_cache_size = 10000;
|
2010-11-13 23:59:23 +00:00
|
|
|
|
|
|
|
// if .size()==0 then local file cache is disabled
|
2011-02-25 17:35:12 +00:00
|
|
|
static std::string use_cache;
|
|
|
|
static std::string use_rrs;
|
2011-03-01 19:35:55 +00:00
|
|
|
std::string ssl_verify_hostname = "1";
|
2011-02-25 17:35:12 +00:00
|
|
|
static std::string public_bucket;
|
|
|
|
|
|
|
|
extern pthread_mutex_t stat_cache_lock;
|
2011-03-01 19:35:55 +00:00
|
|
|
extern pthread_mutex_t curl_handles_lock;
|
|
|
|
extern std::string curl_ca_bundle;
|
2010-11-13 23:59:23 +00:00
|
|
|
|
|
|
|
// TODO(apetresc): make this an enum
|
|
|
|
// private, public-read, public-read-write, authenticated-read
|
2011-02-25 17:35:12 +00:00
|
|
|
static std::string default_acl("private");
|
2010-11-13 23:59:23 +00:00
|
|
|
|
2011-02-17 17:31:43 +00:00
|
|
|
struct file_part {
|
|
|
|
char path[17];
|
2011-02-25 17:35:12 +00:00
|
|
|
std::string etag;
|
2011-02-17 17:31:43 +00:00
|
|
|
bool uploaded;
|
|
|
|
|
|
|
|
file_part() : uploaded(false) {}
|
|
|
|
};
|
|
|
|
|
2010-11-13 23:59:23 +00:00
|
|
|
static const char hexAlphabet[] = "0123456789ABCDEF";
|
|
|
|
|
|
|
|
// http headers
|
2011-02-25 17:35:12 +00:00
|
|
|
typedef std::map<std::string, std::string> headers_t;
|
2010-11-13 23:59:23 +00:00
|
|
|
|
|
|
|
static const EVP_MD* evp_md = EVP_sha1();
|
|
|
|
|
|
|
|
// fd -> flags
|
2011-02-25 17:35:12 +00:00
|
|
|
typedef std::map<int, int> s3fs_descriptors_t;
|
2010-11-13 23:59:23 +00:00
|
|
|
static s3fs_descriptors_t s3fs_descriptors;
|
|
|
|
static pthread_mutex_t s3fs_descriptors_lock;
|
|
|
|
|
|
|
|
static pthread_mutex_t *mutex_buf = NULL;
|
|
|
|
|
|
|
|
static struct fuse_operations s3fs_oper;
|
|
|
|
|
2011-02-25 17:35:12 +00:00
|
|
|
std::string lookupMimeType(std::string);
|
|
|
|
std::string initiate_multipart_upload(const char *path, off_t size, headers_t meta);
|
|
|
|
std::string upload_part(const char *path, const char *source, int part_number, std::string upload_id);
|
|
|
|
static int complete_multipart_upload(const char *path, std::string upload_id, std::vector <file_part> parts);
|
|
|
|
std::string md5sum(int fd);
|
2011-06-26 00:37:52 +00:00
|
|
|
char *get_realpath(const char *path);
|
2011-02-08 18:23:38 +00:00
|
|
|
|
2010-11-13 23:59:23 +00:00
|
|
|
static int s3fs_getattr(const char *path, struct stat *stbuf);
|
|
|
|
static int s3fs_readlink(const char *path, char *buf, size_t size);
|
|
|
|
static int s3fs_mknod(const char* path, mode_t mode, dev_t rdev);
|
|
|
|
static int s3fs_mkdir(const char *path, mode_t mode);
|
|
|
|
static int s3fs_unlink(const char *path);
|
|
|
|
static int s3fs_rmdir(const char *path);
|
|
|
|
static int s3fs_symlink(const char *from, const char *to);
|
|
|
|
static int s3fs_rename(const char *from, const char *to);
|
|
|
|
static int s3fs_link(const char *from, const char *to);
|
|
|
|
static int s3fs_chmod(const char *path, mode_t mode);
|
|
|
|
static int s3fs_chown(const char *path, uid_t uid, gid_t gid);
|
|
|
|
static int s3fs_truncate(const char *path, off_t size);
|
|
|
|
static int s3fs_open(const char *path, struct fuse_file_info *fi);
|
|
|
|
static int s3fs_read(
|
|
|
|
const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi);
|
|
|
|
static int s3fs_write(
|
|
|
|
const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi);
|
|
|
|
static int s3fs_statfs(const char *path, struct statvfs *stbuf);
|
|
|
|
static int s3fs_flush(const char *path, struct fuse_file_info *fi);
|
|
|
|
static int s3fs_release(const char *path, struct fuse_file_info *fi);
|
|
|
|
static int s3fs_readdir(
|
|
|
|
const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi);
|
|
|
|
static int s3fs_access(const char *path, int mask);
|
|
|
|
static int s3fs_utimens(const char *path, const struct timespec ts[2]);
|
2011-06-26 00:37:52 +00:00
|
|
|
static int remote_mountpath_exists(const char *path);
|
2010-11-13 23:59:23 +00:00
|
|
|
static void* s3fs_init(struct fuse_conn_info *conn);
|
|
|
|
static void s3fs_destroy(void*);
|
|
|
|
|
|
|
|
#endif // S3FS_S3_H_
|