summaryrefslogtreecommitdiff
path: root/src/copy.c
AgeCommit message (Collapse)Author
2006-10-18* src/copy.c (copy_internal): Remove redundant and confusing localPaul Eggert
variable src_type.
2006-10-18* src/copy.c (copy_internal): Don't pass mkdir a mode greater thanPaul Eggert
7777. This matches historical 'cp' behavior and avoids some (though not all) implementation-defined behavior of mkdir. * src/cp.c (make_dir_parents_private): Likewise. * src/copy.c (copy_internal): Don't pass 'open' a mode greater than 777. This is required by POSIX. It doesn't make any difference in actual behavior on any host that I know of.
2006-10-14* NEWS: cp -r --backup dir1 dir2, would rename an existing dir1/dir2Jim Meyering
to dir1/dir2~. * src/copy.c (copy_internal): Although we do create a backup of each destination directory when in move mode, don't do that when copying. Reported by Peter Breitenlohner, in <http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/8616>. * tests/cp/backup-dir: New file. Test for the above.
2006-09-24* NEWS: Mention these fixes.Jim Meyering
* src/copy.c (copy_reg): With --verbose (-v), print "removed `file_name'" just after unlinking a file. (copy_internal): Likewise, in three more places. Marc Lehman reported that "touch x; ln x y; mv -v x y" was silent.
2006-09-20* NEWS: Document fix for cp -i and mv -i.Paul Eggert
* src/copy.c (copy_internal): With -i, prompt even if the source is a directory and the destination is not. This is required by POSIX and gives the user a chance to bail out before failing. * tests/cp/Makefile.am (TESTS): Add cp-i. * tests/cp/cp-i: New file. * tests/mv/Makefile.am (TESTS): Add i-5. * tests/mv/i-5: New file.
2006-09-03Don't include dirname.h, since system.h does it now.Paul Eggert
2006-08-28* src/copy.c (copy_internal): Don't test whether macros likePaul Eggert
S_ISLNK are defined, since they're always defined now. * src/cp.c (main): Likewise. * src/ln.c (main): Likewise. * src/ls.c (get_link_name, make_link_name): Likewise. * src/mkfifo.c (usage): Likewise. * src/who.c (S_IWGRP): Likewise.
2006-08-27* src/copy.c (copy_internal): Don't make a backup if the lastJim Meyering
component of the source name is "." or "..". Reported by Andreas Schwab in https://savannah.gnu.org/bugs/?17540. * tests/cp/src-base-dot: New file. Test for the above fix. * tests/cp/Makefile.am (TESTS): Add src-base-dot.
2006-08-27Two of those comments apply only when "moving" (not when copying).Jim Meyering
Correct them.
2006-08-27* src/copy.c (copy_internal): Add comments.Jim Meyering
2006-08-26Fix "mv --verbose --backup" so its output includes theJim Meyering
" (backup: foo.~1~)" suffix also when backing up a directory. * NEWS: Report this bug fix. * src/copy.c (emit_verbose): New function, factored out of... (copy_internal): ...here. Use the new function. * tests/mv/backup-dir: Test for the above fix.
2006-08-19* NEWS: Fix cp --sparse so that it preserves tail-end sparseness, evenJim Meyering
when the file's apparent size is not a multiple of its block size. * src/copy.c (copy_reg): Don't write a NUL before calling ftruncate. For some file sizes, writing that single byte would unnecessarily waste a few file blocks. That write may have been necessary in the early days of Linux, but now, removing it should be safe. Based on a patch by Alan Curry: <http://bugs.debian.org/370792> * tests/cp/sparse: New test for the above. * tests/cp/Makefile.am (TESTS): Add sparse. * tests/sparse-file: New file, essence factored out of... * tests/du/8gb: ... here. Use the new script.
2006-08-17* src/copy.c (copy_internal, same_file_ok): Adjust comments notJim Meyering
to mention the now-removed cp_options.xstat member.
2006-07-29(set_author): Preserve the st_author field via thePaul Eggert
file descriptor dest_desc.
2006-07-26* src/copy.c (set_author) [HAVE_STRUCT_STAT_ST_AUTHOR]:Jim Meyering
Correctly access SRC_SB's element ST_AUTHOR.
2006-07-05* src/copy.c (copy_internal): Don't work around old NFS clients likeJim Meyering
SunOS-4.1.4 and Irix 5.3 that set errno to values like EIO and ENOTEMPTY upon failed rename. Otherwise, we risk misinterpreting a banal failure as a recursive move-into-self failure. Reported by Florent Bayle in <http://bugs.debian.org/376749>.
2006-06-03Make `cp --link --no-dereference' work also on systems where theJim Meyering
link system call cannot create a hard link to a symbolic link. (copy_internal) [LINK_FOLLOWS_SYMLINKS]: Don't use the link syscall on a symlink when it would do the wrong thing. Based on the patch by Aurelien Jarno: <http://bugs.debian.org/329451>
2006-05-11mv -T DIR EMPTY_DIR no longer failsJim Meyering
(copy_internal): Don't manually prohibit a move where the destination is an existing directory. Sometimes doing that is valid. Let the rename system call enforce the rules. That is allowed only when the source is a directory and the destination directory (to be replaced) is empty. Reported by Eric Blake.
2006-05-11(copy_internal): Don't explicitly unlink the destinationJim Meyering
when moving a symlink into the place of an existing non-directory. Reported by Joshua Hudson.
2006-03-12(set_author): Rename function, from preserve_author.Jim Meyering
2006-02-04(copy_internal): cp -RL no longer fails when encounteringJim Meyering
the same directory more than once in the hierarchy beneath a single command-line argument. That is legitimate, e.g. when there are two or more symbolic links, each pointing to some directory that would not otherwise be copied. Reported by Christophe LYON.
2006-01-02(set_owner): Correct a comment.Jim Meyering
2006-01-02Include lchmod.h.Paul Eggert
(copy_internal): Use lchmod rather than chmod.
2005-12-17(get_dest_mode): Remove; it is obsolete after removing umask_kill.Jim Meyering
(copy_reg, copy_internal): Use copy_acl and set_acl instead of fchown/chown. Fix the logic for POSIX ACLs. (chown_succeded): Remove; we now always copy acls and preserve S_ISUID, S_ISGID, and S_ISVTX when needed, no matter if we did a chown before or not.
2005-12-04(fchown) [!HAVE_FCHOWN]: Define fchown(...) to -1.Jim Meyering
(set_owner, preserve_author): New functions, factored out of copy_reg. (copy_reg): Use them. (copy_internal): Use them here, too. From Andreas Gruenbacher.
2005-11-24Improve performance a bit by optimizing awayPaul Eggert
unnecessary system calls and going to a block size of at least 8192 (on normal hosts, anyway). This improved performance 5% on my Debian stable host (2.4.27 kernel, x86, copying from root ext3 file system to itself). Include "buffer-lcm.h". (copy_reg): Omit last argument. All callers changed. Use xmalloc to allocate rather than trusting alloca (which is unwise with large block sizes). Declare locals more locally, if possible. Use uintptr_t words instead of int words, for a bit more speed when looking for null blocks on 64-bit hosts. Optimize away reads of zero bytes on regular files. In the typical case, insist on 8 KiB buffers, at least. Avoid unnecessary extra call to fstat when checking for sparse files. Avoid now-unnecessary cast to off_t, and "0L". Avoid unnecessary test of *new_dst when checking for same owner and group.
2005-09-25(HAVE_FCHMOD, HAVE_FCHOWN): Define to 0 if not defined.Paul Eggert
(copy_reg): New args CHOWN_SUCCEDED and DST_SB. All callers changed. Add a "goto close_src_and_dst_desc;" that was missing in the previous patch. (copy_reg) [HAVE_FCHOWN]: Prefer fchown to chown. (copy_reg) [HAVE_FCHMOD]: Prefer fchmod to chmod. (copy_internal): Don't invoke chown if fchown worked, and likewise for chmod and fchmod.
2005-09-23(copy_reg): Preserve time stamps ifPaul Eggert
x->preserve_timestamps is set, using futimens so that we needn't resolve the path again. (copy_internal): Don't preserve time stamps if copy_reg did it already.
2005-09-16Include stat-time.h, and use its functions instead of the obsoletePaul Eggert
TIMESPEC_NS macro.
2005-07-11(copy_reg): Always copy in binary mode.Paul Eggert
2005-07-03Include fcntl--.h, not unistd-safer.h.Paul Eggert
(copy_reg): Don't call fd_safer; no longer needed now that we include fcntl--.h.
2005-06-02Don't use "path" or "filename".Paul Eggert
2005-05-31(chown_privileges, chown_failure_ok): Mark as `extern'.Jim Meyering
This is a crutch so that `make distcheck's sc_tight_scope rule knows that they really are deliberately declared that way.
2005-05-31Port to Solaris 10's rules for whether programs can chown files.Paul Eggert
[HAVE_PRIV_H]: Include <priv.h>. (DO_CHOWN): Remove. Replaced by chown_failure_ok. All callers changed. (copy_internal): If chown failed, don't worry about what happened to the mode bits; they can't have changed. (chown_privileges, chown_failure_ok): New functions.
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-10(abandon_move): Remove erroneous UNWRITABLE check.Jim Meyering
This makes `mv -i --reply=no f1 f2' work as expected (in not performing the move operation). But note that specifying `-i' after `--reply=no' does *not* work. Tiny patch from Vlada Macek.
2005-04-11Include unistd-safer.h.Paul Eggert
(copy_reg): Use fd_safer.
2005-03-28(copy_reg): Use NULL, not `0'.Jim Meyering
2005-03-15(copy_reg): Copy regular files in binary mode.Jim Meyering
2005-03-11Prompt once again for `mv -i A B' when A and B are hard linksJim Meyering
to the same file. This fixes a bug introduced by my 2003-04-04 (coreutils-5.0.1) change. (abandon_move): New function, factored out of copy_internal, now that this code is being used from two places. (copy_internal): Perform the same interactive-related test for whether it's alright to proceed and (usually) overwrite the destination file.
2005-03-01(copy_internal): Change test of source type from !S_ISREG to S_ISLNK.Jim Meyering
Reported by Paul Eggert in http://lists.gnu.org/archive/html/bug-coreutils/2004-10/msg00050.html.
2005-02-09 * src/copy.c (valid_options): Add an assertion thatJim Meyering
not both hard_link and symbolic_link are set.
2004-09-22(copy): Declare as `extern'.Jim Meyering
2004-09-13Adjust to backup enum rename.Paul Eggert
2004-08-11(copy_internal): When preserving links, unlinkPaul Eggert
a destination with link count greater than one. This is so that commands like "cp -a" don't get confused when copying into a destination that already contains many hard links.
2004-07-30(copy_internal, is_ancestor, copy_dir, copy_reg,Paul Eggert
same_file_ok, seen_file, copy_internal, valid_options, copy): Use bool when appropriate.
2004-07-27(copy_internal): find_backup_file_name no longerPaul Eggert
returns NULL, so don't bother to check for this.
2004-07-04(copy_internal): Add a FIXME comment.Jim Meyering
2004-07-04(copy_dir): Assume path_concat returns non-NULL.Jim Meyering