From 967510df361e0af44d7ca492ae2374674a535023 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 22 Feb 2018 12:03:37 +0000 Subject: shred: fix up for WIN32 and enable by default Use the new low-level support for /dev/zero and /dev/urandom to allow shred to work in busybox-w32. The only change required is to close the file before unlinking it, as Microsoft Windows won't delete an open file. --- configs/mingw32_defconfig | 2 +- configs/mingw64_defconfig | 2 +- coreutils/shred.c | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index 5a17fb164..7c56866a2 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig @@ -283,7 +283,7 @@ CONFIG_PWD=y CONFIG_RM=y CONFIG_RMDIR=y CONFIG_SEQ=y -# CONFIG_SHRED is not set +CONFIG_SHRED=y CONFIG_SHUF=y CONFIG_SLEEP=y CONFIG_FEATURE_FANCY_SLEEP=y diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index 7460e9860..3261d17b8 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig @@ -283,7 +283,7 @@ CONFIG_PWD=y CONFIG_RM=y CONFIG_RMDIR=y CONFIG_SEQ=y -# CONFIG_SHRED is not set +CONFIG_SHRED=y CONFIG_SHUF=y CONFIG_SLEEP=y CONFIG_FEATURE_FANCY_SLEEP=y diff --git a/coreutils/shred.c b/coreutils/shred.c index 3ceb58d19..1b65a359e 100644 --- a/coreutils/shred.c +++ b/coreutils/shred.c @@ -96,8 +96,14 @@ int shred_main(int argc UNUSED_PARAM, char **argv) } if (opt & OPT_u) { ftruncate(fd, 0); +#if ENABLE_PLATFORM_MINGW32 + xclose(fd); +#endif xunlink(fname); } +#if ENABLE_PLATFORM_MINGW32 + else +#endif xclose(fd); } } -- cgit v1.2.3-55-g6feb