summaryrefslogtreecommitdiff
path: root/src/copy.c
AgeCommit message (Collapse)Author
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.
2001-10-06(record_dest): Avoid a small leak.Jim Meyering
(copy_internal): Call remember_copied only for if the source file has 1 < st_nlink, or if it's a directory. Now that EARLIER_FILE is set conditionally, initialize it to NULL.
2001-10-05Include hash-pjw.h and remove definition of hash_pjw.Jim Meyering
2001-09-29(copy_internal): Call record_dest for all types ofJim Meyering
files (for which this makes sense), not just regular ones.
2001-09-28Include "hash.h" and "same.h".Jim Meyering
(struct Dest_info): Define. (dest_info): Declare global. (DEST_INFO_INITIAL_CAPACITY): Define. (hash_pjw): New function. (dest_info_hash): Likewise. (dest_info_compare): Likewise. (dest_info_init): Likewise. (seen_dest): Likewise. (record_dest): Likewise. (copy_internal): If the destination exists, fail if it's in the set of files that have already been created as part of this mv or cp. (copy_internal) [move_mode]: Record the destination dev/ino/filename. (copy_internal) [!move_mode, regular file]: Likewise.
2001-09-22Mostly clean-up (modulo the better diagnostic).Jim Meyering
(copy_internal): Rename parameter, move_mode, to command_line_arg, and adjust caller. Now, move_mode is a local that is derived from command_line_arg. Factor some involved code to produce something slightly more readable. Use x->move_mode, not move_mode in determining which diagnostic to give (`backing up %s would destroy source; %s not moved').
2001-09-15(UNWRITABLE): Define (factored out of copy_internal).Jim Meyering
(copy_internal): Use UNWRITABLE.
2001-09-15(copy_internal) [move_mode]: Support the newJim Meyering
--reply=... option.
2001-09-08(copy_internal): Add braces around now-multi-stmtJim Meyering
if-block. This fixes a bug introduced by my 2001-08-06 change.
2001-08-31(copy_dir): Remove st_size argument.Jim Meyering
2001-08-31Include full-write.h.Jim Meyering
(full_write): Remove decl; not needed. (copy_reg): Don't assume read and write size fits in int.
2001-08-13(overwrite_prompt): New function.Jim Meyering
(copy_internal): Separate the mv-specific and non-move_mode code that determines whether to prompt the user. [move_mode]: Don't make mv fail (i.e. don't return 1) just because the user declined to remove one or more of the files.
2001-08-06(copy_internal): Set *rename_succeeded, so thatJim Meyering
the caller (mv) doesn't remove the source file.
2001-07-08revert unrelated part of last delta -- coming soon with a separate log entryJim Meyering
2001-07-08(get_dest_mode): Clear set-user-ID and set-group-ID bitsJim Meyering
when copying (i.e., not in move mode) and not preserving permissions.
2001-05-12(copy_internal): Remove the code that tested for NULLJim Meyering
dir_name return value. That can't happen.
2001-01-13add comment to go along with last changeJim Meyering
2001-01-13(same_file_ok): When moving a symlink onto itself,Jim Meyering
don't remove the symlink. Reported by David Luyer as Debian bug#82089, via Michael Stone.
2001-01-10(copy_internal): Add a comment.Jim Meyering
Set *copy_into_self in the new code that detects that. Make diagnostic more consistent: s/won't/will not/. [move_mode, copy_into_self]: Give a diagnstic here, now that we have the top_level_* globals. Remove the corresponding diagnostic from mv.c. Add a FIXME comment.
2001-01-10(copy_internal): Don't allow cp (or mv, when workingJim Meyering
across a partition boundary) to overwrite a non-directory with a directory.
2001-01-09add commentJim Meyering
2001-01-09(top_level_src_path, top_level_dst_path): New globals.Jim Meyering
(copy_internal): Use them. (copy): Set them.
2000-12-31Avoid an unnecessary `stat' when using --dereference.Jim Meyering
(same_file_ok): Use stat only if lstat reported that the file was a symbolic link.
2000-12-28tweak commentJim Meyering
2000-12-28tweak commentJim Meyering
2000-12-28(same_file_ok): Fix *another* typo from my 2000-09-03 change: ↵Jim Meyering
s/tmp_dst_sb/tmp_src_sb/.
2000-12-28(same_file_ok): Fix typo from my 2000-09-03 change: s/tmp_dst_sb/tmp_src_sb/.Jim Meyering
2000-12-28(same_file_ok): Use a single auto var forJim Meyering
tmp_dst_sb, instead of two static vars. Likewise for tmp_src_sb.
2000-12-25(same_file_ok): Remove declaration and set of unusedJim Meyering
variables: src_sb_no_link, dst_sb_no_link.
2000-09-22(copy_internal): Don't try to unlink directories whenJim Meyering
using --remove-dest with -R.
2000-09-09(copy_internal): Call chmod also if we've made theJim Meyering
preceding chown call and we're supposed to preserve some special permission bit(s) that would have been reset by chown. Reported by Greg Louis.
2000-09-09(SAME_OWNER, SAME_GROUP, SAME_OWNER_AND_GROUP): Define.Jim Meyering
(copy_internal): Avoid calling chown if we know it's not necessary.
2000-09-04Remove declaration of lstat, now that it's in copy.h.Jim Meyering
2000-09-04(same_file_ok): Hoist a test.Jim Meyering
2000-09-04factor out backup/same test, put it after if-else.Jim Meyering
2000-09-04(same_file_ok): factor some more. improve -- now passes all tests.Jim Meyering
checkpoint
2000-09-03(same_file_ok): New function, extracted from copy_internal,Jim Meyering
and partially rewritten. (copy_internal): Unlink destination file when unlink_dest_before_opening option is set, and when the source is neither a regular file nor a directory.
2000-08-27(copy_reg): New parameters: X and NEW_DST.Jim Meyering
Remove the SPARSE_MODE parameter. Update caller. Perform POSIX-mandated (for cp) open-with-O_WRONLY|O_TRUNC when the regular destination file exists; upon failure, unlink that existing file, then open again, but with O_WRONLY|O_CREAT. (copy_internal): `force' in not related to interactive; remove the conjunct. Remove the entire `else if (x->force)' block; justifying removal of the non-directory part is easy: POSIX requires we try to open an existing regular file, so we can't unlink it beforehand. The part that changes the mode on a directory to allow overwriting isn't necessary.
2000-08-27(copy_internal): Set `new_dst' when the move_mode rename fails,Jim Meyering
since we then unlink the destination file.