summaryrefslogtreecommitdiffstats
path: root/src/ipsw.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-07-16 16:07:01 +0200
committerGravatar Nikias Bassen2012-07-16 16:07:01 +0200
commit4211f24424a4b22b5941a52e8acd988a500488ee (patch)
treeae323f6f0d9131da50547194b1daaecc292d8a01 /src/ipsw.c
parenteb2db6e2bedefa426fba43cc7a9d47d868a9d897 (diff)
downloadidevicerestore-4211f24424a4b22b5941a52e8acd988a500488ee.tar.gz
idevicerestore-4211f24424a4b22b5941a52e8acd988a500488ee.tar.bz2
ipsw: implemented file locking for on-demand downloading
Diffstat (limited to 'src/ipsw.c')
-rw-r--r--src/ipsw.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ipsw.c b/src/ipsw.c
index 033b894..8e3d598 100644
--- a/src/ipsw.c
+++ b/src/ipsw.c
@@ -26,6 +26,7 @@
#include <openssl/sha.h>
#include "ipsw.h"
+#include "locking.h"
#include "idevicerestore.h"
#define BUFSIZE 0x100000
@@ -403,6 +404,15 @@ int ipsw_download_latest_fw(plist_t version_data, const char* product, const cha
char fwlfn[256];
sprintf(fwlfn, "%s/%s", todir, fwfn);
+ char fwlock[256];
+ sprintf(fwlock, "%s.lock", fwlfn);
+
+ lock_info_t lockinfo;
+
+ if (lock_file(fwlock, &lockinfo) != 0) {
+ error("WARNING: Could not lock file '%s'\n", fwlock);
+ }
+
int need_dl = 0;
unsigned char zsha1[20] = {0, };
FILE* f = fopen(fwlfn, "rb");
@@ -452,5 +462,10 @@ int ipsw_download_latest_fw(plist_t version_data, const char* product, const cha
if (res == 0) {
*ipswfile = strdup(fwlfn);
}
+
+ if (unlock_file(&lockinfo) != 0) {
+ error("WARNING: Could not unlock file '%s'\n", fwlock);
+ }
+
return res;
}