diff options
author | Nikias Bassen | 2012-07-16 16:07:01 +0200 |
---|---|---|
committer | Nikias Bassen | 2012-07-16 16:07:01 +0200 |
commit | 4211f24424a4b22b5941a52e8acd988a500488ee (patch) | |
tree | ae323f6f0d9131da50547194b1daaecc292d8a01 /src/ipsw.c | |
parent | eb2db6e2bedefa426fba43cc7a9d47d868a9d897 (diff) | |
download | idevicerestore-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.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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; } |