summaryrefslogtreecommitdiffstats
path: root/src/ifuse.c
diff options
context:
space:
mode:
authorGravatar Matt Colyer2008-08-01 08:46:16 -0700
committerGravatar Matt Colyer2008-08-01 08:46:16 -0700
commitf492fa820bf35e96092ad7110d80708629c038ae (patch)
treee9f30bf23d3fdf03611a2473c619a50439d7917f /src/ifuse.c
parentd05ae226356cc674a055c784a4b9b75825162ba6 (diff)
downloadlibimobiledevice-f492fa820bf35e96092ad7110d80708629c038ae.tar.gz
libimobiledevice-f492fa820bf35e96092ad7110d80708629c038ae.tar.bz2
A few cleanups, got rid of global afc variable.
Diffstat (limited to 'src/ifuse.c')
-rw-r--r--src/ifuse.c21
1 files changed, 14 insertions, 7 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 = {