mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-22 08:48:55 +00:00
parent
5bf2b46fa3
commit
e811ae1104
19
src/s3fs.cpp
19
src/s3fs.cpp
@ -114,6 +114,7 @@ static bool is_s3fs_uid = false;// default does not set.
|
||||
static bool is_s3fs_gid = false;// default does not set.
|
||||
static bool is_s3fs_umask = false;// default does not set.
|
||||
static bool is_remove_cache = false;
|
||||
static bool create_bucket = false;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Static functions : prototype
|
||||
@ -782,6 +783,16 @@ static int s3fs_readlink(const char* path, char* buf, size_t size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_create_bucket(void)
|
||||
{
|
||||
FPRNNN("/");
|
||||
|
||||
headers_t meta;
|
||||
|
||||
S3fsCurl s3fscurl(true);
|
||||
return s3fscurl.PutRequest("/", meta, -1); // fd=-1 means for creating zero byte object.
|
||||
}
|
||||
|
||||
// common function for creation of a plain object
|
||||
static int create_file_object(const char* path, mode_t mode, uid_t uid, gid_t gid)
|
||||
{
|
||||
@ -2682,6 +2693,10 @@ static void* s3fs_init(struct fuse_conn_info* conn)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (create_bucket){
|
||||
do_create_bucket();
|
||||
}
|
||||
|
||||
// Check Bucket
|
||||
// If the network is up, check for valid credentials and if the bucket
|
||||
// exists. skip check if mounting a public bucket
|
||||
@ -3862,6 +3877,10 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
|
||||
S3fsCurl::SetSignatureV4(false);
|
||||
return 0;
|
||||
}
|
||||
if(0 == strcmp(arg, "createbucket")){
|
||||
create_bucket = true;
|
||||
return 0;
|
||||
}
|
||||
if(0 == STR2NCMP(arg, "endpoint=")){
|
||||
endpoint = strchr(arg, '=') + sizeof(char);
|
||||
is_specified_endpoint = true;
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
S3FS=../src/s3fs
|
||||
|
||||
S3FS_CREDENTIALS_FILE=$(eval echo ~${SUDO_USER}/.passwd-s3fs)
|
||||
S3FS_CREDENTIALS_FILE="passwd-s3fs"
|
||||
|
||||
TEST_BUCKET_1=${SUDO_USER}-s3fs-integration-test
|
||||
TEST_BUCKET_1="s3fs-integration-test"
|
||||
TEST_BUCKET_MOUNT_POINT_1=${TEST_BUCKET_1}
|
||||
|
||||
if [ ! -f "$S3FS_CREDENTIALS_FILE" ]
|
||||
@ -12,3 +12,9 @@ then
|
||||
echo "Missing credentials file: $S3FS_CREDENTIALS_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
S3PROXY_VERSION="1.3.0"
|
||||
S3PROXY_BINARY="s3proxy-${S3PROXY_VERSION}-jar-with-dependencies.jar"
|
||||
if [ ! -e "${S3PROXY_BINARY}" ]; then
|
||||
wget "http://repo1.maven.org/maven2/org/gaul/s3proxy/${S3PROXY_VERSION}/${S3PROXY_BINARY}"
|
||||
fi
|
||||
|
1
test/passwd-s3fs
Normal file
1
test/passwd-s3fs
Normal file
@ -0,0 +1 @@
|
||||
local-identity:local-credential
|
8
test/s3proxy.conf
Normal file
8
test/s3proxy.conf
Normal file
@ -0,0 +1,8 @@
|
||||
s3proxy.endpoint=http://127.0.0.1:8080
|
||||
s3proxy.authorization=aws-v2
|
||||
s3proxy.identity=local-identity
|
||||
s3proxy.credential=local-credential
|
||||
|
||||
jclouds.provider=transient
|
||||
jclouds.identity=remote-identity
|
||||
jclouds.credential=remote-credential
|
@ -3,16 +3,39 @@
|
||||
# Require root
|
||||
REQUIRE_ROOT=require-root.sh
|
||||
#source $REQUIRE_ROOT
|
||||
source integration-test-common.sh
|
||||
|
||||
java -jar "$S3PROXY_BINARY" --properties s3proxy.conf &
|
||||
S3PROXY_PID="$?"
|
||||
|
||||
# wait for S3Proxy to start
|
||||
for i in $(seq 30);
|
||||
do
|
||||
if exec 3<>"/dev/tcp/localhost/8080";
|
||||
then
|
||||
exec 3<&- # Close for read
|
||||
exec 3>&- # Close for write
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Mount the bucket
|
||||
if [ ! -d $TEST_BUCKET_MOUNT_POINT_1 ]
|
||||
then
|
||||
mkdir -p $TEST_BUCKET_MOUNT_POINT_1
|
||||
fi
|
||||
$S3FS $TEST_BUCKET_1 $TEST_BUCKET_MOUNT_POINT_1 -o passwd_file=$S3FS_CREDENTIALS_FILE
|
||||
$S3FS $TEST_BUCKET_1 $TEST_BUCKET_MOUNT_POINT_1 \
|
||||
-o createbucket \
|
||||
-o passwd_file=$S3FS_CREDENTIALS_FILE \
|
||||
-o sigv2 \
|
||||
-o url=http://127.0.0.1:8080 \
|
||||
-o use_path_request_style
|
||||
|
||||
./integration-test-main.sh $TEST_BUCKET_MOUNT_POINT_1
|
||||
|
||||
umount $TEST_BUCKET_MOUNT_POINT_1
|
||||
|
||||
kill $S3PROXY_PID
|
||||
|
||||
echo "All tests complete."
|
||||
|
Loading…
Reference in New Issue
Block a user