summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ifuse.c21
-rw-r--r--src/userpref.c6
2 files changed, 17 insertions, 10 deletions
diff --git a/src/ifuse.c b/src/ifuse.c
index 6ee8eb5..5b63152 100644
--- a/src/ifuse.c
+++ b/src/ifuse.c
@@ -37,8 +37,6 @@
#include "AFC.h"
#include "userpref.h"
-
-AFClient *afc = NULL;
GHashTable *file_handles;
int fh_index = 0;
@@ -47,6 +45,7 @@ int debug = 0;
static int ifuse_getattr(const char *path, struct stat *stbuf) {
int res = 0;
AFCFile *file;
+ AFClient *afc = fuse_get_context()->private_data;
memset(stbuf, 0, sizeof(struct stat));
file = afc_get_file_info(afc, path);
@@ -66,6 +65,7 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi) {
int i;
char **dirs, **filename;
+ AFClient *afc = fuse_get_context()->private_data;
dirs = afc_get_dir_list(afc, path);
for (i = 0; strcmp(dirs[i], ""); i++) {
@@ -79,6 +79,7 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
static int ifuse_open(const char *path, struct fuse_file_info *fi) {
AFCFile *file;
+ AFClient *afc = fuse_get_context()->private_data;
if((fi->flags & 3) != O_RDONLY)
return -EACCES;
@@ -96,6 +97,7 @@ static int ifuse_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi) {
int bytes;
AFCFile *file;
+ AFClient *afc = fuse_get_context()->private_data;
file = g_hash_table_lookup(file_handles, &(fi->fh));
if (!file){
@@ -111,7 +113,10 @@ void *ifuse_init(struct fuse_conn_info *conn) {
char *response = (char*)malloc(sizeof(char) * 2048);
int bytes = 0, port = 0, i = 0;
char* host_id = NULL;
+ AFClient *afc = NULL;
+ conn->async_read = 0;
+
file_handles = g_hash_table_new(g_int_hash, g_int_equal);
iPhone *phone = get_iPhone();
@@ -127,8 +132,8 @@ void *ifuse_init(struct fuse_conn_info *conn) {
}
host_id = get_host_id();
- if (host_id && !lockdownd_start_SSL_session(control, host_id)) {
- fprintf(stderr, "Something went wrong in GnuTLS.\n");
+ if (host_id && !lockdownd_start_SSL_session(control, host_id) || !host_id) {
+ fprintf(stderr, "Something went wrong in GnuTLS. Is your HostID configured in .config/libiphone/libiphonerc?\n");
return NULL;
}
free(host_id);
@@ -145,9 +150,11 @@ void *ifuse_init(struct fuse_conn_info *conn) {
return afc;
}
-void ifuse_cleanup() {
- free_iPhone(afc->phone);
- afc_disconnect(afc);
+void ifuse_cleanup(AFClient *afc) {
+ if (afc) {
+ free_iPhone(afc->phone);
+ afc_disconnect(afc);
+ }
}
static struct fuse_operations ifuse_oper = {
diff --git a/src/userpref.c b/src/userpref.c
index b877700..a2b77dc 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -32,14 +32,14 @@ char* get_host_id()
gchar* config_file = NULL;
/* first get config file */
- config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL);
+ config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL);
if (g_file_test(config_file, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
- /*now parse file to get the HostID*/
+ /* now parse file to get the HostID */
GKeyFile* key_file = g_key_file_new ();
if( g_key_file_load_from_file (key_file, config_file, G_KEY_FILE_KEEP_COMMENTS, NULL) ) {
- gchar* loc_host_id = g_key_file_get_value(key_file, "Global", "HostID", NULL);
+ gchar* loc_host_id = g_key_file_get_value(key_file, "Global", "HostID", NULL);
if (loc_host_id)
host_id = strdup(loc_host_id);
g_free(loc_host_id);