summaryrefslogtreecommitdiff
path: root/src/copy.c
AgeCommit message (Collapse)Author
2007-02-22Adjust preceding change not to perform an unaligned access.Jim Meyering
* src/copy.c (copy_reg): Undo previous change. Instead, make it clearer that we're using a single-byte sentinel, and [lint]: Initialize uintptr_t-1 bytes after the sentinel. Reported by Andreas Schwab.
2007-02-22Placate valgrind, wrt ./cp --sparse=alwaysJim Meyering
* src/copy.c (copy_reg): Place the sentinel by setting a full word's worth of bits, not just a single byte's worth. This avoids a harmless (but distracting) case of memory being used-uninitialized.
2007-02-21* src/copy.c (cached_umask): Cast -1 to mode_t to avoid a warningPaul Eggert
about out-of-range initializer with Sun C 5.8.
2007-02-03* NEWS: Document fix for cp --preserve=mode.Paul Eggert
* src/copy.c (copy_internal): Omit the group- or other-writeable permissions when creating a directory, to avoid a race condition if the special mode bits aren't right just after the directory is created. * src/cp.c (make_dir_parents_private): Likewise. * tests/cp/parent-perm-race: Test for the "cp --preserve=mode" race fix in copy.c.
2007-01-03* src/copy.c (copy_internal): Use mkfifo as a fallback if mknod fails.Bruno Haible
Needed on MacOS X. Signed-off-by: Jim Meyering <jim@meyering.net>
2006-12-30* src/copy.c (copy_reg): Rewrite a comment that was renderedJim Meyering
inaccurate by the 2006-10-18 change.
2006-12-07cp -p now clears special bits if it fails to preserve owner or groupPaul Eggert
* NEWS: Document the cp -p fix for special bits. * src/copy.c (set_owner): Now returns a three-way result, so that the caller can clear the special bits. All callers changed. (copy_reg): Don't set the special bits if chown failed. (copy_internal): Likewise. * tests/cp/special-bits: Test this fix. Signed-off-by: Jim Meyering <jim@meyering.net>
2006-12-06* NEWS: Document the cp --preserve=ownership fix.Paul Eggert
* m4/jm-macros.m4 (coreutils_MACROS): Check for fchmod. * src/copy.c (fchmod_or_lchmod): New function. (copy_reg): New arg OMITTED_PERMISSIONS. All uses changed. Omit confusing and unused ", dst_mode" arg to 'open' without O_CREAT. When creating a file, use O_EXCL, so we're more likely to detect funny business by other processes. At the end, if permissions were omitted, chmod them back in. (copy_internal): If the ownership might change, omit some permissions at first, then restore them after chowning the file. * src/cp.c (make_dir_parents_private): Likewise. * src/copy.c (cached_umask): New function. * src/copy.h (cached_umask): New decl.
2006-10-21* src/copy.c (copy_internal): Add a comment saying why we preferJim Meyering
mknod over mkfifo.
2006-10-19* src/copy.c (copy_reg): Rewrite slightly to avoid duplicte codePaul Eggert
when opening dst_name. (copy_reg, copy_internal): Use (SYSCALL != 0) rather than plain (SYSCALL) to test for failure in a system call.
2006-10-18* src/copy.c (copy_internal): Use mknod rather than mkfifo to copyPaul Eggert
a fifo. This preserves the special mode bits on Solaris 10, which is compatible with what Solaris 10 cp -R does.
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