mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-01-03 13:07:24 +00:00
Support Google Cloud Storage headers
This allows s3fs to interpret objects created by gsutil.
This commit is contained in:
parent
6e134a23f9
commit
8945e98d8b
@ -797,13 +797,10 @@ time_t get_mtime(const char *str)
|
|||||||
return static_cast<time_t>(s3fs_strtoofft(strmtime.c_str()));
|
return static_cast<time_t>(s3fs_strtoofft(strmtime.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
static time_t get_time(headers_t& meta, bool overcheck, const char *header)
|
static time_t get_time(headers_t& meta, const char *header)
|
||||||
{
|
{
|
||||||
headers_t::const_iterator iter;
|
headers_t::const_iterator iter;
|
||||||
if(meta.end() == (iter = meta.find(header))){
|
if(meta.end() == (iter = meta.find(header))){
|
||||||
if(overcheck){
|
|
||||||
return get_lastmodified(meta);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return get_mtime((*iter).second.c_str());
|
return get_mtime((*iter).second.c_str());
|
||||||
@ -811,12 +808,30 @@ static time_t get_time(headers_t& meta, bool overcheck, const char *header)
|
|||||||
|
|
||||||
time_t get_mtime(headers_t& meta, bool overcheck)
|
time_t get_mtime(headers_t& meta, bool overcheck)
|
||||||
{
|
{
|
||||||
return get_time(meta, overcheck, "x-amz-meta-mtime");
|
time_t t = get_time(meta, "x-amz-meta-mtime");
|
||||||
|
if(t != 0){
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
t = get_time(meta, "x-amz-meta-goog-reserved-file-mtime");
|
||||||
|
if(t != 0){
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
if(overcheck){
|
||||||
|
return get_lastmodified(meta);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t get_ctime(headers_t& meta, bool overcheck)
|
time_t get_ctime(headers_t& meta, bool overcheck)
|
||||||
{
|
{
|
||||||
return get_time(meta, overcheck, "x-amz-meta-ctime");
|
time_t t = get_time(meta, "x-amz-meta-ctime");
|
||||||
|
if(t != 0){
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
if(overcheck){
|
||||||
|
return get_lastmodified(meta);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t get_size(const char *s)
|
off_t get_size(const char *s)
|
||||||
@ -833,9 +848,9 @@ off_t get_size(headers_t& meta)
|
|||||||
return get_size((*iter).second.c_str());
|
return get_size((*iter).second.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
mode_t get_mode(const char *s)
|
mode_t get_mode(const char *s, int base)
|
||||||
{
|
{
|
||||||
return static_cast<mode_t>(s3fs_strtoofft(s));
|
return static_cast<mode_t>(s3fs_strtoofft(s, base));
|
||||||
}
|
}
|
||||||
|
|
||||||
mode_t get_mode(headers_t& meta, const char* path, bool checkdir, bool forcedir)
|
mode_t get_mode(headers_t& meta, const char* path, bool checkdir, bool forcedir)
|
||||||
@ -849,6 +864,8 @@ mode_t get_mode(headers_t& meta, const char* path, bool checkdir, bool forcedir)
|
|||||||
}else if(meta.end() != (iter = meta.find("x-amz-meta-permissions"))){ // for s3sync
|
}else if(meta.end() != (iter = meta.find("x-amz-meta-permissions"))){ // for s3sync
|
||||||
mode = get_mode((*iter).second.c_str());
|
mode = get_mode((*iter).second.c_str());
|
||||||
isS3sync = true;
|
isS3sync = true;
|
||||||
|
}else if(meta.end() != (iter = meta.find("x-amz-meta-goog-reserved-posix-mode"))){ // for GCS
|
||||||
|
mode = get_mode((*iter).second.c_str(), 8);
|
||||||
}else{
|
}else{
|
||||||
// If another tool creates an object without permissions, default to owner
|
// If another tool creates an object without permissions, default to owner
|
||||||
// read-write and group readable.
|
// read-write and group readable.
|
||||||
@ -927,6 +944,8 @@ uid_t get_uid(headers_t& meta)
|
|||||||
return get_uid((*iter).second.c_str());
|
return get_uid((*iter).second.c_str());
|
||||||
}else if(meta.end() != (iter = meta.find("x-amz-meta-owner"))){ // for s3sync
|
}else if(meta.end() != (iter = meta.find("x-amz-meta-owner"))){ // for s3sync
|
||||||
return get_uid((*iter).second.c_str());
|
return get_uid((*iter).second.c_str());
|
||||||
|
}else if(meta.end() != (iter = meta.find("x-amz-meta-goog-reserved-posix-uid"))){ // for GCS
|
||||||
|
return get_uid((*iter).second.c_str());
|
||||||
}else{
|
}else{
|
||||||
return geteuid();
|
return geteuid();
|
||||||
}
|
}
|
||||||
@ -944,6 +963,8 @@ gid_t get_gid(headers_t& meta)
|
|||||||
return get_gid((*iter).second.c_str());
|
return get_gid((*iter).second.c_str());
|
||||||
}else if(meta.end() != (iter = meta.find("x-amz-meta-group"))){ // for s3sync
|
}else if(meta.end() != (iter = meta.find("x-amz-meta-group"))){ // for s3sync
|
||||||
return get_gid((*iter).second.c_str());
|
return get_gid((*iter).second.c_str());
|
||||||
|
}else if(meta.end() != (iter = meta.find("x-amz-meta-goog-reserved-posix-gid"))){ // for GCS
|
||||||
|
return get_gid((*iter).second.c_str());
|
||||||
}else{
|
}else{
|
||||||
return getegid();
|
return getegid();
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ time_t get_mtime(headers_t& meta, bool overcheck = true);
|
|||||||
time_t get_ctime(headers_t& meta, bool overcheck = true);
|
time_t get_ctime(headers_t& meta, bool overcheck = true);
|
||||||
off_t get_size(const char *s);
|
off_t get_size(const char *s);
|
||||||
off_t get_size(headers_t& meta);
|
off_t get_size(headers_t& meta);
|
||||||
mode_t get_mode(const char *s);
|
mode_t get_mode(const char *s, int base = 0);
|
||||||
mode_t get_mode(headers_t& meta, const char* path = NULL, bool checkdir = false, bool forcedir = false);
|
mode_t get_mode(headers_t& meta, const char* path = NULL, bool checkdir = false, bool forcedir = false);
|
||||||
uid_t get_uid(const char *s);
|
uid_t get_uid(const char *s);
|
||||||
uid_t get_uid(headers_t& meta);
|
uid_t get_uid(headers_t& meta);
|
||||||
|
@ -540,8 +540,8 @@ function test_update_time() {
|
|||||||
|
|
||||||
# create the test
|
# create the test
|
||||||
mk_test_file
|
mk_test_file
|
||||||
mtime=`get_ctime $TEST_TEXT_FILE`
|
ctime=`get_ctime $TEST_TEXT_FILE`
|
||||||
ctime=`get_mtime $TEST_TEXT_FILE`
|
mtime=`get_mtime $TEST_TEXT_FILE`
|
||||||
|
|
||||||
sleep 2
|
sleep 2
|
||||||
chmod +x $TEST_TEXT_FILE
|
chmod +x $TEST_TEXT_FILE
|
||||||
|
Loading…
Reference in New Issue
Block a user