summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2014-05-27 11:34:18 +0200
committerGravatar Martin Szulecki2014-05-27 11:34:18 +0200
commit5fbd3251e9ab03be952a876f261ca466398c1696 (patch)
treedc682f87a474113e82dbb1e25c5f966f5d60ecc5
parentf6fc79344487ac8e1f335fb86e0fb71c316f94a2 (diff)
downloadideviceinstaller-5fbd3251e9ab03be952a876f261ca466398c1696.tar.gz
ideviceinstaller-5fbd3251e9ab03be952a876f261ca466398c1696.tar.bz2
Add support for installing from directories which contain symlinks
-rw-r--r--configure.ac19
-rw-r--r--src/ideviceinstaller.c11
2 files changed, 30 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 11f24b4..0529da5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,25 @@ AC_FUNC_MALLOC
52AC_FUNC_REALLOC 52AC_FUNC_REALLOC
53AC_CHECK_FUNCS([strcasecmp strdup strerror strndup]) 53AC_CHECK_FUNCS([strcasecmp strdup strerror strndup])
54 54
55# Check for lstat
56
57AC_MSG_CHECKING([whether lstat is available])
58AC_TRY_LINK([
59#include <sys/types.h>
60#include <sys/stat.h>
61#if defined(HAVE_UNISTD_H)
62#include <unistd.h>
63#endif
64],[
65struct stat st;
66lstat("/tmp", &st);
67], [have_lstat="yes"], [have_lstat="no"])
68AC_MSG_RESULT([${have_lstat}])
69
70if test "x${have_lstat}" = "xyes" ; then
71 AC_DEFINE([HAVE_LSTAT], 1, [Define if lstat syscall is supported])
72fi
73
55AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -Werror -g") 74AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -Werror -g")
56AC_SUBST(GLOBAL_CFLAGS) 75AC_SUBST(GLOBAL_CFLAGS)
57 76
diff --git a/src/ideviceinstaller.c b/src/ideviceinstaller.c
index 17f7c17..55f3062 100644
--- a/src/ideviceinstaller.c
+++ b/src/ideviceinstaller.c
@@ -36,6 +36,9 @@
36#include <limits.h> 36#include <limits.h>
37#include <sys/stat.h> 37#include <sys/stat.h>
38#include <dirent.h> 38#include <dirent.h>
39#ifdef HAVE_UNISTD_H
40#include <unistd.h>
41#endif
39 42
40#include <libimobiledevice/libimobiledevice.h> 43#include <libimobiledevice/libimobiledevice.h>
41#include <libimobiledevice/lockdown.h> 44#include <libimobiledevice/lockdown.h>
@@ -537,6 +540,14 @@ static void afc_upload_dir(afc_client_t afc, const char* path, const char* afcpa
537 strcat(apath, "/"); 540 strcat(apath, "/");
538 strcat(apath, ep->d_name); 541 strcat(apath, ep->d_name);
539 542
543#ifdef HAVE_LSTAT
544 if ((lstat(fpath, &st) == 0) && S_ISLNK(st.st_mode)) {
545 char *target = (char *)malloc(st.st_size);
546 readlink(fpath, target, st.st_size);
547 afc_make_link(afc, AFC_SYMLINK, target, fpath);
548 free(target);
549 } else
550#endif
540 if ((stat(fpath, &st) == 0) && S_ISDIR(st.st_mode)) { 551 if ((stat(fpath, &st) == 0) && S_ISDIR(st.st_mode)) {
541 afc_upload_dir(afc, fpath, apath); 552 afc_upload_dir(afc, fpath, apath);
542 } else { 553 } else {