aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-11-29 10:12:11 +0000
committerRon Yorston <rmy@pobox.com>2012-11-29 10:12:11 +0000
commit45c0070a259132f13424ba2ff42ea523c4fd318a (patch)
treedc1b443f039a47eb27c80690346ccc7dce10dcd1 /coreutils
parent0528a8658d7237f4bac0d853db51028036f6a650 (diff)
downloadbusybox-w32-45c0070a259132f13424ba2ff42ea523c4fd318a.tar.gz
busybox-w32-45c0070a259132f13424ba2ff42ea523c4fd318a.tar.bz2
busybox-w32-45c0070a259132f13424ba2ff42ea523c4fd318a.zip
Ensure mingw_stat is called when necessary
In some cases a funtion pointer to the stat function is used. The preprocessor can't replace these with the mingw_stat, so make alternative arrangements in those cases.
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/cp.c4
-rw-r--r--coreutils/libcoreutils/cp_mv_stat.c4
-rw-r--r--coreutils/stat.c4
3 files changed, 11 insertions, 1 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c
index de2e512be..fee82c26b 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -149,7 +149,11 @@ int cp_main(int argc, char **argv)
149 /* If there are only two arguments and... */ 149 /* If there are only two arguments and... */
150 if (argc == 2) { 150 if (argc == 2) {
151 s_flags = cp_mv_stat2(*argv, &source_stat, 151 s_flags = cp_mv_stat2(*argv, &source_stat,
152#if !ENABLE_PLATFORM_MINGW32
152 (flags & FILEUTILS_DEREFERENCE) ? stat : lstat); 153 (flags & FILEUTILS_DEREFERENCE) ? stat : lstat);
154#else
155 (flags & FILEUTILS_DEREFERENCE) ? mingw_stat : lstat);
156#endif
153 if (s_flags < 0) 157 if (s_flags < 0)
154 return EXIT_FAILURE; 158 return EXIT_FAILURE;
155 d_flags = cp_mv_stat(last, &dest_stat); 159 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..6e9fd09f0 100644
--- a/coreutils/libcoreutils/cp_mv_stat.c
+++ b/coreutils/libcoreutils/cp_mv_stat.c
@@ -46,5 +46,9 @@ 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
49 return cp_mv_stat2(fn, fn_stat, stat); 50 return cp_mv_stat2(fn, fn_stat, stat);
51#else
52 return cp_mv_stat2(fn, fn_stat, mingw_stat);
53#endif
50} 54}
diff --git a/coreutils/stat.c b/coreutils/stat.c
index e6b0e95de..259481750 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -564,6 +564,7 @@ static bool do_statfs(const char *filename, const char *format)
564static bool do_stat(const char *filename, const char *format) 564static bool do_stat(const char *filename, const char *format)
565{ 565{
566 struct stat statbuf; 566 struct stat statbuf;
567 int status;
567#if ENABLE_SELINUX 568#if ENABLE_SELINUX
568 security_context_t scontext = NULL; 569 security_context_t scontext = NULL;
569 570
@@ -578,7 +579,8 @@ static bool do_stat(const char *filename, const char *format)
578 } 579 }
579 } 580 }
580#endif 581#endif
581 if ((option_mask32 & OPT_DEREFERENCE ? stat : lstat) (filename, &statbuf) != 0) { 582 status = option_mask32 & OPT_DEREFERENCE ? stat(filename, &statbuf) : lstat(filename, &statbuf);
583 if (status != 0) {
582 bb_perror_msg("can't stat '%s'", filename); 584 bb_perror_msg("can't stat '%s'", filename);
583 return 0; 585 return 0;
584 } 586 }