diff options
| -rw-r--r-- | configure.ac | 19 | ||||
| -rw-r--r-- | src/ideviceinstaller.c | 11 | 
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  AC_FUNC_REALLOC  AC_CHECK_FUNCS([strcasecmp strdup strerror strndup]) +# Check for lstat + +AC_MSG_CHECKING([whether lstat is available]) +AC_TRY_LINK([ +#include <sys/types.h> +#include <sys/stat.h> +#if defined(HAVE_UNISTD_H) +#include <unistd.h> +#endif +],[ +struct stat st; +lstat("/tmp", &st); +], [have_lstat="yes"], [have_lstat="no"]) +AC_MSG_RESULT([${have_lstat}]) + +if test "x${have_lstat}" = "xyes" ; then +  AC_DEFINE([HAVE_LSTAT], 1, [Define if lstat syscall is supported]) +fi +  AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith  -Wwrite-strings -Wswitch-default -Wno-unused-parameter -Werror -g")  AC_SUBST(GLOBAL_CFLAGS) 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 @@  #include <limits.h>  #include <sys/stat.h>  #include <dirent.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif  #include <libimobiledevice/libimobiledevice.h>  #include <libimobiledevice/lockdown.h> @@ -537,6 +540,14 @@ static void afc_upload_dir(afc_client_t afc, const char* path, const char* afcpa  			strcat(apath, "/");  			strcat(apath, ep->d_name); +#ifdef HAVE_LSTAT +			if ((lstat(fpath, &st) == 0) && S_ISLNK(st.st_mode)) { +				char *target = (char *)malloc(st.st_size); +				readlink(fpath, target, st.st_size); +				afc_make_link(afc, AFC_SYMLINK, target, fpath); +				free(target); +			} else +#endif  			if ((stat(fpath, &st) == 0) && S_ISDIR(st.st_mode)) {  				afc_upload_dir(afc, fpath, apath);  			} else { | 
