diff options
author | Matt Colyer | 2008-10-17 08:54:40 -0700 |
---|---|---|
committer | Matt Colyer | 2008-10-17 08:54:40 -0700 |
commit | fe90955ffb6aef6f10fd77d5e1606f6f83ac74b4 (patch) | |
tree | 3e53ee6f3318c34fc139bb88d3aa70ad2ec2a574 /src/ifuse.c | |
parent | 4929cf01cfe053b934d962cf169c712044d4449d (diff) | |
download | ifuse-fe90955ffb6aef6f10fd77d5e1606f6f83ac74b4.tar.gz ifuse-fe90955ffb6aef6f10fd77d5e1606f6f83ac74b4.tar.bz2 |
Made afc the default, afc2 must be specified to use the jailbroken mode.
Diffstat (limited to 'src/ifuse.c')
-rw-r--r-- | src/ifuse.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/ifuse.c b/src/ifuse.c index 4832947..52c6a63 100644 --- a/src/ifuse.c +++ b/src/ifuse.c @@ -295,15 +295,17 @@ int ifuse_mkdir(const char *dir, mode_t ignored) return -1; } -void *ifuse_init(struct fuse_conn_info *conn) +void *ifuse_init_normal(struct fuse_conn_info *conn) { - if (ifuse_init_with_service(conn, "com.apple.afc2")){ - return; - }else{ - return ifuse_init_with_service(conn, "com.apple.afc"); - } + return ifuse_init_with_service(conn, "com.apple.afc"); +} + +void *ifuse_init_jailbroken(struct fuse_conn_info *conn) +{ + return ifuse_init_with_service(conn, "com.apple.afc2"); } + static struct fuse_operations ifuse_oper = { .getattr = ifuse_getattr, .statfs = ifuse_statfs, @@ -320,7 +322,7 @@ static struct fuse_operations ifuse_oper = { .rename = ifuse_rename, .fsync = ifuse_fsync, .release = ifuse_release, - .init = ifuse_init, + .init = ifuse_init_normal, .destroy = ifuse_cleanup }; @@ -331,7 +333,6 @@ static int ifuse_opt_proc(void *data, const char *arg, int key, static int option_num = 0; (void) data; - fprintf(stderr, "%s\n", arg); switch (key) { case FUSE_OPT_KEY_OPT: if (strcmp(arg, "allow_other") == 0) @@ -356,16 +357,34 @@ int main(int argc, char *argv[]) char **ammended_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); } - //fuse_opt_add_arg(&args, "-o allow_other"); + if (argc < 2){ + fprintf(stderr, "A path to the USB device must be specified\n"); + 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"); - + return fuse_main(args.argc, args.argv, &ifuse_oper, NULL); } |