summaryrefslogtreecommitdiffstats
path: root/src/ifuse.c
diff options
context:
space:
mode:
authorGravatar Paul Sladen2008-09-02 11:47:39 +0300
committerGravatar Matt Colyer2008-09-02 08:37:31 -0700
commitb61d63f43f28d2ec94f750753b1d6d4748fd944b (patch)
tree3c47416eddb02704486f3b1a53d0fc2957710985 /src/ifuse.c
parent2b05e48cb4a90dfc94ff584124f08e431398bb1a (diff)
downloadlibimobiledevice-b61d63f43f28d2ec94f750753b1d6d4748fd944b.tar.gz
libimobiledevice-b61d63f43f28d2ec94f750753b1d6d4748fd944b.tar.bz2
Added --root option to use afc2, expand README
Diffstat (limited to 'src/ifuse.c')
-rw-r--r--src/ifuse.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/ifuse.c b/src/ifuse.c
index ad34eb5..aef24bd 100644
--- a/src/ifuse.c
+++ b/src/ifuse.c
@@ -169,7 +169,7 @@ static int ifuse_release(const char *path, struct fuse_file_info *fi)
169 return 0; 169 return 0;
170} 170}
171 171
172void *ifuse_init(struct fuse_conn_info *conn) 172void *ifuse_init_with_service(struct fuse_conn_info *conn, const char *service_name)
173{ 173{
174 int port = 0; 174 int port = 0;
175 iphone_afc_client_t afc = NULL; 175 iphone_afc_client_t afc = NULL;
@@ -191,7 +191,7 @@ void *ifuse_init(struct fuse_conn_info *conn)
191 return NULL; 191 return NULL;
192 } 192 }
193 193
194 if (IPHONE_E_SUCCESS == iphone_lckd_start_service(control, "com.apple.afc", &port) && !port) { 194 if (IPHONE_E_SUCCESS == iphone_lckd_start_service(control, service_name, &port) && !port) {
195 iphone_lckd_free_client(control); 195 iphone_lckd_free_client(control);
196 iphone_free_device(phone); 196 iphone_free_device(phone);
197 fprintf(stderr, "Something went wrong when starting AFC."); 197 fprintf(stderr, "Something went wrong when starting AFC.");
@@ -298,6 +298,16 @@ int ifuse_mkdir(const char *dir, mode_t ignored)
298 return -1; 298 return -1;
299} 299}
300 300
301void *ifuse_init_normal(struct fuse_conn_info *conn)
302{
303 return ifuse_init_with_service(conn, "com.apple.afc");
304}
305
306void *ifuse_init_jailbroken(struct fuse_conn_info *conn)
307{
308 return ifuse_init_with_service(conn, "com.apple.afc2");
309}
310
301static struct fuse_operations ifuse_oper = { 311static struct fuse_operations ifuse_oper = {
302 .getattr = ifuse_getattr, 312 .getattr = ifuse_getattr,
303 .statfs = ifuse_statfs, 313 .statfs = ifuse_statfs,
@@ -314,11 +324,28 @@ static struct fuse_operations ifuse_oper = {
314 .rename = ifuse_rename, 324 .rename = ifuse_rename,
315 .fsync = ifuse_fsync, 325 .fsync = ifuse_fsync,
316 .release = ifuse_release, 326 .release = ifuse_release,
317 .init = ifuse_init, 327 .init = ifuse_init_normal,
318 .destroy = ifuse_cleanup 328 .destroy = ifuse_cleanup
319}; 329};
320 330
321int main(int argc, char *argv[]) 331int main(int argc, char *argv[])
322{ 332{
333 char **ammended_argv;
334 int i, j;
335
336 // Parse extra options
337 if (argc > 2 && (ammended_argv = malloc((argc + 1) * sizeof(*ammended_argv)))) {
338 for (i = j = 0; ammended_argv[j] = argv[i], i < argc; i++) {
339 // Try to use the (jailbroken) com.apple.afc2 if requested by the user
340 if (argv[i] && (!strcmp("--root", argv[i]) || !strcmp("--afc2", argv[i]))) {
341 ifuse_oper.init = ifuse_init_jailbroken;
342 continue;
343 }
344 j++;
345 }
346 argv = ammended_argv;
347 argc = j;
348 }
349
323 return fuse_main(argc, argv, &ifuse_oper, NULL); 350 return fuse_main(argc, argv, &ifuse_oper, NULL);
324} 351}