Upload tizen_2.2 source
authorkh5325.kim <kh5325.kim@samsung.com>
Thu, 11 Jul 2013 13:36:11 +0000 (22:36 +0900)
committerkh5325.kim <kh5325.kim@samsung.com>
Thu, 11 Jul 2013 13:36:11 +0000 (22:36 +0900)
Change-Id: I29a16ec87e3eacb5332b0c54c744670880a4cca1

16 files changed:
package/changelog
package/pkginfo.manifest
package/sdb.install.darwin [deleted file]
package/sdb.install.linux
package/sdb.install.macos-64 [new file with mode: 0755]
package/sdb.install.windows [new file with mode: 0644]
package/sdb.remove.darwin [deleted file]
package/sdb.remove.linux
package/sdb.remove.macos-64 [new file with mode: 0755]
package/sdb.remove.windows
src/command_function.h
src/file_sync_client.c
src/file_sync_functions.c
src/file_sync_functions.h
src/sdb_client.c
src/sdb_client.h

index cc004cc34f9120d5bd4217c4270e29ca93269cc5..f6558420d5a754bc0ceea5759a9c3e23256832b4 100644 (file)
@@ -1,3 +1,18 @@
+* 2.2.14
+- Change PATH_MAX in Windows 256 -> 4096
+== ho.namkoong <ho.namkoong@samsung.com> 2013-07-11
+* 2.2.13
+- echo stdout in install script
+== ho.namkoong <ho.namkoong@samsung.com> 2013-07-11
+* 2.2.12
+- use tsudo instead of gksudo
+== ho.namkoong <ho.namkoong@samsung.com> 2013-07-11
+* 2.2.11
+- Fixed sdbd version checking without rpm query
+== ho.namkoong <ho.namkoong@samsung.com> 2013-07-08
+* 2.2.10
+- Fixed argument append util for da/oprofile command
+== kh5325.kim <kh5325.kim@samsung.com> 2013-07-08
 * 2.2.9
 - Fix pull/push message
 == ho.namkoong <ho.namkoong@samsung.com> 2013-07-04
index d126dee65357a32ef2c09ede360014dfe110febd..9c4ccd47eab039b93c94c0c1edbcc621dea055b3 100644 (file)
@@ -1,4 +1,4 @@
-Version:2.2.9
+Version:2.2.14
 Source:sdb
 Maintainer:Kangho Kim <kh5325.kim@samsung.com>, Yoonki Park<yoonki.park@samsung.com>, Hyunsik Noh<hyunsik.noh@samsung.com>, Gun Kim<gune.kim@samsung.com>, Ho Namkoong<ho.namkoong@samsung.com>, Taeyoung Son<taeyoung2.son@samsung.com>
 
diff --git a/package/sdb.install.darwin b/package/sdb.install.darwin
deleted file mode 100755 (executable)
index 76df931..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash -x
-
-## Set sdb's environment path
-s=`cat ${HOME}/.bashrc | grep -n "## Tizen SDK configuration" | cut -f1 -d":"`
-
-if [ "x${s}" = "x" ] ; then
-    cat >> ${HOME}/.bashrc << END
-## Tizen SDK configuration
-# This is generated by Tizen SDK. Please do not modify by yourself.
-# Set sdb environment path
-export PATH=\$PATH:${INSTALLED_PATH}/tools
-## End Tizen SDK configuration
-END
-fi
-
-source ${HOME}/.bashrc
-
-exit 0
index dcd3c4379e0ffc6b5432bbccc4301eb591499872..8a410efd64d85c5c1e30dcb5c22cf34a7133854f 100755 (executable)
@@ -1,10 +1,15 @@
-#!/bin/bash -x
+#!/bin/bash -ex
 
 ## Set sdb's environment path
-s=`cat ${HOME}/.bashrc | grep -n "## Tizen SDK configuration" | cut -f1 -d":"`
+bashrc=${HOME}/.bashrc
+if [ -f ${bashrc} ]; then
+    s=`cat ${bashrc} | grep -n "## Tizen SDK configuration" | cut -f1 -d":"`
+else
+    s=
+fi
 
-if [ "x${s}" = "x" ] ; then
-    cat >> ${HOME}/.bashrc << END
+if [ "x${s}" = "x" ]; then
+cat >> ${bashrc} << END
 ## Tizen SDK configuration
 # This is generated by Tizen SDK. Please do not modify by yourself.
 # Set sdb environment path
@@ -30,11 +35,18 @@ echo "# Samsung" >> $TMP_FILE
 echo "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"04e8\", ATTRS{idProduct}==\"6864\", MODE=\"0666\", GROUP=\"plugdev\"" >> $TMP_FILE
 echo "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"04e8\", ATTRS{idProduct}==\"6863\", MODE=\"0666\", GROUP=\"plugdev\"" >> $TMP_FILE
 chmod +x $TMP_FILE
-if [ -f /usr/bin/gksudo ]
-    then gksudo mv ${TMP_FILE} /etc/udev/rules.d/
-    else if [ -f /usr/bin/sudo ]
-        then sudo mv ${TMP_FILE} /etc/udev/rules.d/
+
+if [ -z "$TSUDO" ]; then
+    if [ -f /usr/bin/gksudo ]
+        then gksudo mv ${TMP_FILE} /etc/udev/rules.d/
+        else if [ -f /usr/bin/sudo ]
+            then sudo mv ${TMP_FILE} /etc/udev/rules.d/
+        fi
     fi
+    exit 0
+else
+    $TSUDO -m "Enter your password to install sdb." mv ${TMP_FILE} /etc/udev/rules.d/
+    exit 0
 fi
 
 exit 0
diff --git a/package/sdb.install.macos-64 b/package/sdb.install.macos-64
new file mode 100755 (executable)
index 0000000..08a8365
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash -ex
+
+## Set sdb's environment path
+
+bashrc=${HOME}/.bashrc
+if [ -f ${bashrc} ]; then
+    s=`cat ${bashrc} | grep -n "## Tizen SDK configuration" | cut -f1 -d":"`
+else
+    s=
+fi
+
+if [ "x${s}" = "x" ]; then
+cat >> ${bashrc} << END
+## Tizen SDK configuration
+# This is generated by Tizen SDK. Please do not modify by yourself.
+# Set sdb environment path
+export PATH=\$PATH:${INSTALLED_PATH}/tools
+## End Tizen SDK configuration
+END
+fi
+
+source ${HOME}/.bashrc
+
+exit 0
diff --git a/package/sdb.install.windows b/package/sdb.install.windows
new file mode 100644 (file)
index 0000000..02753b7
--- /dev/null
@@ -0,0 +1,5 @@
+@echo off
+
+echo "setting path..."
+setx -m PATH "%PATH%;${INSTALLED_PATH}\tools
+exit 0
diff --git a/package/sdb.remove.darwin b/package/sdb.remove.darwin
deleted file mode 100755 (executable)
index 7d0ea0f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-SDB_PATH=tools/sdb
-${INSTALLED_PATH}/${SDB_PATH} kill-server
-rm -rf ${INSTALLED_PATH}/${SDB_PATH}
-## remove sdb environment path
-s=`cat ${HOME}/.bashrc | grep -n "## Tizen SDK configuration" | cut -f1 -d":"`
-
-if [ "x${s}" = "x" ] ; then
-       exit 1
-fi
-
-if [ ${s} -ge 0 ] ; then
-       e=`cat ${HOME}/.bashrc | grep -n "## End Tizen SDK configuration" | cut -f1 -d":"`
-       if [ $e -ge $s ] ; then
-               cp ${HOME}/.bashrc ${HOME}/.bashrc.tizen
-               sed "${s},${e}d" ${HOME}/.bashrc > ${HOME}/.bashrc.swap
-               mv ${HOME}/.bashrc.swap ${HOME}/.bashrc
-               source ${HOME}/.bashrc
-       fi
-fi
-
-exit 0
index 5ddd1cf683bf71ad952133ae1042f4a900530ad3..96166427c68783fd68671074b46f18e188c74fd3 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash -ex
 SDB_PATH=tools/sdb
 ${INSTALLED_PATH}/${SDB_PATH} kill-server
 rm -rf ${INSTALLED_PATH}/${SDB_PATH}
@@ -20,6 +20,18 @@ if [ ${s} -ge 0 ] ; then
 fi
 
 ## remove udev rule file
-gksudo rm -rf /etc/udev/rules.d/99-samsung-device.rules
+
+if [ -z "$TSUDO" ]; then
+    if [ -f /usr/bin/gksudo ]
+        then gksudo rm -rf /etc/udev/rules.d/99-samsung-device.rules
+        else if [ -f /usr/bin/sudo ]
+            then sudo rm -rf /etc/udev/rules.d/99-samsung-device.rules
+        fi
+    fi
+    exit 0
+else
+    $TSUDO -m "Enter your password to uninstall sdb." rm -rf /etc/udev/rules.d/99-samsung-device.rules
+    exit 0
+fi
 
 exit 0
diff --git a/package/sdb.remove.macos-64 b/package/sdb.remove.macos-64
new file mode 100755 (executable)
index 0000000..7632317
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash -ex
+SDB_PATH=tools/sdb
+${INSTALLED_PATH}/${SDB_PATH} kill-server
+rm -rf ${INSTALLED_PATH}/${SDB_PATH}
+## remove sdb environment path
+s=`cat ${HOME}/.bashrc | grep -n "## Tizen SDK configuration" | cut -f1 -d":"`
+
+if [ "x${s}" = "x" ] ; then
+       exit 1
+fi
+
+if [ ${s} -ge 0 ] ; then
+       e=`cat ${HOME}/.bashrc | grep -n "## End Tizen SDK configuration" | cut -f1 -d":"`
+       if [ $e -ge $s ] ; then
+               cp ${HOME}/.bashrc ${HOME}/.bashrc.tizen
+               sed "${s},${e}d" ${HOME}/.bashrc > ${HOME}/.bashrc.swap
+               mv ${HOME}/.bashrc.swap ${HOME}/.bashrc
+               source ${HOME}/.bashrc
+       fi
+fi
+
+exit 0
index 88ae1bcd4d73add0ba3370772686027045bb922a..1c3c6646c52913a61c53f0aa4081a42fe45f97d1 100644 (file)
@@ -3,8 +3,6 @@
 set execute_path=tools
 %INSTALLED_PATH%\%execute_path%\sdb.exe kill-server
 del %INSTALLED_PATH%\%execute_path%\sdb.exe
-del %INSTALLED_PATH%\%execute_path%\SdbWinApi.dll
-del %INSTALLED_PATH%\%execute_path%\SdbWinUsbApi.dll
 del %INSTALLED_PATH%\%execute_path%\ansicon.exe
 del %INSTALLED_PATH%\%execute_path%\ANSI32.dll
 exit 0
index 92e71aee937e3d41c64099d740c51736163fc8a4..f9c6801f795ebb369cbb62fca31fdcb4a5b808df 100644 (file)
 
 #define  TRACE_TAG  TRACE_SDB
 
+#ifdef OS_WINDOWS
+#define PATH_MAX 4096
+#endif
+
+
 int da(int argc, char ** argv, void** extargv);
 int oprofile(int argc, char ** argv, void** extargv);
 int launch(int argc, char ** argv, void** extargv);
index 3a68b8d23213d058d19db781b8acf229bd1590d3..ffc8f117024efba9fc36cdb9f6db96b05d01862c 100644 (file)
@@ -33,6 +33,8 @@
 #include "file_sync_functions.h"
 #include "utils.h"
 #include "strutils.h"
+#include "fdevent.h"
+#include "sdb.h"
 
 static __inline__ void finalize(int srcfd, int dstfd, FILE_FUNC* srcF, FILE_FUNC* dstF);
 
@@ -48,6 +50,7 @@ static __inline__ void finalize(int srcfd, int dstfd, FILE_FUNC* srcF, FILE_FUNC
 }
 
 static int file_copy(int src_fd, int dst_fd, char* srcp, char* dstp, FILE_FUNC* srcF, FILE_FUNC* dstF, unsigned* total_bytes) {
+    D("file is copied from 'fd:%d' '%s' to 'fd:%d' '%s'\n", src_fd, srcp, dst_fd, dstp);
     void* srcstat;
     if(srcF->_stat(src_fd, srcp, &srcstat, 1) < 0) {
         return -1;
@@ -122,6 +125,7 @@ static void free_copyinfo(void* data) {
 
 int do_sync_copy(char* srcp, char* dstp, FILE_FUNC* srcF, FILE_FUNC* dstF, int is_utf8, void** ext_argv) {
 
+    D("copy %s to the %s\n", srcp, dstp);
     unsigned total_bytes = 0;
     long long start_time = NOW();
 
@@ -142,19 +146,24 @@ int do_sync_copy(char* srcp, char* dstp, FILE_FUNC* srcF, FILE_FUNC* dstF, int i
         return 1;
     }
     int src_dir = srcF->is_dir(srcp, srcstat, 1);
-    int dst_dir = 1;
+    int dst_dir = 0;
 
     if(dstF->_stat(dst_fd, dstp, &dststat, 0) >= 0) {
         dst_dir = dstF->is_dir(dstp, dststat, 0);
     }
+    else {
+        int dst_len = strlen(dstp);
+        if( dstp[dst_len - 1] == '/' || dstp[dst_len - 1] == '\\') {
+            dst_dir = 1;
+        }
+    }
     free(dststat);
     free(srcstat);
     if(src_dir == -1 || dst_dir == -1) {
         finalize(src_fd, dst_fd, srcF, dstF);
         return 1;
     }
-    //copy file
-    else if(src_dir == 0) {
+    if(src_dir == 0) {
         /* if we're copying a local file to a remote directory,
         ** we *really* want to copy to remotedir + "/" + localfilename
         */
index bd2a8eab1fe3958f991199ecb732b38e4951b8e4..baceb3b8b20ed7d70ee266cafd08d03686191367 100644 (file)
@@ -32,7 +32,6 @@
 #include "sdb_client.h"
 #include "file_sync_functions.h"
 #include "linkedlist.h"
-
 #include "strutils.h"
 #include "file_sync_client.h"
 
@@ -68,12 +67,14 @@ static int sync_readmode(int fd, const char *path, unsigned *mode);
 
 //return > 0 fd, = 0 success, < 0 fail.
 int initialize_local(char* path, void** extargv) {
+    D("initialize local file '%s'", path);
     return 0;
 }
 
 //return fd
 int initialize_remote(char* path, void** extargv) {
 
+    D("initialize remote file '%s'", path);
     int fd = sdb_connect("sync:", extargv);
 
     if(fd < 0) {
@@ -85,10 +86,11 @@ int initialize_remote(char* path, void** extargv) {
 }
 
 void finalize_local(int fd) {
-
+    D("finalize local fd '%d'", fd);
 }
 
 void finalize_remote(int fd) {
+    D("finalize remote fd '%d'", fd);
     syncmsg msg;
 
     msg.req.id = ID_QUIT;
@@ -103,6 +105,7 @@ void finalize_remote(int fd) {
 
 //TODO stat should be freed.
 int _stat_local(int fd, char* path, void** _stat, int show_error) {
+    D("stat local file 'fd:%d' '%s'", fd, path);
     struct stat* st = (struct stat*)malloc(sizeof(struct stat));
     if(stat(path, st)) {
         if(show_error) {
@@ -117,6 +120,7 @@ int _stat_local(int fd, char* path, void** _stat, int show_error) {
 
 int _stat_remote(int fd, char* path, void** stat, int show_error) {
 
+    D("stat remote file 'fd:%d' '%s'", fd, path);
     unsigned* mode = (unsigned*)malloc(sizeof(unsigned));
     if(sync_readmode(fd, path, mode)) {
         if(show_error) {
@@ -170,6 +174,7 @@ int is_directory_remote(char* path, void* stat, int show_error) {
 //return fd.
 int readopen_local(int fd, char* srcp, void* srcstat) {
 
+    D("read open local file 'fd:%d' '%s'", fd, srcp);
     struct stat* st = srcstat;
     if(S_ISREG(st->st_mode)) {
         fd = sdb_open(srcp, O_RDONLY);
@@ -186,6 +191,7 @@ int readopen_local(int fd, char* srcp, void* srcstat) {
 }
 
 int readopen_remote(int fd, char* srcp, void* srcstat) {
+    D("read open remote file 'fd:%d' '%s'", fd, srcp);
     syncmsg msg;
     int len;
 
@@ -206,6 +212,7 @@ int readopen_remote(int fd, char* srcp, void* srcstat) {
 }
 
 int readclose_local(int lfd) {
+    D("read close local file 'fd:%d'", lfd);
     if(lfd > 0) {
         sdb_close(lfd);
     }
@@ -213,10 +220,12 @@ int readclose_local(int lfd) {
 }
 
 int readclose_remote(int fd) {
+    D("read close remote file 'fd:%d'", fd);
     return fd;
 }
 
 int writeopen_local(int fd, char* dstp, void* stat) {
+    D("write open local file 'fd:%d' '%s'", fd, dstp);
     sdb_unlink(dstp);
     mkdirs(dstp);
     fd = sdb_creat(dstp, 0644);
@@ -231,6 +240,7 @@ int writeopen_local(int fd, char* dstp, void* stat) {
 
 //return fd.
 int writeopen_remote(int fd, char* dstp, void* stat) {
+    D("write open remote file 'fd:%d' '%s'", fd, dstp);
     syncmsg msg;
     struct stat* st = (struct stat*)stat;
 
@@ -262,6 +272,7 @@ int writeopen_remote(int fd, char* dstp, void* stat) {
 }
 
 int writeclose_local(int fd, char*dstp, void* stat) {
+    D("write close local file 'fd:%d' '%s'", fd, dstp);
     if(fd > 0) {
         sdb_close(fd);
     }
@@ -269,6 +280,7 @@ int writeclose_local(int fd, char*dstp, void* stat) {
 }
 
 int writeclose_remote(int fd, char* dstp, void* stat) {
+    D("write close remote file 'fd:%d' '%s'", fd, dstp);
     struct stat* st = (struct stat*)stat;
     syncmsg msg;
     msg.data.id = ID_DONE;
@@ -314,6 +326,7 @@ int writeclose_remote(int fd, char* dstp, void* stat) {
 //1: write and continue load
 //3: write and stop
 int readfile_local(int lfd, char* srcpath, void* stat, FILE_BUFFER* sbuf) {
+    D("read local file 'fd:%d' '%s'", lfd, srcpath);
     struct stat* st = (struct stat*)stat;
 
     if (S_ISREG(st->st_mode)) {
@@ -363,6 +376,7 @@ int readfile_local(int lfd, char* srcpath, void* stat, FILE_BUFFER* sbuf) {
 }
 
 int readfile_remote(int fd, char* srcpath, void* stat, FILE_BUFFER* buffer) {
+    D("read remote file 'fd:%d' '%s'", fd, srcpath);
     syncmsg msg;
     unsigned id;
 
@@ -416,6 +430,7 @@ int readfile_remote(int fd, char* srcpath, void* stat, FILE_BUFFER* buffer) {
 }
 
 int writefile_local(int fd, char* dstp, FILE_BUFFER* sbuf, unsigned* total_bytes) {
+    D("write local file 'fd:%d' '%s'", fd, dstp);
     char* data = sbuf->data;
     unsigned len = sbuf->size;
 
@@ -429,6 +444,7 @@ int writefile_local(int fd, char* dstp, FILE_BUFFER* sbuf, unsigned* total_bytes
 }
 
 int writefile_remote(int fd, char* dstp, FILE_BUFFER* sbuf, unsigned* total_bytes) {
+    D("write remote file 'fd:%d' '%s'", fd, dstp);
     int size = ltohl(sbuf->size);
 
     if(writex(fd, sbuf, sizeof(unsigned)*2 + size)) {
@@ -441,6 +457,7 @@ int writefile_remote(int fd, char* dstp, FILE_BUFFER* sbuf, unsigned* total_byte
 }
 
 int getdirlist_local(int fd, char* src_dir, char* dst_dir, LIST_NODE** dirlist) {
+    D("get list of local file 'fd:%d' '%s'", fd, src_dir);
     DIR* d;
 
     d = opendir(src_dir);
@@ -479,6 +496,7 @@ int getdirlist_local(int fd, char* src_dir, char* dst_dir, LIST_NODE** dirlist)
 }
 
 int getdirlist_remote(int fd, char* src_dir, char* dst_dir, LIST_NODE** dirlist) {
+    D("get list of remote file 'fd:%d' '%s'", fd, src_dir);
     syncmsg msg;
     int len;
 
index 34be58ed9c230b39ff0848075107ec8ae86add8c..ddba671293562d0c5ddbe944b3db53cea1538fea 100644 (file)
@@ -27,6 +27,8 @@
 #ifndef FILE_SYNC_FUNCTIONS_H_
 #define FILE_SYNC_FUNCTIONS_H_
 
+#define  TRACE_TAG  TRACE_SDB
+
 #include "file_sync_service.h"
 #include "linkedlist.h"
 
index ab54aee2b3d73f3f7534401fb5cd1932a2f8ff70..62dadc303eed9a904dff8247ad9bd636de039f7a 100644 (file)
@@ -89,6 +89,46 @@ static int switch_socket_transport(int fd, void** extra_args)
     return 0;
 }
 
+int sdk_launch_exist(void* extargv) {
+    const char* SDK_LAUNCH_QUERY = "shell:ls /usr/sbin/sdk_launch";
+    D("query the existence of sdk_launch\n");
+    int fd = sdb_connect(SDK_LAUNCH_QUERY, extargv);
+
+    if(fd < 0) {
+        D("fail to query the sdbd version\n");
+        return fd;
+    }
+
+    char query_result[PATH_MAX];
+    char* result_ptr = query_result;
+    int max_len = PATH_MAX;
+    int len;
+
+    while(fd >= 0) {
+        len = sdb_read(fd, result_ptr, max_len);
+        if(len == 0) {
+            break;
+        }
+
+        if(len < 0) {
+            if(errno == EINTR) {
+                continue;
+            }
+            break;
+        }
+        max_len -= len;
+        result_ptr += len;
+        fflush(stdout);
+    }
+
+    const char* expected_result = "/usr/sbin/sdk_launch";
+
+    if(!strncmp(expected_result, query_result, sizeof(expected_result))) {
+        return 1;
+    }
+    return 0;
+}
+
 int sdb_higher_ver(int first, int middle, int last, void* extargv) {
 
     const char* VERSION_QUERY = "shell:rpm -q sdbd";
@@ -101,19 +141,25 @@ int sdb_higher_ver(int first, int middle, int last, void* extargv) {
     }
 
     char ver[PATH_MAX];
+    int max_len = PATH_MAX;
+    char* result_ptr = ver;
     int len;
 
     D("read sdb version\n");
     while(fd >= 0) {
-        len = sdb_read(fd, ver, PATH_MAX);
+        len = sdb_read(fd, result_ptr, max_len);
         if(len == 0) {
             break;
         }
 
         if(len < 0) {
-            if(errno == EINTR) continue;
+            if(errno == EINTR) {
+                continue;
+            }
             break;
         }
+        max_len -= len;
+        result_ptr += len;
         fflush(stdout);
     }
 
index 7f8706c39f632bcd8f984b4739f84095b6f49b48..04d9da2038a925d3b05ce532b971656a8eb1b673 100644 (file)
@@ -21,7 +21,7 @@
 #include "sdb_constants.h"
 
 // debug launch pad is applied after sdbd 2.2.3
-#define SDB_HIGHER_THAN_2_2_3(extargv) sdb_higher_ver(2, 2, 3, extargv)
+#define SDB_HIGHER_THAN_2_2_3(extargv) sdk_launch_exist(extargv)
 
 /* connect to sdb, connect to the named service, and return
 ** a valid fd for interacting with that service upon success
@@ -52,6 +52,14 @@ const char *sdb_error(void);
  */
 int sdb_higher_ver(int first, int middle, int last, void* extargv);
 
+/**
+ * check /usr/sbin/sdk_launch exists in the target.
+ * /usr/sbin/sdk_launch is included higher than sdbd 2.2.4
+ * returns true, if sdbd contains it.
+ * else, returns false.
+ */
+int sdk_launch_exist(void* extargv);
+
 /* read a standard sdb status response (OKAY|FAIL) and
 ** return 0 in the event of OKAY, -1 in the event of FAIL
 ** or protocol error