diff options
| -rw-r--r-- | README | 103 | ||||
| -rw-r--r-- | src/ifuse.c | 33 |
2 files changed, 124 insertions, 12 deletions
| @@ -1,6 +1,10 @@ | |||
| 1 | INSTALLATION | 1 | INSTALLATION |
| 2 | ================================================================================ | 2 | ================================================================================ |
| 3 | 3 | ||
| 4 | For: | ||
| 5 | Apple iPhone/iPod Touch 1.0/1.1/1.1.1/1.2/1.3/2.0+ | ||
| 6 | + iPod USB cable | ||
| 7 | |||
| 4 | You must have: | 8 | You must have: |
| 5 | libgnutls-dev | 9 | libgnutls-dev |
| 6 | libusb-dev | 10 | libusb-dev |
| @@ -17,25 +21,106 @@ To compile run: | |||
| 17 | ./autogen.sh | 21 | ./autogen.sh |
| 18 | ./configure | 22 | ./configure |
| 19 | make | 23 | make |
| 20 | sudo make install (if you want to install it into your system directories) | 24 | sudo make install # (if you want to install it into your system directories) |
| 21 | libiphone-initconf (as the user you intend to user the library) | 25 | libiphone-initconf # (as the user you intend to user the library) |
| 26 | |||
| 27 | On Ubuntu/Debian, you can do: | ||
| 28 | sudo apt-get install build-essential automake autoconf \ | ||
| 29 | libgnutls-dev libusb-dev libfuse-dev libglib2.0-dev libxml2-dev | ||
| 22 | 30 | ||
| 23 | USAGE | 31 | USAGE |
| 24 | ================================================================================ | 32 | ================================================================================ |
| 25 | 33 | ||
| 26 | IMPORTANT: Before using the library you must run "libiphone-initconf". It will | 34 | Now comes the fun bit! |
| 27 | generate keys and a host id for your system. It only needs to be run once but | 35 | |
| 28 | it MUST be run. | 36 | == Generating keys == |
| 37 | |||
| 38 | IMPORTANT: Before using the library you must run "libiphone-initconf" | ||
| 39 | as your own user (not root). It will generate keys and a host id for your | ||
| 40 | system to be able to communicate with 'lockdownd' on the iPhone. | ||
| 41 | |||
| 42 | It will probably take 5-10 minutes, but thankfully only needs to be | ||
| 43 | run _once_. It MUST be run otherwise communication will not work: | ||
| 44 | |||
| 45 | libiphone-initconf | ||
| 46 | |||
| 47 | The generated keys are saved in '~/.config/libiphone/' in your home directory. | ||
| 48 | |||
| 49 | == Tools == | ||
| 29 | 50 | ||
| 30 | There are currently 2 executables iphoneclient and ifuse, located in src/. | 51 | There are currently two more executables 'ifuse' and 'iphoneclient', |
| 52 | both located in src/. | ||
| 31 | 53 | ||
| 32 | iphoneclient is a basic commandline interface, it just runs a few various operations. | 54 | |
| 55 | === iFuse === | ||
| 56 | |||
| 57 | This is probably what you're after; this mounts a view of your | ||
| 58 | iPhone/iPod Touch's filesystem over the USB interface using the native | ||
| 59 | Apple protocol (AFC/"com.apple.afc"). | ||
| 33 | 60 | ||
| 34 | ifuse is a Fuse filesystem which allows you to mount your iPhone to a directory | 61 | ifuse is a Fuse filesystem which allows you to mount your iPhone to a directory |
| 35 | like this: | 62 | like this: |
| 36 | 63 | ||
| 37 | ./src/ifuse mountpoint | 64 | ./src/ifuse <mountpoint> -s |
| 38 | 65 | ||
| 39 | To unmount: | 66 | To unmount: |
| 40 | umount mountpoint | 67 | umount <mountpoint> |
| 68 | |||
| 69 | (nb: '-s' is to force single-threaded mode, as ifuse maybe unstable without it). | ||
| 70 | |||
| 71 | Eg: | ||
| 72 | mkdir ~/iphone | ||
| 73 | |||
| 74 | ifuse ~/iphone -s | ||
| 75 | ls -l ~/iphone | ||
| 76 | ... | ||
| 77 | umount ~/iphone | ||
| 78 | |||
| 79 | Currently ifuse (via the AFC protocol) only gives access to the | ||
| 80 | '/var/root/Media/' chroot on the iPhone (containing music/pictures). | ||
| 81 | |||
| 82 | If you have a device that has been jailedbreaked then an additional | ||
| 83 | ("com.apple.afc2") service will have been installed, without the chroot. | ||
| 84 | On jailbroken devices only, you can do: | ||
| 85 | |||
| 86 | ifuse ~/iphone --root -s | ||
| 87 | |||
| 88 | And this will mount a full view of the iPhone's filesystem. | ||
| 89 | |||
| 90 | |||
| 91 | ==== Setting up FUSE ==== | ||
| 92 | |||
| 93 | Note that on some systems, you may have to load the 'fuse' kernel | ||
| 94 | module first and to ensure that you are a member of the 'fuse' group: | ||
| 95 | |||
| 96 | sudo modprobe fuse | ||
| 97 | sudo adduser $USER fuse | ||
| 98 | |||
| 99 | You can check your membership of the 'fuse' group with: | ||
| 100 | |||
| 101 | id | grep fuse && echo yes! || echo not yet... | ||
| 102 | |||
| 103 | If you have just added yourself, you will need to logout and log back | ||
| 104 | in for the group change to become visible. | ||
| 105 | |||
| 106 | |||
| 107 | === iphoneclient === | ||
| 108 | |||
| 109 | 'iphoneclient' is a basic commandline interface for testing, it just | ||
| 110 | runs a few various test operations such as attempting to view/create a | ||
| 111 | test file in the iPhone, but is mainly a developer tool. | ||
| 112 | |||
| 113 | |||
| 114 | == Who/what/where? == | ||
| 115 | |||
| 116 | wiki: | ||
| 117 | http://matt.colyer.name/projects/iphone-linux/index.php?title=Main_Page | ||
| 118 | |||
| 119 | code: | ||
| 120 | git clone http://git.matt.colyer.name/2008/libiphone/ | ||
| 121 | |||
| 122 | mailing list: | ||
| 123 | http://lists.mattcolyer.com/listinfo.cgi/iphone-linux-dev-mattcolyer.com | ||
| 41 | 124 | ||
| 125 | updated: | ||
| 126 | 2008-09-02 | ||
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 | ||
| 172 | void *ifuse_init(struct fuse_conn_info *conn) | 172 | void *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 | ||
| 301 | void *ifuse_init_normal(struct fuse_conn_info *conn) | ||
| 302 | { | ||
| 303 | return ifuse_init_with_service(conn, "com.apple.afc"); | ||
| 304 | } | ||
| 305 | |||
| 306 | void *ifuse_init_jailbroken(struct fuse_conn_info *conn) | ||
| 307 | { | ||
| 308 | return ifuse_init_with_service(conn, "com.apple.afc2"); | ||
| 309 | } | ||
| 310 | |||
| 301 | static struct fuse_operations ifuse_oper = { | 311 | static 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 | ||
| 321 | int main(int argc, char *argv[]) | 331 | int 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 | } |
