Age | Commit message (Collapse) | Author |
|
* 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.
|
|
* 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.
|
|
about out-of-range initializer with Sun C 5.8.
|
|
* 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.
|
|
Needed on MacOS X.
Signed-off-by: Jim Meyering <jim@meyering.net>
|
|
inaccurate by the 2006-10-18 change.
|
|
* 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>
|
|
* 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.
|
|
mknod over mkfifo.
|
|
when opening dst_name.
(copy_reg, copy_internal): Use (SYSCALL != 0) rather than plain
(SYSCALL) to test for failure in a system call.
|
|
a fifo. This preserves the special mode bits on Solaris 10, which
is compatible with what Solaris 10 cp -R does.
|
|
variable src_type.
|
|
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.
|
|
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.
|
|
* 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.
|
|
* 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.
|
|
|
|
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.
|
|
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.
|
|
Correct them.
|
|
|
|
" (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.
|
|
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.
|
|
to mention the now-removed cp_options.xstat member.
|
|
file descriptor dest_desc.
|
|
Correctly access SRC_SB's element ST_AUTHOR.
|
|
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>.
|
|
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>
|
|
(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.
|
|
when moving a symlink into the place of an existing non-directory.
Reported by Joshua Hudson.
|
|
|
|
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.
|
|
|
|
(copy_internal): Use lchmod rather than chmod.
|
|
(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.
|
|
(set_owner, preserve_author): New functions, factored out of copy_reg.
(copy_reg): Use them.
(copy_internal): Use them here, too.
From Andreas Gruenbacher.
|
|
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.
|
|
(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.
|
|
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.
|
|
TIMESPEC_NS macro.
|
|
|
|
(copy_reg): Don't call fd_safer; no longer needed
now that we include fcntl--.h.
|
|
|
|
This is a crutch so that `make distcheck's sc_tight_scope rule
knows that they really are deliberately declared that way.
|
|
[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.
|
|
|
|
|
|
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.
|
|
(copy_reg): Use fd_safer.
|
|
|