Update for THOR 5.0 support 05/177605/3
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 30 Apr 2018 05:57:58 +0000 (14:57 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 18 May 2018 03:51:36 +0000 (12:51 +0900)
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>
libthor/thor.c
libthor/thor.h
lthor.c

index 0a98c6dc9b3afc8421876b5f6b87a86ad5a04375..cfd2302a4b28e240d4304da6abf169c4c4cb29ae 100644 (file)
@@ -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) {
                        /*
index 213a8b225c4bcb6d1a63908f72dcfe8ea76a0ede..7f13ff5f0caeb9795c205fd36421eca28161629e 100644 (file)
@@ -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 268e8074a0bceafa5497a32a140d0289b7477922..bb33436aa9526bc219b7d6560a3fdc2ead6902f8 100644 (file)
--- 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;
        }