Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
.SUFFIXES: .c .o

CC = @CC@
CFLAGS = @CFLAGS@ @XML_CFLAGS@ @CURL_CFLAGS@ @FUSE_CFLAGS@ @OPENSSL_CFLAGS@
CFLAGS = @CFLAGS@ @XML_CFLAGS@ @CURL_CFLAGS@ @FUSE_CFLAGS@ @OPENSSL_CFLAGS@ @GIO_CFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@ @XML_LIBS@ @CURL_LIBS@ @FUSE_LIBS@ @OPENSSL_LIBS@
LIBS = @LIBS@ @XML_LIBS@ @CURL_LIBS@ @FUSE_LIBS@ @OPENSSL_LIBS@ @GIO_LIBS@
INSTALL = @INSTALL@
MKDIR_P = @MKDIR_P@
prefix = @prefix@
Expand Down
4 changes: 4 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ BUILDING:
apt-get install build-essential libcurl4-openssl-dev libxml2-dev \
libssl-dev libfuse-dev

For MIME (Content-type header) support you need GIO. On Debian and
Ubuntu it comes with GLib:
apt-get install libglib2.0-dev

Cloudfuse is built and installed like any other autoconf configured code.
Normally,
./configure
Expand Down
44 changes: 43 additions & 1 deletion cloudfsapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
#include "cloudfsapi.h"
#include "config.h"

#ifdef HAVE_GIO
#include <glib.h>
#include <gio/gio.h>
#endif

#define REQUEST_RETRIES 4

static char storage_url[MAX_URL_SIZE];
Expand Down Expand Up @@ -143,10 +148,21 @@ static int send_request(char *method, const char *path, FILE *fp, xmlParserCtxtP
}
else if (!strcasecmp(method, "PUT") && fp)
{
#ifdef HAVE_GIO
gchar *guess_type = NULL;
gboolean guess_uncertain = TRUE;
#endif
rewind(fp);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
curl_easy_setopt(curl, CURLOPT_INFILESIZE, file_size(fileno(fp)));
curl_easy_setopt(curl, CURLOPT_READDATA, fp);
#ifdef HAVE_GIO
guess_type = g_content_type_guess(path, NULL, 0, &guess_uncertain);
if (! guess_uncertain && guess_type) {
add_header(&headers, "Content-Type", guess_type);
}
g_free(guess_type);
#endif
}
else if (!strcasecmp(method, "GET"))
{
Expand Down Expand Up @@ -338,8 +354,22 @@ int copy_object(const char *src, const char *dst)
{
char *dst_encoded = curl_escape(dst, 0);
curl_slist *headers = NULL;
#ifdef HAVE_GIO
gchar *guess_type = NULL;
gboolean guess_uncertain = TRUE;
#endif

add_header(&headers, "X-Copy-From", src);
add_header(&headers, "Content-Length", "0");
#ifdef HAVE_GIO
if (dst) {
guess_type = g_content_type_guess(dst, NULL, 0, &guess_uncertain);
if (! guess_uncertain && guess_type) {
add_header(&headers, "Content-Type", guess_type);
}
g_free(guess_type);
}
#endif
int response = send_request("PUT", dst_encoded, NULL, NULL, headers);
curl_free(dst_encoded);
curl_slist_free_all(headers);
Expand Down Expand Up @@ -395,7 +425,7 @@ int cloudfs_connect(char *username, char *password, char *authurl, int use_snet)
use_snet = reconnect_args.use_snet;
}


pthread_mutex_lock(&pool_mut);
debugf("Authenticating...");
storage_token[0] = storage_url[0] = '\0';
Expand Down Expand Up @@ -453,3 +483,15 @@ void debugf(char *fmt, ...)
}
}

/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
43 changes: 41 additions & 2 deletions cloudfuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
#include "cloudfsapi.h"
#include "config.h"

#ifdef HAVE_GIO
#include <glib.h>
#include <gio/gio.h>
#endif


#define OPTION_SIZE 1024

Expand Down Expand Up @@ -95,6 +100,11 @@ static void update_dir_cache(const char *path, off_t size, int isdir)
dir_cache *cw;
dir_entry *de;
char dir[MAX_PATH_SIZE];
#ifdef HAVE_GIO
gchar *guess_type;
gboolean guess_uncertain;
#endif

dir_for(path, dir);
for (cw = dcache; cw; cw = cw->next)
{
Expand All @@ -114,7 +124,21 @@ static void update_dir_cache(const char *path, off_t size, int isdir)
de->isdir = isdir;
de->name = strdup(&path[strlen(cw->path)+1]);
de->full_name = strdup(path);
de->content_type = strdup(isdir ? "application/directory" : "application/octet-stream");
if (isdir) {
de->content_type = strdup("application/directory");
} else {
#ifdef HAVE_GIO
guess_type = g_content_type_guess(de->name, NULL, 0, &guess_uncertain);
if (! guess_uncertain && guess_type) {
de->content_type = strdup(guess_type);
} else {
#endif
de->content_type = strdup("application/octet-stream");
}
#ifdef HAVE_GIO
g_free(guess_type);
}
#endif
de->last_modified = time(NULL);
de->next = cw->entries;
cw->entries = de;
Expand Down Expand Up @@ -449,7 +473,7 @@ int main(int argc, char **argv)
char settings_filename[MAX_PATH_SIZE] = "";
FILE *settings;
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);

fuse_opt_parse(&args, &options, NULL, parse_option);

snprintf(settings_filename, sizeof(settings_filename), "%s/.cloudfuse", get_home_dir());
Expand All @@ -462,6 +486,9 @@ int main(int argc, char **argv)
}

cache_timeout = atoi(options.cache_timeout);
#ifdef HAVE_GIO
g_type_init();
#endif

if (!*options.username || !*options.api_key)
{
Expand Down Expand Up @@ -516,3 +543,15 @@ int main(int argc, char **argv)
return fuse_main(args.argc, args.argv, &cfs_oper, &options);
}

/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
3 changes: 3 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
/* Openssl headers were found */
#undef HAVE_OPENSSL

/* GIO headers were found */
#undef HAVE_GIO

/* Define to 1 if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H

Expand Down
84 changes: 82 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ ALLOCA
EGREP
GREP
CPP
GIO_LIBS
GIO_CFLAGS
OPENSSL_LIBS
OPENSSL_CFLAGS
FUSE_LIBS
Expand Down Expand Up @@ -693,8 +695,9 @@ FUSE_CFLAGS
FUSE_LIBS
OPENSSL_CFLAGS
OPENSSL_LIBS
CPP
CPPFLAGS'
GIO_CFLAGS
GIO_LIBS
CPP'


# Initialize some variables set by options.
Expand Down Expand Up @@ -1325,6 +1328,8 @@ Some influential environment variables:
C compiler flags for OPENSSL, overriding pkg-config
OPENSSL_LIBS
linker flags for OPENSSL, overriding pkg-config
GIO_CFLAGS C compiler flags for GIO, overriding pkg-config
GIO_LIBS linker flags for GIO, overriding pkg-config
CPP C preprocessor

Use these variables to override the choices made by `configure' or to help
Expand Down Expand Up @@ -3618,6 +3623,81 @@ $as_echo "yes" >&6; }

fi

pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GIO" >&5
$as_echo_n "checking for GIO... " >&6; }

if test -n "$GIO_CFLAGS"; then
pkg_cv_GIO_CFLAGS="$GIO_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gio-2.0\""; } >&5
($PKG_CONFIG --exists --print-errors "gio-2.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_GIO_CFLAGS=`$PKG_CONFIG --cflags "gio-2.0" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$GIO_LIBS"; then
pkg_cv_GIO_LIBS="$GIO_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gio-2.0\""; } >&5
($PKG_CONFIG --exists --print-errors "gio-2.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_GIO_LIBS=`$PKG_CONFIG --libs "gio-2.0" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi



if test $pkg_failed = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }

if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
GIO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gio-2.0" 2>&1`
else
GIO_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gio-2.0" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$GIO_PKG_ERRORS" >&5

{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'Unable to find GIO. MIME type support disabled.'" >&5
$as_echo "$as_me: WARNING: 'Unable to find GIO. MIME type support disabled.'" >&2;}
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'Unable to find GIO. MIME type support disabled.'" >&5
$as_echo "$as_me: WARNING: 'Unable to find GIO. MIME type support disabled.'" >&2;}
else
GIO_CFLAGS=$pkg_cv_GIO_CFLAGS
GIO_LIBS=$pkg_cv_GIO_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }

$as_echo "#define HAVE_GIO /**/" >>confdefs.h

fi

# Checks for header files.

ac_ext=c
Expand Down
1 change: 1 addition & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ PKG_CHECK_MODULES(XML, libxml-2.0, , AC_MSG_ERROR('Unable to find libxml2. Pleas
PKG_CHECK_MODULES(CURL, libcurl, , AC_MSG_ERROR('Unable to find libcurl. Please make sure library and header files are installed.'))
PKG_CHECK_MODULES(FUSE, fuse, , AC_MSG_ERROR('Unable to find libfuse. Please make sure library and header files are installed.'))
PKG_CHECK_MODULES(OPENSSL, openssl, , [])
PKG_CHECK_MODULES(GIO, gio-2.0, AC_DEFINE([HAVE_GIO], [], [GIO package was found]), AC_MSG_WARN('Unable to find GIO. MIME type support disabled.'))

# Checks for header files.
AC_FUNC_ALLOCA
Expand Down