diff options
Diffstat (limited to 'src/ifuse.c')
| -rw-r--r-- | src/ifuse.c | 21 |
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 | |||
| 41 | AFClient *afc = NULL; | ||
| 42 | GHashTable *file_handles; | 40 | GHashTable *file_handles; |
| 43 | int fh_index = 0; | 41 | int fh_index = 0; |
| 44 | 42 | ||
| @@ -47,6 +45,7 @@ int debug = 0; | |||
| 47 | static int ifuse_getattr(const char *path, struct stat *stbuf) { | 45 | static 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 | ||
| 80 | static int ifuse_open(const char *path, struct fuse_file_info *fi) { | 80 | static 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 | ||
| 148 | void ifuse_cleanup() { | 153 | void 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 | ||
| 153 | static struct fuse_operations ifuse_oper = { | 160 | static struct fuse_operations ifuse_oper = { |
