aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZheng, Lei <zhenglei@pmail.ntu.edu.sg>2011-11-20 16:46:31 +0800
committerZheng, Lei <zhenglei@pmail.ntu.edu.sg>2011-11-20 16:46:31 +0800
commit681755bcf5506109375e6fb9fc777461a704cf36 (patch)
tree77c0c3c05448cde4d64c0f743d252c7db3ccc9da
parent846ac8422390ed9aa1f572a6089f2a7fc41f4aed (diff)
downloadbusybox-w32-681755bcf5506109375e6fb9fc777461a704cf36.tar.gz
busybox-w32-681755bcf5506109375e6fb9fc777461a704cf36.tar.bz2
busybox-w32-681755bcf5506109375e6fb9fc777461a704cf36.zip
Added missing stat() tweaks for mingw port
-rw-r--r--coreutils/cp.c5
-rw-r--r--coreutils/libcoreutils/cp_mv_stat.c5
-rw-r--r--libbb/copy_file.c3
-rw-r--r--libbb/recursive_action.c5
4 files changed, 18 insertions, 0 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c
index ab17b39a6..bbdb10e95 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -131,8 +131,13 @@ int cp_main(int argc, char **argv)
131 last = argv[argc - 1]; 131 last = argv[argc - 1];
132 /* If there are only two arguments and... */ 132 /* If there are only two arguments and... */
133 if (argc == 2) { 133 if (argc == 2) {
134#if ENABLE_PLATFORM_MINGW32
135 /* stat can't be aliased, and MinGW uses lstat anyway */
136 s_flags = cp_mv_stat2(*argv, &source_stat, lstat);
137#else
134 s_flags = cp_mv_stat2(*argv, &source_stat, 138 s_flags = cp_mv_stat2(*argv, &source_stat,
135 (flags & FILEUTILS_DEREFERENCE) ? stat : lstat); 139 (flags & FILEUTILS_DEREFERENCE) ? stat : lstat);
140#endif
136 if (s_flags < 0) 141 if (s_flags < 0)
137 return EXIT_FAILURE; 142 return EXIT_FAILURE;
138 d_flags = cp_mv_stat(last, &dest_stat); 143 d_flags = cp_mv_stat(last, &dest_stat);
diff --git a/coreutils/libcoreutils/cp_mv_stat.c b/coreutils/libcoreutils/cp_mv_stat.c
index 5ba07ecc3..1af2ebb71 100644
--- a/coreutils/libcoreutils/cp_mv_stat.c
+++ b/coreutils/libcoreutils/cp_mv_stat.c
@@ -46,5 +46,10 @@ int FAST_FUNC cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf)
46 46
47int FAST_FUNC cp_mv_stat(const char *fn, struct stat *fn_stat) 47int FAST_FUNC cp_mv_stat(const char *fn, struct stat *fn_stat)
48{ 48{
49#if ENABLE_PLATFORM_MINGW32
50 /* stat can't be aliased, and MinGW uses lstat anyway */
51 return cp_mv_stat2(fn, fn_stat, lstat);
52#else
49 return cp_mv_stat2(fn, fn_stat, stat); 53 return cp_mv_stat2(fn, fn_stat, stat);
54#endif
50} 55}
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index 2134ee046..d9bbb6ba3 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -105,12 +105,15 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags)
105 return -1; 105 return -1;
106 } 106 }
107 } else { 107 } else {
108#if !ENABLE_PLATFORM_MINGW32
109 /* MinGW does not have inode, and does not use device */
108 if (source_stat.st_dev == dest_stat.st_dev 110 if (source_stat.st_dev == dest_stat.st_dev
109 && source_stat.st_ino == dest_stat.st_ino 111 && source_stat.st_ino == dest_stat.st_ino
110 ) { 112 ) {
111 bb_error_msg("'%s' and '%s' are the same file", source, dest); 113 bb_error_msg("'%s' and '%s' are the same file", source, dest);
112 return -1; 114 return -1;
113 } 115 }
116#endif
114 dest_exists = 1; 117 dest_exists = 1;
115 } 118 }
116 119
diff --git a/libbb/recursive_action.c b/libbb/recursive_action.c
index b5cf7c0ab..560c93cad 100644
--- a/libbb/recursive_action.c
+++ b/libbb/recursive_action.c
@@ -73,7 +73,12 @@ int FAST_FUNC recursive_action(const char *fileName,
73 if (depth == 0) 73 if (depth == 0)
74 follow = ACTION_FOLLOWLINKS | ACTION_FOLLOWLINKS_L0; 74 follow = ACTION_FOLLOWLINKS | ACTION_FOLLOWLINKS_L0;
75 follow &= flags; 75 follow &= flags;
76#if ENABLE_PLATFORM_MINGW32
77 /* stat can't be aliased, and MinGW uses lstat anyway */
78 status = lstat(fileName, &statbuf);
79#else
76 status = (follow ? stat : lstat)(fileName, &statbuf); 80 status = (follow ? stat : lstat)(fileName, &statbuf);
81#endif
77 if (status < 0) { 82 if (status < 0) {
78#ifdef DEBUG_RECURS_ACTION 83#ifdef DEBUG_RECURS_ACTION
79 bb_error_msg("status=%d flags=%x", status, flags); 84 bb_error_msg("status=%d flags=%x", status, flags);