summaryrefslogtreecommitdiff
path: root/src/copy.c
AgeCommit message (Collapse)Author
2004-04-15Include getpagesize.h.Jim Meyering
(copy_reg): Align I/O buffers to page boundaries.
2004-04-12Include "utimecmp.h".Jim Meyering
(copy_internal): Compare time stamps using utimecmp rather than MTIME_CMP.
2004-03-12Sometimes, when source and destination partition are different,Jim Meyering
mv mistakenly fails to preserve a hard link. Reported by IIDA Yosiaki. When moving a set of N hard-linked files between partitions, via two or more command line arguments where the command line argument containing the Nth link contains no other link to that same file, mv would mistakenly copy the file, rather than hard-linking it to the other(s). That happens because when the final link is processed, its link count has been reduced to 1 since the other links have been `copied' to the destination partition and the source links have been removed. (copy_internal): When in move mode, use the source dev/inode pair to look up destination name even when st_nlink == 1.
2004-03-06cp --sparse=always sparse-image-file.img /dev/hda1 couldJim Meyering
produce an invalid copy on the destination device. (copy_reg): Even with --sparse=always, try to make `holes' only if the destination is a regular file. Reported by Szakacsits Szabolcs.
2004-02-07Remove xstat function pointer member. The way it was used was notJim Meyering
portable, since some systems (OSF V5.1, Solaris 2.5.1) provide static inline `stat' and `lstat' functions, thus making the tests of `xstat == lstat' in copy.c always fail. (copy_dir): Set `.dereference' member, not .xstat. (copy_internal): Use `XSTAT (x, ...)' in place of `*(x->xstat) (...)'. Use `x->dereference == DEREF_NEVER' in place of `x->xstat == lstat'. (valid_options): Remove now-obsolete FIXME comments.
2004-01-04(copy_internal): Use ASSIGN_STRDUPA rather than alloca and strcpy.Jim Meyering
2003-11-02(copy_internal): Use `sizeof *var' rather than `sizeof EXPLICIT_TYPE'.Jim Meyering
The former is more maintainable and usually shorter.
2003-10-25(triple_hash, triple_hash_no_name): Adjust to reflectJim Meyering
type changes (unsigned int -> size_t) in hash.c.
2003-10-12(copy_internal): Don't #ifdef-out simple uses ofJim Meyering
S_ISLNK or S_ISSOCK. The S_IS* macros are guaranteed to be defined via system.h.
2003-09-28Remove unnecessary cast of alloca, since now it's guaranteed to be (void *).Jim Meyering
2003-09-09Alphabetize includes.Jim Meyering
Remove duplicate inclusion of "same.h".
2003-08-30When source and destination arguments refer to the same file, resideJim Meyering
on a partition (e.g. VFAT) on which distinct names may refer to the same directory entry (often due to variations in case), and when the link count for the file is 1, mv no longer unlinks the file. FIXME: this is a band-aid fix. If the file happens to have a link count of 2 or greater, mv will still unlink it. (same_file_ok): Invoke same_name (which might still return false for names that refer to the same directory entry) only if the link count is 2 or more.
2003-08-09Include utimens.h.Jim Meyering
(copy_internal): Set file timestamps with utimens, not utime.
2003-07-23Tweak comment: Solaris2.5.1 -> Solaris 2.5.1Jim Meyering
2003-07-12It appears that the `#pragma alloca' included via "system.h" isJim Meyering
adequate, since join.c uses alloca, yet lacked an in-file #pragma. Remove `#pragma alloca'.
2003-06-19(copy_internal) [HAVE_STRUCT_STAT_ST_AUTHOR]:Jim Meyering
Use `error_t' (rather than int) as type for local `err'.
2003-06-19(copy_internal) [HAVE_STRUCT_STAT_ST_AUTHOR]:Jim Meyering
Fix author preservation code.
2003-05-13(struct F_triple) [name]: Remove const attribute.Jim Meyering
(triple_free): Don't apply cast to argument of free. (seen_file): Add cast here instead.
2003-04-11Remove anachronistic casts of xmalloc,Jim Meyering
xrealloc, and xcalloc return values and of xrealloc's first argument.
2003-04-04Because of inappropriate (but POSIX-mandated) behavior of rename,Jim Meyering
`mv a b' would not remove `a' in some unusual cases. Work around this by unlinking `a' when necessary. (same_file_ok): Add an output parameter. Set it in the offending case. (copy_internal): When necessary, unlink SRC_PATH and inform caller.
2003-03-02(copy_internal) [un_backup]: When recovering from aJim Meyering
failure to create a hard link, do not remove the entry associating the source dev/ino with the destination file name.
2003-02-28(copy_internal): When link fails because of anJim Meyering
existing destination file, unlink that file and try again.
2002-12-15Remove all uses of `PARAMS'.Jim Meyering
2002-09-29In move mode, always first try to rename. Before, upon failure toJim Meyering
rename a directory, this code would never attempt to rename any other file in that directory, but would thenceforth always copy. On some systems (NetApp version ??), renaming a directory may fail with EXDEV, yet renaming files within that directory to a newly- created destination directory succeeds. (copy_internal): Remove local, move_mode; use x->move_mode instead. Based on a patch from Tom Haynes.
2002-07-20(copy_internal): Use file_name_lookup, not getdport.Jim Meyering
Patch by Alfred M. Szmidt.
2002-06-21Change all `preserving ...' diagnostics toJim Meyering
`failed to preserve ...' to make the failure clearer.
2002-06-21Include hurd.h.Jim Meyering
(copy_internal): Preserve the stat.st_author field.
2002-05-30(copy_reg): Use a temporary to avoid a warningJim Meyering
from gcc -W about comparison between signed and unsigned. (copy_internal): Likewise, but use a cast.
2002-03-30(copy_internal): Move the block that sets `earlier_file'Jim Meyering
down to just before the first use of that variable. Otherwise, it was possible to make mv (and probably cp, too) malfunction when copying hard-linked files into a directory containing at least one of the source file names. Call forget_created everywhere thereafter where this function returns without creating a destination file that might subsequently be linked. Reported by Iida Yosiaki.
2002-03-19use only one space after semicolonJim Meyering
2002-03-17(copy_internal) [move_mode]: Give a better diagnosticJim Meyering
(using errno from the failed unlink) when a cross-device `mv' fails, e.g., because the destination cannot be unlinked. Prompted by a report from Karl Berry.
2002-03-10(copy_reg): Don't exit upon finding a replaced file.Jim Meyering
Instead, just skip it like the diagnostic says. Reported by Paul Eggert.
2002-03-10(copy_reg): Use a more concise diagnostic forJim Meyering
reporting replaced files. This avoids a bug in the code, which mishandled ino_t wider than long.
2002-03-03(copy_internal): Remove -r warning; no longer needed.Jim Meyering
2002-03-02add a commentJim Meyering
2002-03-02(copy_internal): For each symlink copied by cp -r,Jim Meyering
issue a warning that `cp -r' is not portable.
2002-03-02(copy_reg): Detect abuse of a race conditionJim Meyering
whereby an unprivileged user could gain read access to otherwise- inaccessible files when root uses cp or mv to copy a hierarchy belonging to that user.
2002-02-26tweak commentJim Meyering
2002-01-12(copy_reg): Don't treat errno==ENOENT as a special case.Jim Meyering
(same_file_ok): Detect a case that would have lead to the errno==ENOENT condition above (and a misleading diagnostic), and return 0 so we give a diagnostic about the source and destination being the same file. (copy_internal): Use an explicit test for errno==EXDEV to detect that rename has failed because source and destination are on different devices. This reverts part of a change from 1997-12-13, and is to avoid letting a race condition evoke a bogus diagnostic. Note that while POSIX has encouraged the errno==EXDEV test for years, it was inadequate back in 1997. I'm hoping that many more systems have conforming support these days. Reported by Michael Gaughen <mgaughen@polyserve.com>
2001-11-22(triple_hash_no_name): New function.Jim Meyering
(src_info_init): New function. (copy_internal): Warn and return early for the second and subsequent occurrences of the same source file named on the command line.
2001-11-22(seen_file): Change type of `stats' parameter to pointer.Jim Meyering
(copy_internal): Update caller.
2001-11-22(struct F_triple): Rename from dest_info.Jim Meyering
(seen_file): Rename from seen_dest. Rename parameters accordingly. (record_file): Rename from record_dest. Rename parameters accordingly. (triple_hash): Rename from dest_info_hash. (triple_compare): Rename from dest_info_compare. (triple_free): Rename from dest_info_free.
2001-11-22copy.c shouldn't maintain static state.Jim Meyering
(dest_info): Remove declaration of file-scoped global. (dest_info_init): Require a parameter. Update all callers. (seen_dest): Require a hash table parameter. Update callers. (record_dest): Likewise.
2001-10-21yikes. put the preserve_metadata assignment *after* declarations.Jim Meyering
gcc-3.0 didn't complain.
2001-10-21Include xreadlink.h.Jim Meyering
(copy_internal): Don't use PATH_MAX. Rewrite the symlink-copying code to use xreadlink.
2001-10-18(dest_info_free): New function.Jim Meyering
(dest_info_init): Make the hash table code use it. (record_dest): Store each DEST in malloc'd memory. Hence the above. Use dest_info_free to free the `ent' we couldn't insert.
2001-10-13(copy_internal): Tighten up and add commentsJim Meyering
describing the test for when to record (via remember_copied) a <dst_path, source_dev, source_ino> triple. Relax the test that guards the hard-linked-dir check and the hard-link-preserving code.
2001-10-13* src/copy.h (struct cp_options): Rename members:Jim Meyering
s/preserve_owner_and_group/preserve_ownership/, and s/preserve_chmod_bits/preserve_mode/. * src/copy.c, src/cp.c, src/install.c, src/mv.c: Update all uses.
2001-10-07(copy_dir): Now that remember_copied copies theJim Meyering
file name, free the temporary `dst_path' allocated here.
2001-10-06(record_dest): Fix test for whether to free `ent'.Jim Meyering
Thank heavens for regression tests.