summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-01-21 12:41:28 +0100
committerGravatar Matt Colyer2010-01-21 21:13:40 -0800
commitf97fdbda9e5660186f40cbeaab82ae7bc0bce5b4 (patch)
treeb377e76047653264b5b3c33579c667298a56e4c5 /src
parent267f8d0aa6d33394ec8c53e24ad7ffeb35288cf3 (diff)
downloadifuse-f97fdbda9e5660186f40cbeaab82ae7bc0bce5b4.tar.gz
ifuse-f97fdbda9e5660186f40cbeaab82ae7bc0bce5b4.tar.bz2
Improve error message on failed root filesystem access and add hint to README
The AFC2 service required to access the root filesystem is non-standard. It is installed by older jailbreaking software but for instance not by blackra1n for devices like the 3GS. Now users get a better hint at why their attempts to use ifuse fail with the --root switch. This also moves the print to stderr where it actually can be seen by users. [#107 state:resolved]
Diffstat (limited to 'src')
-rw-r--r--src/ifuse.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/ifuse.c b/src/ifuse.c
index 949ae38..3de393f 100644
--- a/src/ifuse.c
+++ b/src/ifuse.c
@@ -35,6 +35,9 @@
#include <stdint.h>
#include <stdlib.h>
+#define AFC_SERVICE_NAME "com.apple.afc"
+#define AFC2_SERVICE_NAME "com.apple.afc2"
+
typedef uint32_t uint32; // this annoys me too
#include <libiphone/libiphone.h>
@@ -52,6 +55,8 @@ int debug = 0;
static struct {
char *mount_point;
char *device_uuid;
+ char *service_name;
+ uint16_t port;
} opts;
enum {
@@ -366,21 +371,13 @@ static int ifuse_release(const char *path, struct fuse_file_info *fi)
return 0;
}
-void *ifuse_init_with_service(struct fuse_conn_info *conn, const char *service_name)
+void *ifuse_init(struct fuse_conn_info *conn)
{
- uint16_t port = 0;
afc_client_t afc = NULL;
conn->async_read = 0;
- if (LOCKDOWN_E_SUCCESS == lockdownd_start_service(control, service_name, &port) && !port) {
- lockdownd_client_free(control);
- iphone_device_free(phone);
- fprintf(stderr, "Something went wrong when starting AFC.");
- return NULL;
- }
-
- afc_client_new(phone, port, &afc);
+ afc_client_new(phone, opts.port, &afc);
lockdownd_client_free(control);
control = NULL;
@@ -560,16 +557,6 @@ int ifuse_mkdir(const char *dir, mode_t ignored)
return -get_afc_error_as_errno(err);
}
-void *ifuse_init_normal(struct fuse_conn_info *conn)
-{
- 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,
@@ -590,7 +577,7 @@ static struct fuse_operations ifuse_oper = {
.utimens = ifuse_utimens,
.fsync = ifuse_fsync,
.release = ifuse_release,
- .init = ifuse_init_normal,
+ .init = ifuse_init,
.destroy = ifuse_cleanup
};
@@ -632,7 +619,7 @@ static int ifuse_opt_proc(void *data, const char *arg, int key, struct fuse_args
res = 0;
break;
case KEY_ROOT:
- ifuse_oper.init = ifuse_init_jailbroken;
+ opts.service_name = AFC2_SERVICE_NAME;
res = 0;
break;
case KEY_HELP:
@@ -667,6 +654,7 @@ int main(int argc, char *argv[])
lockdownd_error_t ret = LOCKDOWN_E_SUCCESS;
memset(&opts, 0, sizeof(opts));
+ opts.service_name = AFC_SERVICE_NAME;
if (fuse_opt_parse(&args, NULL, ifuse_opts, ifuse_opt_proc) == -1) {
return -1;
@@ -714,5 +702,17 @@ int main(int argc, char *argv[])
return 0;
}
+ if ((lockdownd_start_service(control, opts.service_name, &opts.port) != LOCKDOWN_E_SUCCESS) || !opts.port) {
+ lockdownd_client_free(control);
+ iphone_device_free(phone);
+ fprintf(stderr, "Failed to start AFC service '%s' on the device.\n", opts.service_name);
+ if (!strcmp(opts.service_name, AFC2_SERVICE_NAME)) {
+ fprintf(stderr, "This service enables access to the root filesystem of your device.\n");
+ fprintf(stderr, "Your device needs to be jailbroken and have this service installed.\n");
+ fprintf(stderr, "Note that PwnageTool installs it while blackra1n does not.\n");
+ }
+ return 0;
+ }
+
return fuse_main(args.argc, args.argv, &ifuse_oper, NULL);
}