diff options
author | Matt Colyer | 2009-01-13 23:49:56 -0800 |
---|---|---|
committer | Matt Colyer | 2009-01-13 23:49:56 -0800 |
commit | b3e4adbda64ffea81794b8c928922c5778636d05 (patch) | |
tree | 68af6ec290d7183cac43006f7c7bb4cded9da4bd /src | |
parent | 54311c89363d1d5ed375370635a17d96f141393c (diff) | |
download | ifuse-b3e4adbda64ffea81794b8c928922c5778636d05.tar.gz ifuse-b3e4adbda64ffea81794b8c928922c5778636d05.tar.bz2 |
Handle command options correctly and add helpful errors for common mistakes.
Diffstat (limited to 'src')
-rw-r--r-- | src/ifuse.c | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/src/ifuse.c b/src/ifuse.c index 670a458..8d36144 100644 --- a/src/ifuse.c +++ b/src/ifuse.c @@ -182,19 +182,6 @@ void *ifuse_init_with_service(struct fuse_conn_info *conn, const char *service_n file_handles = g_hash_table_new(g_int_hash, g_int_equal); - iphone_get_device(&phone); - if (!phone) { - fprintf(stderr, "No iPhone found, is it connected?\n"); - return NULL; - } - - - if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { - iphone_free_device(phone); - fprintf(stderr, "Something went wrong in the lockdownd client.\n"); - return NULL; - } - if (IPHONE_E_SUCCESS == iphone_lckd_start_service(control, service_name, &port) && !port) { iphone_lckd_free_client(control); iphone_free_device(phone); @@ -341,9 +328,12 @@ static int ifuse_opt_proc(void *data, const char *arg, int key, struct fuse_args switch (key) { case FUSE_OPT_KEY_OPT: - if (strcmp(arg, "allow_other") == 0) + if (strcmp(arg, "allow_other") == 0 || strcmp(arg, "-d") == 0 || strcmp(arg, "-s") == 0) return 1; - else + else if (strcmp(arg, "--afc2") == 0) { + ifuse_oper.init = ifuse_init_jailbroken; + return 0; + } else return 0; break; case FUSE_OPT_KEY_NONOPT: @@ -364,20 +354,6 @@ int main(int argc, char *argv[]) int i, j; struct fuse_args args = FUSE_ARGS_INIT(argc, argv); - // Parse extra options - if (argc > 2 && (ammended_argv = malloc((argc + 1) * sizeof(*ammended_argv)))) { - for (i = j = 0; ammended_argv[j] = argv[i], i < argc; i++) { - // Try to use the (jailbroken) com.apple.afc2 if requested by the user - if (argv[i] && strcmp("--afc2", argv[i]) == 0) { - ifuse_oper.init = ifuse_init_jailbroken; - continue; - } - j++; - } - argv = ammended_argv; - argc = j; - } - if (fuse_opt_parse(&args, NULL, NULL, ifuse_opt_proc) == -1) { exit(-1); } @@ -387,10 +363,20 @@ int main(int argc, char *argv[]) return -1; } - char *argument = malloc((strlen(argv[1]) + 10) * sizeof(char)); - sprintf(argument, "-ofsname=%s", argv[1]); - fuse_opt_add_arg(&args, argument); - fuse_opt_add_arg(&args, "-osubtype=ifuse"); + iphone_get_device(&phone); + if (!phone) { + fprintf(stderr, "No iPhone found, is it connected?\n"); + fprintf(stderr, "If it is make sure that your user has permissions to access the raw usb device.\n"); + fprintf(stderr, "If you're still having issues try unplugging the device and reconnecting it.\n"); + return NULL; + } + + if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { + iphone_free_device(phone); + fprintf(stderr, "Something went in lockdown handshake.\n"); + fprintf(stderr, "Did you run libiphone-initconf as the current user?\n"); + return NULL; + } return fuse_main(args.argc, args.argv, &ifuse_oper, NULL); } |