diff options
author | Jim Meyering <jim@meyering.net> | 2001-01-10 09:43:36 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2001-01-10 09:43:36 +0000 |
commit | 2a5fb11132e09058344ba9a3a58a74230e2cf373 (patch) | |
tree | e0ebf833c818968320eaef13484552a6da31b4e5 | |
parent | a49513bedda382cff5801b8e4247a2aeab5dcc13 (diff) | |
download | coreutils-2a5fb11132e09058344ba9a3a58a74230e2cf373.tar.xz |
(copy_internal): Don't allow cp (or mv, when working
across a partition boundary) to overwrite a non-directory with a directory.
-rw-r--r-- | src/copy.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/copy.c b/src/copy.c index 734271b4f..c7a5b72fa 100644 --- a/src/copy.c +++ b/src/copy.c @@ -628,6 +628,14 @@ copy_internal (const char *src_path, const char *dst_path, return 1; } + if (S_ISDIR (src_type) && !S_ISDIR (dst_sb.st_mode)) + { + error (0, 0, + _("cannot overwrite non-directory %s with directory %s"), + quote_n (0, dst_path), quote_n (1, src_path)); + return 1; + } + if (!S_ISDIR (src_type)) { if (S_ISDIR (dst_sb.st_mode)) |