aboutsummaryrefslogtreecommitdiff
path: root/coreutils/mv.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-28 17:49:31 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-28 17:49:31 +0000
commitb9ad75fa602dd72b042b2ea08ce86da50746ab30 (patch)
tree19445163e0f30e8015eeafbcad091309407ab050 /coreutils/mv.c
parenta38ba59cc3e78db0234cf4c224de6749d8ce759d (diff)
downloadbusybox-b9ad75fa602dd72b042b2ea08ce86da50746ab30.tar.gz
copy_file: handle "cp /dev/foo file" (almost) compatibly to coreutils.
(almost because we do not copy mode, which is probably wasn't intended). +61 bytes.
Diffstat (limited to 'coreutils/mv.c')
-rw-r--r--coreutils/mv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/coreutils/mv.c b/coreutils/mv.c
index 5d02196e3..613d4ac46 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -71,7 +71,8 @@ int mv_main(int argc, char **argv)
}
DO_MOVE:
- if (dest_exists && !(flags & OPT_FILEUTILS_FORCE)
+ if (dest_exists
+ && !(flags & OPT_FILEUTILS_FORCE)
&& ((access(dest, W_OK) < 0 && isatty(0))
|| (flags & OPT_FILEUTILS_INTERACTIVE))
) {
@@ -108,6 +109,9 @@ int mv_main(int argc, char **argv)
goto RET_1;
}
}
+ /* FILEUTILS_RECUR also prevents nasties like
+ * "read from device and write contents to dst"
+ * instead of "create same device node" */
copy_flag = FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS;
#if ENABLE_SELINUX
copy_flag |= FILEUTILS_PRESERVE_SECURITY_CONTEXT;