summaryrefslogtreecommitdiff
path: root/src/copy.c
AgeCommit message (Collapse)Author
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.
2000-08-27(copy_reg): Rename two goto labels.Jim Meyering
2000-08-20Declare lstat.Jim Meyering
(copy_dir): Set `xstat' member to lstat so that with `-H' we don't follow symlinks found via recursive traversal. Update uses of `dereference' to compare against new enum member names.
2000-08-18(DO_CHOWN): Do not make a special case for non-root.Jim Meyering
POSIX.2 requires that cp -p and mv attempt to set the uid of the destination file, even if you're not root. This affects behavior only on hosts that let you give files away via chmod.
2000-08-14(copy_reg): Move declaration of local, `n_read', intoJim Meyering
the scope where it's used. (copy_internal): In calling copy_reg, pass not the raw `src_mode', but the possibly-umask-relative mode, `get_dest_mode (x, src_mode)'.
2000-08-13(copy_reg): Add comment.Jim Meyering
2000-08-13(get_dest_mode): Rename from new_nondir_mode.Jim Meyering
Honor the umask for `cp', but not for `mv' or `cp -p'. (copy_reg): New 4th parameter, dst_mode. Pass it as 3rd arg. to open. (copy_internal): Change type of locals `src_mode' and `src_type' from int to mode_t. Remove unnecessary local `fix_mode'. Combine two if-stmts into one. Pass `src_mode' as 4th arg to copy_reg. If we've just created a new regular file, return early, skipping the chmod step. copy_reg now sets permissions of such files upon creation. Use get_dest_mode, so there's just one chmod call here.
2000-08-08(copy_dir, copy_internal): Invoke xalloc_die instead of printing our own ↵Jim Meyering
message.
2000-07-30(copy_internal): Quote the file names that are displayedJim Meyering
with --verbose and --backup.
2000-07-15Convert "`%s'" in format strings to "%s", and wrap eachJim Meyering
corresponding argument in a `quote (...)' call -- if there's only one. If there are more than one, then use `quote_n (0, ...), quote_n (1, ...), ...'.
2000-06-27(copy_dir): Don't set errno beforeJim Meyering
invoking savedir, and assume that errno is nonzero if savedir fails.
2000-06-25(copy_internal): Don't return return immediately after aJim Meyering
failed copy_dir call -- otherwise, the failure to read a single file in a source directory would cause the containing destination directory not to have owner/perms set properly. Reported by Piotr Kwapulinski.
2000-06-16(copy_reg): Give a slightly better diagnostic.Jim Meyering
2000-05-29Allow `cp -d -u' to copy one symlink onto another that's identical.Jim Meyering
(copy_internal): Change the || to ^ in the big sameness test, so copying one symlink onto another, identical one doesn't fail here. If the symlink call fails, don't report the failure if the destination already exists and is a symlink pointing to the proper name.
2000-05-12(copy_internal): Fix force and interactive tests.Jim Meyering
2000-02-05(copy_internal): Don't allow mv to move a directory ontoJim Meyering
a non-directory. Reported by Brian Kimball via Michael Stone.
2000-01-09This affects cp, install, and mv.Jim Meyering
(copy_internal): When making backup files in verbose mode, print the backup file name on the same line as the rest of the information, e.g., `a -> b (backup: b.~13~)' rather than on a line by itself.
1999-12-05Revert the previous change.Jim Meyering
(copy_internal): In move mode, if the rename attempt fails, then unlink any existing destination file. This makes a cross-device `mv' more consistent with the intra-device behavior. This change is required by POSIX to make a cross-device move act with semantics similar to those of the rename syscall. For example now `mv' can move a file onto a symlink to itself when that symlink is on a separate partition. With fileutils-4.0j, it would fail with a diagnostic saying they were the same file. Reported by Bruno Haible.
1999-12-04(copy_internal): Be consistent with intra-device behaviorJim Meyering
and *do* allow `mv' to move a file onto a symlink to itself when that symlink is on a separate partition. With fileutils-4.0j, it would fail with a diagnostic saying they were the same file. Reported by Bruno Haible.
1999-11-11(copy_internal): Treat src and dest as the `same' inJim Meyering
`mv src symlink-to-src' when src and dest are on different partitions. Otherwise, that `mv' command would silently remove `src'. Reported by Michael Stone.
1999-11-05Use HAVE_STRUCT_STAT_ST_BLOCKS, not deprecated HAVE_ST_BLOCKS.Jim Meyering
1999-08-08(copy_dir): Remove cast of savedir arg.Jim Meyering
1999-05-23(copy_internal): Don't apply the umask in move_mode.Jim Meyering
Otherwise, `mv' would not preserve the permissions when copying between partitions. Reported by David Godfrey
1999-05-23Remove today's earlier misguided attempts.Jim Meyering
Add a single condition to the existing sameness test.
1999-05-23Include same.h.Jim Meyering
(copy_internal): Qualify SAME_INODE test with (link-count == 1 || same_name(...)).
1999-05-23(copy_internal): Make it so `mv -f FILE FILE' does not remove FILE.Jim Meyering
Based on a patch from Chris Yeo.
1999-04-30(copy_internal): Move the one-file-system test so thatJim Meyering
it follows the `if (new_dst || !S_ISDIR (dst_sb.st_mode))' block. Prior to this change, `cp --one-file-system' would traverse a file- system boundary if the destination directory existed. From thospel@mail.dma.be.
1999-04-30(copy_internal): Don't make `mv foo symlink-to-foo' fail.Jim Meyering
That is, even though source and destination are `the same,' don't fail if the destination is a symlink. From Peter Samuelson.
1999-04-26(copy_reg, copy_internal): Use proper mode_t types and macros.Jim Meyering
Don't assume the traditional Unix values for mode bits.
1999-02-16update copyright datesJim Meyering
1999-01-31(copy_internal): Describe any backup-related renamingJim Meyering
operations when in verbose mode. (copy_internal): Likewise. Based on changes from Marty Leisner.
1999-01-11(copy_internal): Handle two more values of errno fromJim Meyering
failed rename of a directory into a subdirectory of itself.
1998-12-18(copy_internal): Remove errnoeous `%s: ' prefixJim Meyering
from format string. From Michiel Bacchiani.
1998-12-07Use dir_name, not dirname. Include dirname.h.Jim Meyering
1998-11-30(copy_internal): Remove earlier (but less effective)Jim Meyering
test for move/copy-into-self. Instead, deduce the move-into-self condition from errno==EINVAL after a failed rename.
1998-09-28(copy_internal): Do honor `n' reply in move-mode.Jim Meyering
Otherwise, `touch a b; echo n|mv -i a b' would remove b. From Bernd Leibing.
1998-09-27(copy_internal): Don't preserve hard-linked directoriesJim Meyering
to avoid damaging the destination filesystem when copying from a Netapp snapshot directory. With code from Kjetil Torgrim Hollstein and Paul Eggert.
1998-08-15(copy_internal) [one-file-system]: Do copy mount pointJim Meyering
directories (but none of their entries). This makes `cp --one-file-system' work the same way tar does. From Marty Leisner.
1998-08-02(copy_internal): Compare time stamps with subsecond resolution if available.Jim Meyering