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 @@
37#include "AFC.h" 37#include "AFC.h"
38#include "userpref.h" 38#include "userpref.h"
39 39
40
41AFClient *afc = NULL;
42GHashTable *file_handles; 40GHashTable *file_handles;
43int fh_index = 0; 41int fh_index = 0;
44 42
@@ -47,6 +45,7 @@ int debug = 0;
47static int ifuse_getattr(const char *path, struct stat *stbuf) { 45static int ifuse_getattr(const char *path, struct stat *stbuf) {
48 int res = 0; 46 int res = 0;
49 AFCFile *file; 47 AFCFile *file;
48 AFClient *afc = fuse_get_context()->private_data;
50 49
51 memset(stbuf, 0, sizeof(struct stat)); 50 memset(stbuf, 0, sizeof(struct stat));
52 file = afc_get_file_info(afc, path); 51 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,
66 off_t offset, struct fuse_file_info *fi) { 65 off_t offset, struct fuse_file_info *fi) {
67 int i; 66 int i;
68 char **dirs, **filename; 67 char **dirs, **filename;
68 AFClient *afc = fuse_get_context()->private_data;
69 69
70 dirs = afc_get_dir_list(afc, path); 70 dirs = afc_get_dir_list(afc, path);
71 for (i = 0; strcmp(dirs[i], ""); i++) { 71 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,
79 79
80static int ifuse_open(const char *path, struct fuse_file_info *fi) { 80static int ifuse_open(const char *path, struct fuse_file_info *fi) {
81 AFCFile *file; 81 AFCFile *file;
82 AFClient *afc = fuse_get_context()->private_data;
82 83
83 if((fi->flags & 3) != O_RDONLY) 84 if((fi->flags & 3) != O_RDONLY)
84 return -EACCES; 85 return -EACCES;
@@ -96,6 +97,7 @@ static int ifuse_read(const char *path, char *buf, size_t size, off_t offset,
96 struct fuse_file_info *fi) { 97 struct fuse_file_info *fi) {
97 int bytes; 98 int bytes;
98 AFCFile *file; 99 AFCFile *file;
100 AFClient *afc = fuse_get_context()->private_data;
99 101
100 file = g_hash_table_lookup(file_handles, &(fi->fh)); 102 file = g_hash_table_lookup(file_handles, &(fi->fh));
101 if (!file){ 103 if (!file){
@@ -111,7 +113,10 @@ void *ifuse_init(struct fuse_conn_info *conn) {
111 char *response = (char*)malloc(sizeof(char) * 2048); 113 char *response = (char*)malloc(sizeof(char) * 2048);
112 int bytes = 0, port = 0, i = 0; 114 int bytes = 0, port = 0, i = 0;
113 char* host_id = NULL; 115 char* host_id = NULL;
116 AFClient *afc = NULL;
114 117
118 conn->async_read = 0;
119
115 file_handles = g_hash_table_new(g_int_hash, g_int_equal); 120 file_handles = g_hash_table_new(g_int_hash, g_int_equal);
116 121
117 iPhone *phone = get_iPhone(); 122 iPhone *phone = get_iPhone();
@@ -127,8 +132,8 @@ void *ifuse_init(struct fuse_conn_info *conn) {
127 } 132 }
128 133
129 host_id = get_host_id(); 134 host_id = get_host_id();
130 if (host_id && !lockdownd_start_SSL_session(control, host_id)) { 135 if (host_id && !lockdownd_start_SSL_session(control, host_id) || !host_id) {
131 fprintf(stderr, "Something went wrong in GnuTLS.\n"); 136 fprintf(stderr, "Something went wrong in GnuTLS. Is your HostID configured in .config/libiphone/libiphonerc?\n");
132 return NULL; 137 return NULL;
133 } 138 }
134 free(host_id); 139 free(host_id);
@@ -145,9 +150,11 @@ void *ifuse_init(struct fuse_conn_info *conn) {
145 return afc; 150 return afc;
146} 151}
147 152
148void ifuse_cleanup() { 153void ifuse_cleanup(AFClient *afc) {
149 free_iPhone(afc->phone); 154 if (afc) {
150 afc_disconnect(afc); 155 free_iPhone(afc->phone);
156 afc_disconnect(afc);
157 }
151} 158}
152 159
153static struct fuse_operations ifuse_oper = { 160static struct fuse_operations ifuse_oper = {