From 681755bcf5506109375e6fb9fc777461a704cf36 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sun, 20 Nov 2011 16:46:31 +0800 Subject: Added missing stat() tweaks for mingw port --- coreutils/cp.c | 5 +++++ coreutils/libcoreutils/cp_mv_stat.c | 5 +++++ libbb/copy_file.c | 3 +++ libbb/recursive_action.c | 5 +++++ 4 files changed, 18 insertions(+) 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) last = argv[argc - 1]; /* If there are only two arguments and... */ if (argc == 2) { +#if ENABLE_PLATFORM_MINGW32 + /* stat can't be aliased, and MinGW uses lstat anyway */ + s_flags = cp_mv_stat2(*argv, &source_stat, lstat); +#else s_flags = cp_mv_stat2(*argv, &source_stat, (flags & FILEUTILS_DEREFERENCE) ? stat : lstat); +#endif if (s_flags < 0) return EXIT_FAILURE; 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) int FAST_FUNC cp_mv_stat(const char *fn, struct stat *fn_stat) { +#if ENABLE_PLATFORM_MINGW32 + /* stat can't be aliased, and MinGW uses lstat anyway */ + return cp_mv_stat2(fn, fn_stat, lstat); +#else return cp_mv_stat2(fn, fn_stat, stat); +#endif } 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) return -1; } } else { +#if !ENABLE_PLATFORM_MINGW32 + /* MinGW does not have inode, and does not use device */ if (source_stat.st_dev == dest_stat.st_dev && source_stat.st_ino == dest_stat.st_ino ) { bb_error_msg("'%s' and '%s' are the same file", source, dest); return -1; } +#endif dest_exists = 1; } 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, if (depth == 0) follow = ACTION_FOLLOWLINKS | ACTION_FOLLOWLINKS_L0; follow &= flags; +#if ENABLE_PLATFORM_MINGW32 + /* stat can't be aliased, and MinGW uses lstat anyway */ + status = lstat(fileName, &statbuf); +#else status = (follow ? stat : lstat)(fileName, &statbuf); +#endif if (status < 0) { #ifdef DEBUG_RECURS_ACTION bb_error_msg("status=%d flags=%x", status, flags); -- cgit v1.2.3-55-g6feb