summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeung-Woo Kim <sw0312.kim@samsung.com>2018-04-30 14:57:58 +0900
committerSeung-Woo Kim <sw0312.kim@samsung.com>2018-05-18 12:51:36 +0900
commit701e944daaa1fb9f8ac8a8b5441531f1e639555f (patch)
treed95c494761821fef8f8e0cb55a29b88130e94854
parent7da7ee14ea6eed60274ef3d65d16e842547bbd3e (diff)
downloadlthor-701e944daaa1fb9f8ac8a8b5441531f1e639555f.tar.gz
lthor-701e944daaa1fb9f8ac8a8b5441531f1e639555f.tar.bz2
lthor-701e944daaa1fb9f8ac8a8b5441531f1e639555f.zip
Update for THOR 5.0 support
Until THOR 4.0, it uses only 32bit to send file size. From THOR 5.0, it starts to use two 32bit variables for the file size. Update for the THOR 5.0 protocol support. Change-Id: I3569d51179bb75b034a62f902e8640a1232d6ed3 Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
-rw-r--r--libthor/thor.c12
-rw-r--r--libthor/thor.h2
-rw-r--r--lthor.c8
3 files changed, 14 insertions, 8 deletions
diff --git a/libthor/thor.c b/libthor/thor.c
index 0a98c6d..cfd2302 100644
--- a/libthor/thor.c
+++ b/libthor/thor.c
@@ -160,8 +160,13 @@ static int t_thor_exec_cmd(thor_device_handle *th, request_type req_id,
int thor_start_session(thor_device_handle *th, off_t total)
{
int ret;
+ uint32_t int_data[2];
- ret = t_thor_exec_cmd(th, RQT_DL, RQT_DL_INIT, (int *)&total, 1);
+ int_data[0] = (uint32_t)(total & 0xffffffff);
+ int_data[1] = (uint32_t)((total >> 32) & 0xffffffff);
+
+ ret = t_thor_exec_cmd(th, RQT_DL, RQT_DL_INIT, int_data,
+ ARRAY_SIZE(int_data));
return ret;
}
@@ -449,7 +454,7 @@ int thor_send_data(thor_device_handle *th, struct thor_data_src *data,
const char *str_data[2] = { NULL, NULL };
int scnt;
struct res_pkt resp;
- int32_t int_data[2];
+ int32_t int_data[3];
off_t trans_unit_size;
int ret;
@@ -464,7 +469,8 @@ int thor_send_data(thor_device_handle *th, struct thor_data_src *data,
filename = data->get_name(data);
int_data[0] = type;
- int_data[1] = filesize;
+ int_data[1] = (uint32_t)(filesize & 0xffffffff);
+ int_data[2] = (uint32_t)((filesize >> 32) & 0xffffffff);
if (strlen(filename) <= 32) {
/*
diff --git a/libthor/thor.h b/libthor/thor.h
index 213a8b2..7f13ff5 100644
--- a/libthor/thor.h
+++ b/libthor/thor.h
@@ -58,7 +58,7 @@ enum thor_data_src_format {
typedef void (*thor_progress_cb)(thor_device_handle *th,
struct thor_data_src *data,
- unsigned int sent, unsigned int left,
+ off_t sent, off_t left,
int chunk_nmb, void *user_data);
typedef void (*thor_next_entry_cb)(thor_device_handle *th,
diff --git a/lthor.c b/lthor.c
index 268e807..bb33436 100644
--- a/lthor.c
+++ b/lthor.c
@@ -27,7 +27,7 @@
#include "thor.h"
-#define KB (1024)
+#define KB (1024U)
#define MB (1024*KB)
#define GB ((off_t)1024*MB)
@@ -45,7 +45,7 @@ struct helper {
struct time_data {
struct timeval start_time;
struct timeval last_time;
- int last_sent;
+ off_t last_sent;
};
static int test_tar_file_list(char **tarfilelist)
@@ -174,7 +174,7 @@ static double timediff(struct timeval *atv, struct timeval *btv)
}
static void report_progress(thor_device_handle *th, struct thor_data_src *data,
- unsigned int sent, unsigned int left, int chunk_nmb,
+ off_t sent, off_t left, int chunk_nmb,
void *user_data)
{
struct time_data *tdata = user_data;
@@ -302,7 +302,7 @@ static int process_download(struct thor_device_id *dev_id, const char *pitfile,
printf("[" TERM_LIGHT_GREEN "%s" TERM_NORMAL "]"
"\t %jdk\n",
(*ent)->name,
- (intmax_t)((*ent)->size/KB));
+ (uint64_t)((*ent)->size/KB));
total_size += size;
}