struct data_thread data;
-void* Function(int);
+int Function(int);
#endif
}
}
- if (en - st < 2) {
- x = matchlen(old + I[st], oldsize - I[st], new, newsize);
- y = matchlen(old + I[en], oldsize - I[en], new, newsize);
+ x = matchlen(old + I[st], oldsize - I[st], new, newsize);
+ y = matchlen(old + I[en], oldsize - I[en], new, newsize);
- if (x > y) {
- *pos = I[st];
- return x;
- } else {
- *pos = I[en];
- return y;
- }
- };
+ if (x > y) {
+ *pos = I[st];
+ return x;
+ } else {
+ *pos = I[en];
+ return y;
+ }
}
static void offtout(off_t x, u_char *buf)
buf[7] |= 0x80;
}
-int create_patch(int argc, char *argv[], int offset_oldscore)
+int create_patch(int argc, const char *argv[], int offset_oldscore)
{
data.num_threads = MULTI_THREADING;
data.new = (u_char **)malloc(sizeof(u_char *)*data.num_threads);
return ret;
}
-void* Function(int offset_oldscore)
+int Function(int offset_oldscore)
{
unsigned int thread_num = 0;
off_t end;
off_t lens;
off_t i;
+ pos = 0;
len = 0;
lastscan = 0;
lastpos = 0;
{
CFileSeqInStream inStream;
CFileOutStream outStream;
- char c;
int res;
- int encodeMode;
- Bool useOutFile = False;
FileSeqInStream_CreateVTable(&inStream);
File_Construct(&inStream.file);
FileOutStream_CreateVTable(&outStream);
File_Construct(&outStream.file);
- encodeMode = 1;
-
size_t t4 = sizeof(UInt32);
size_t t8 = sizeof(UInt64);
if (t4 != 4 || t8 != 8)
int main2(int numArgs, const char *args[], char *rs)
{
CFileSeqInStream inStream;
- ISeqOutStream outStream;
+ CFileOutStream outStream;
int res, fd;
int encodeMode;
- char * buf_res = NULL;
- unsigned char* new_data;
+ unsigned char *buf_res = NULL;
+ unsigned char *new_data;
ssize_t new_size;
FileSeqInStream_CreateVTable(&inStream);
File_GetLength(&inStream.file, &fileSize);
//res = Encode(&outStream.s, &inStream.s, fileSize, rs);
} else {
- UInt64 unpackSize, i, dest_len;
+ UInt64 unpackSize, i;
CLzmaDec state;
unsigned char header[LZMA_PROPS_SIZE + 8];
RINOK(SeqInStream_Read(&inStream.s, header, sizeof(header)));
unpackSize += (UInt64)header[LZMA_PROPS_SIZE + i] << (i * 8);
buf_res = (unsigned char *)malloc(unpackSize);
memset(buf_res, 0x0, unpackSize);
- dest_len = unpackSize;
LzmaDec_Construct(&state);
RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc));
- res = Decode2(&state, &outStream, &inStream.s, &unpackSize, buf_res);
+ res = Decode2(&state, &outStream.s, &inStream.s, &unpackSize, buf_res);
LzmaDec_Free(&state, &g_Alloc);
File_Close(&inStream.file);
if (apply_patch(args[1], buf_res, &new_data, &new_size) != 0) {
free(buf_res);
return 0;
}
+ return 1;
}
int main(int numArgs, const char *args[])
}
}
-int apply_patch(char *oldfile, char *patch_buffer, unsigned char **dest_buf, ssize_t *dest_size)
+int apply_patch(const char *oldfile, unsigned char *patch_buffer, unsigned char **dest_buf, ssize_t *dest_size)
{
int fd = -1, result = 0;
off_t oldsize, newsize;
SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inStream,
UInt64 *unpackSize, unsigned char *dec_data);
-int apply_patch(char *oldfile, char *patch_buffer, unsigned char **dest_buf, ssize_t *dest_size);
+int apply_patch(const char *oldfile, unsigned char *patch_buffer, unsigned char **dest_buf, ssize_t *dest_size);
#endif /* _SS_BSPATCH_COMMON_H */
Name: libtota
Summary: fota update library
-Version: 0.2.2
-Release: 3
+Version: 0.2.3
+Release: 4
Group: System
License: Apache-2.0 and BSD-2-Clause and BSD-3-Clause and PD
Source0: %{name}-%{version}.tar.gz
#include "fota_common.h"
#include "sha1.h"
#include "SS_Engine_Errors.h"
+#include "SS_FSUpdate.h"
#include "ss_bspatch_common.h"
#include <Alloc.h>
UInt64 unpackSize = 0;
CFileSeqInStream inStream;
ISeqOutStream outStream;
- char *buf_res = NULL;
+ unsigned char *buf_res = NULL;
unsigned char *new_data = NULL;
ssize_t new_size = 0;
int result = E_SS_FAILURE;
RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc));
//decompress the patch file into buf_res
- buf_res = (char *)SS_Malloc(unpackSize);
+ buf_res = (unsigned char *)SS_Malloc(unpackSize);
if (!buf_res) {
LOGE("Bad memory allocation\n");
goto Cleanup;
}
- result = Decode2(&state, &outStream, &inStream.s, &unpackSize, (unsigned char *)buf_res);
+ result = Decode2(&state, &outStream, &inStream.s, &unpackSize, buf_res);
LzmaDec_Free(&state, &g_Alloc);
File_Close(&inStream.file);
#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
+#include <strings.h>
#include <sys/smack.h>
#include <sys/wait.h>
if (ret == 0 || ((ret == -1) && (errno == EEXIST))) {
return 0; //meaning the depth creation is success.
} else if ((ret == -1) && (errno == ENOENT)) {
- if ((ret = SS_recursive_folder_creater(temppath, mode)) == 0);
+ if ((ret = SS_recursive_folder_creater(temppath, mode)) == 0)
ret = mkdir(temppath, mode);
return ret;
} else {
result = E_SS_MALLOC_ERROR;
goto Cleanup;
}
- fread(buf, 1, SS_KERNEL_DELTA_HEADER, fp);
+ ssize_t bytes_read = fread(buf, 1, SS_KERNEL_DELTA_HEADER, fp);
+ if (bytes_read != SS_KERNEL_DELTA_HEADER)
+ LOGL(LOG_SSENGINE, "short read of \"%s\" (%ld bytes of %ld)\n", SS_PATCHFILE_SOURCE, (long)bytes_read, (long)SS_KERNEL_DELTA_HEADER);
magic = strtok(buf, ":");
+ LOGL(LOG_SSENGINE, "magic: %s\n", magic);
file_num = atoi(strtok(NULL, ":"));
//adjust offset to start of data section before proceeding
}
#endif
+//Check SS function if available
+int file_exist(char *filename, int type)
+{
+ struct stat buf;
+ int ret = 0;
+
+ ret = lstat(filename, &buf);
+ if (ret < 0) {
+ ret = stat(filename, &buf);
+ }
+ return (ret >= 0) ? (1) : (0);
+}
+
long SS_GetUPIVersion(unsigned char *ver_str)
{
if (ver_str) {
return FS_UpgradeState;
}
-//Check SS function if available
-int file_exist(char *filename, int type)
-{
- struct stat buf;
- int ret = 0;
-
- ret = lstat(filename, &buf);
- if (ret < 0) {
- ret = stat(filename, &buf);
- }
- return (ret >= 0) ? (1) : (0);
-}
-
int SS_rename(const char *old_file_name, const char *new_file_name)
{
if (link(old_file_name, new_file_name) < 0) {
pfiletype = strtok(NULL, SS_TOKEN_SPACE);
attributSize = strtok(NULL, SS_TOKEN_SPACE);
pattribs = strtok(NULL, SS_TOKEN_NEWLINE);
+ LOG("\nSS_FSSetAttributes [%s][%s][%s]", pfiletype, attributSize, pattribs);
if (pattribs && pfilePath && pfiletype) {
ulAttribSize = strlen(pattribs);
//LOG("\nSS_SetFileAttributes [%s][%s][%d][%s]",pfilePath,pfiletype,ulAttribSize, pattribs );
FILE *fp = NULL;
char buf[14] = { 0, }; //to store zImage-delta magic keyword
+ ssize_t bytes_read;
fp = fopen(SS_PATCHFILE_SOURCE, "r");
- fread(buf, 1, 13, fp); //error check not required as any delta corruption will be caught in SS_UpdateDeltaIMG
+ bytes_read = fread(buf, 1, 13, fp); //error check not required as any delta corruption will be caught in SS_UpdateDeltaIMG
+ if (bytes_read != 13)
+ LOGL(LOG_SSENGINE, "short read of \"%s\" (%ld bytes of %ld)\n", SS_PATCHFILE_SOURCE, (long)bytes_read, (long)13);
fclose(fp);
if (strcmp(buf, SS_KERNEL_MAGIC) == 0)
#include <errno.h>
#include "SS_Engine_Update.h"
#include "SS_Engine_Errors.h"
+#include "SS_FSUpdate.h"
#include "fota_common.h"
#include "fota_tar.h"
#include "ua.h"
char dirPath[512] = { 0 };
int getheader = 1; // Asuming initial header is TAR header
char fullname[512] = { 0 };
+ int ret;
LOG("Extracting Folder from %s %s to %s\n", tar, item, path);
data_offset = tar_get_item_offset(tar, item);
memset(dirPath, 0, sizeof(dirPath));
sprintf(dirPath, "%s/%s", path, fullname + folderpathlen);
LOG(" Creating Symlink [%s][%s]\n", name, dirPath);
- symlink(name, dirPath); // use ss_link
+ ret = symlink(name, dirPath); // use ss_link
+ if (ret < 0)
+ LOG("Error with symlink: %d\n", errno);
}
break;
case '3':