aboutsummaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-05-10 05:05:45 +0000
committerErik Andersen <andersen@codepoet.org>2000-05-10 05:05:45 +0000
commit59b9e870243c56a9c5ec045a925e4e9b3f1f6c3c (patch)
tree8db9c40b68387c1017007f5265e45c2a66ccfb0d /utility.c
parentac130e1dca289c431c43b6efee4b3d9f2b367c87 (diff)
downloadbusybox-59b9e870243c56a9c5ec045a925e4e9b3f1f6c3c.tar.gz
* 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
Diffstat (limited to 'utility.c')
-rw-r--r--utility.c20
1 files changed, 9 insertions, 11 deletions
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;