summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaLyong Cho <walyong.cho@samsung.com>2016-11-15 17:22:07 +0900
committerWaLyong Cho <walyong.cho@samsung.com>2016-11-15 17:26:24 +0900
commit7c2a7c86a22dc42c61163fd4e50c1cc5d7f77b13 (patch)
tree366db0c64441cad2633f838c0dda207a52758aed
parent920f4d6b249c198863b1935b189ccbfae517228d (diff)
downloadlibsystem-7c2a7c86a22dc42c61163fd4e50c1cc5d7f77b13.tar.gz
libsystem-7c2a7c86a22dc42c61163fd4e50c1cc5d7f77b13.tar.bz2
libsystem-7c2a7c86a22dc42c61163fd4e50c1cc5d7f77b13.zip
libsystem: remove origin do_copy and rename symbol do_cp() family to do_copy()
Change-Id: If1b60742e05591124e4de145e9a81397ef0f68df Signed-off-by: WaLyong Cho <walyong.cho@samsung.com> Signed-off-by: WaLyong Cho <walyong.cho@samsung.com>
-rw-r--r--src/libsystem/libsystem.c35
-rw-r--r--src/libsystem/libsystem.h22
-rw-r--r--src/test/test-cp.c6
3 files changed, 16 insertions, 47 deletions
diff --git a/src/libsystem/libsystem.c b/src/libsystem/libsystem.c
index cb74b34..2a8aced 100644
--- a/src/libsystem/libsystem.c
+++ b/src/libsystem/libsystem.c
@@ -407,24 +407,7 @@ bool is_number(const char *s, int l) {
return true;
}
-int do_copy(const char *src, const char *dst, const char *option, int64_t timeout_msec) {
- /* TODO
- * change direct execution of cp to c api
- */
- char *argv[] = {"/bin/cp", NULL, NULL, NULL, NULL};
-
- assert(src);
- assert(dst);
- assert(option);
-
- argv[1] = (char *)src;
- argv[2] = (char *)dst;
- argv[3] = (char *)option;
-
- return do_fork_exec(argv, NULL, timeout_msec);
-}
-
-static int do_cp_internal(const char *src, const char *dst, mode_t mode, bool force) {
+static int do_copy_internal(const char *src, const char *dst, mode_t mode, bool force) {
_cleanup_close_ int rfd = -1, wfd = -1;
char buf[1024];
ssize_t red;
@@ -459,36 +442,36 @@ static int do_cp_internal(const char *src, const char *dst, mode_t mode, bool fo
return 0;
}
-int do_cp_mode(const char *src, const char *dst, mode_t mode) {
+int do_copy_mode(const char *src, const char *dst, mode_t mode) {
assert(src);
assert(dst);
- return do_cp_internal(src, dst, mode, false);
+ return do_copy_internal(src, dst, mode, false);
}
-int do_cp_mode_force(const char *src, const char *dst, mode_t mode) {
+int do_copy_mode_force(const char *src, const char *dst, mode_t mode) {
assert(src);
assert(dst);
- return do_cp_internal(src, dst, mode, true);
+ return do_copy_internal(src, dst, mode, true);
}
-int do_cp(const char *src, const char *dst) {
+int do_copy(const char *src, const char *dst) {
assert(src);
assert(dst);
- return do_cp_internal(src, dst, 0644, false);
+ return do_copy_internal(src, dst, 0644, false);
}
-int do_cp_force(const char *src, const char *dst) {
+int do_copy_force(const char *src, const char *dst) {
assert(src);
assert(dst);
- return do_cp_internal(src, dst, 0644, true);
+ return do_copy_internal(src, dst, 0644, true);
}
int do_mkdir(const char *path, mode_t mode) {
diff --git a/src/libsystem/libsystem.h b/src/libsystem/libsystem.h
index a6ed0db..5f6df97 100644
--- a/src/libsystem/libsystem.h
+++ b/src/libsystem/libsystem.h
@@ -260,20 +260,6 @@ char *path_kill_slashes(char *path);
bool is_number(const char *s, int l);
/**
- * @brief Run cp with given src, dst with option. Internally, directly
- * calls /bin/cp with given arguments.
- * @todo change direct calls of /bin/cp to c api.
- *
- * @param src source
- * @param dst destination
- * @param option cp option
- * @param timeout_msec timeout milliseconds
- *
- * @return return exit code of /bin/cp or negative errno.
- */
-int do_copy(const char *src, const char *dst, const char *option, int64_t timeout_msec);
-
-/**
* @brief copy a file with mode, if destination file exists, return
* error.
*
@@ -284,7 +270,7 @@ int do_copy(const char *src, const char *dst, const char *option, int64_t timeou
* @return 0 on success, -errno on failure. -EALREADY if destination
* file exist.
*/
-int do_cp_mode(const char *src, const char *dst, mode_t mode);
+int do_copy_mode(const char *src, const char *dst, mode_t mode);
/**
* @brief copy a file with mode, if destination file exists, the file
@@ -296,7 +282,7 @@ int do_cp_mode(const char *src, const char *dst, mode_t mode);
*
* @return 0 on success, -errno on failure.
*/
-int do_cp_mode_force(const char *src, const char *dst, mode_t mode);
+int do_copy_mode_force(const char *src, const char *dst, mode_t mode);
/**
* @brief copy a file, destination file mode is 0644, if destination
@@ -308,7 +294,7 @@ int do_cp_mode_force(const char *src, const char *dst, mode_t mode);
* @return 0 on success, -errno on failure. -EALREADY if destination
* file exist.
*/
-int do_cp(const char *src, const char *dst);
+int do_copy(const char *src, const char *dst);
/**
* @brief copy a file, destination file mode is 0644, if destination
@@ -319,7 +305,7 @@ int do_cp(const char *src, const char *dst);
*
* @return 0 on success, -errno on failure.
*/
-int do_cp_force(const char *src, const char *dst);
+int do_copy_force(const char *src, const char *dst);
/**
* @brief Make a directory. If parent directories are also absent,
diff --git a/src/test/test-cp.c b/src/test/test-cp.c
index 532dee7..81253bb 100644
--- a/src/test/test-cp.c
+++ b/src/test/test-cp.c
@@ -113,14 +113,14 @@ static void test_overwite(void) {
assert(touch(TEST_SRC_FILE) == 0);
assert(touch(TEST_DST_FILE) == 0);
- assert(do_cp(TEST_SRC_FILE, TEST_DST_FILE) == -EALREADY);
- assert(do_cp_force(TEST_SRC_FILE, TEST_DST_FILE) == 0);
+ assert(do_copy(TEST_SRC_FILE, TEST_DST_FILE) == -EALREADY);
+ assert(do_copy_force(TEST_SRC_FILE, TEST_DST_FILE) == 0);
compare_file();
}
static void test_n_byte_cp_force(unsigned int n) {
assert(write_src_file(n) == 0);
- assert(do_cp_force(TEST_SRC_FILE, TEST_DST_FILE) == 0);
+ assert(do_copy_force(TEST_SRC_FILE, TEST_DST_FILE) == 0);
compare_file();
}