From 59b9e870243c56a9c5ec045a925e4e9b3f1f6c3c Mon Sep 17 00:00:00 2001 From: Erik Andersen Date: Wed, 10 May 2000 05:05:45 +0000 Subject: * cp -fa now works as expected for symlinks (it didn't before) * zcat works again (wasn't working since option parsing was broken) * more doc updates/more support for BB_FEATURE_SIMPLE_HELP -Erik --- utility.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'utility.c') diff --git a/utility.c b/utility.c index c8442f1ba..5899fe954 100644 --- a/utility.c +++ b/utility.c @@ -234,15 +234,14 @@ int isDirectory(const char *fileName, const int followLinks, struct stat *statBu #if defined (BB_CP_MV) /* - * Copy one file to another, while possibly preserving its modes, times, - * and modes. Returns TRUE if successful, or FALSE on a failure with an - * error message output. (Failure is not indicated if the attributes cannot - * be set.) - * -Erik Andersen + * Copy one file to another, while possibly preserving its modes, times, and + * modes. Returns TRUE if successful, or FALSE on a failure with an error + * message output. (Failure is not indicated if attributes cannot be set.) + * -Erik Andersen */ int copyFile(const char *srcName, const char *destName, - int setModes, int followLinks) + int setModes, int followLinks, int forceFlag) { int rfd; int wfd; @@ -268,7 +267,8 @@ copyFile(const char *srcName, const char *destName, else status = lstat(destName, &dstStatBuf); - if (status < 0) { + if (status < 0 || forceFlag==TRUE) { + unlink(destName); dstStatBuf.st_ino = -1; dstStatBuf.st_dev = -1; } @@ -306,10 +306,8 @@ copyFile(const char *srcName, const char *destName, } #if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) if (setModes == TRUE) { - if (lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid) < 0) { - perror(destName); - return FALSE; - } + /* Try to set owner, but fail silently like GNU cp */ + lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid); } #endif return TRUE; -- cgit v1.2.3