summaryrefslogtreecommitdiffstats
path: root/bin/cp/utils.c
Commit message (Collapse)AuthorAgeFilesLines
* Add NFSv4 ACL support to cp(1) and fix a few memory leaks.trasz2009-09-021-30/+93
| | | | | | | | | Note that this changes error reporting behaviour somewhat - before, no error was reported if ACL couldn't be copied because the target filesystem doesn't support ACLs. Now, it will be reported - of course, only if there actually is an ACL to copy. Reviewed by: rwatson
* Preserve file flags on symlinks in cp -Rp.jilles2009-05-301-1/+1
| | | | | | | | | This reported ENOSYS before. PR: bin/111226 (part of) Submitted by: Martin Kammerhofer Approved by: ed (mentor) MFC after: 3 weeks
* Teach cat(1) and cp(1) to use a larger buffer if enough memory is presentivoras2008-10-301-2/+29
| | | | | | | | | | | | | | | | | | | | | in the system. A simple heuristics is used to detect what is "enough" memory: if number of physmem pages is greater than 32k (equalling 128 MB on machines with 4 kB pages). Typical immediate result of these changes is reduction in context switches and the goal is to increase efficiency by using large buffers: before: /usr/bin/time -hlp cat file1 > file2 ... 163 voluntary context switches 11194 involuntary context switches after: /usr/bin/time -hlp ./cat file1 > file2 ... 417 voluntary context switches 272 involuntary context switches Reviewed by: hackers@ (no objections to earlier version of cat patch) Approved by: gnn (mentor) MFC after: 4 months
* Add fallback when mmap fails on regular files. Some filesystems,dds2008-10-271-30/+28
| | | | | | | like smbnetfs, do not support mmap. Reported by: Harti Brandt MFC after: 1 month
* Remove redundant close(2).trasz2008-09-091-1/+0
| | | | | Submitted by: kensmith Approved by: rwatson (mentor)
* Fix ACL preservation, apparently broken in 1.47.trasz2008-08-071-1/+3
| | | | | Approved by: rwatson MFC after: 3 weeks
* Add an '-a' option which is identical to specifying '-RpP' forjhb2008-03-101-2/+2
| | | | | | compatibility with other implementations. MFC after: 1 month
* o Style(9).maxim2006-10-071-9/+7
| | | | Submitted by: bde
* o Avoid division by zero.maxim2006-10-071-3/+8
| | | | | | o Place error checking code near to the syscall. Submitted by: bde
* o Hold copied bytes counter in off_t. This prevents statisticsmaxim2006-10-061-1/+1
| | | | | | | | displayed by SIGINFO handler from overflow. PR: bin/104039 Submitted by: Geoffrey Giesemann MFC after: 2 weeks
* - Fix options order.ru2006-08-251-2/+2
| | | | - Touch manpage's document date.
* Remove a stray -a option that probably sneaked in from julian'sru2006-08-251-2/+2
| | | | attempt to enter append mode twice in vi(1). :-)
* Add an option to allow copying of a hierarchy while linking he regular files.julian2006-08-241-77/+92
| | | | | | Bikeshedded to death on: hackers Submitted by:andersonatcenttech.com MFC in: 1 month
* Attempt to complete the userspace integration of POSIX.1e extended ACLs.csjp2005-09-051-0/+80
| | | | | | | | | | | | | | This includes adding support for ACLs into cp(1) and mv(1) userspace utilities. For mv(1), if _PC_ACL_EXTENDED is in effect for the source AND destination operands, the destination file's ACLs shall reflect the source. For cp(1), if _PC_ACL_EXTENDED is in effect for both source and destination operands, and -p has been specified, the ACLs from the source shall be preserved on the destination. MFC after: 1 month
* Sync program's usage() with manpage's SYNOPSIS.ru2005-02-091-2/+3
|
* Plug file descriptor leak in implementation of -n option.tjr2004-06-051-0/+1
|
* Remove clause 3 from the UCB licenses.markm2004-04-061-4/+0
| | | | OK'ed by: imp, core
* Don't mmap(2) and munmap(2) zero-length files.alc2003-11-131-1/+2
| | | | Submitted by: Wiktor Niesiobedzki <bsd@w.evip.pl>
* support saving both user/group and permissions on symlinks (from PR)jmg2003-06-221-13/+20
| | | | | | | | also fix a slight bogon that assumed an fd of 0 was not valid. Changed it to be -1. PR: bin/25017 Submitted by: Martin Kammerhofer
* Add a SIGINFO handler.mdodd2003-04-071-0/+22
|
* Constify and staticify for lint.markm2002-10-181-2/+2
|
* Fix some easy WARNS.markm2002-07-311-4/+4
|
* Add the -n option, which automatically answers "no" to the overwrite question.johan2002-07-231-3/+7
| | | | | | | PR: 7828 Suggested by: Daniel O'Connor <doconnor@gsoft.com.au> Approved by: sheldonh (mentor) MFC after: 2 weeks
* Fix some low-hanging lint-fruit: endianness and staticness warnings.markm2002-07-031-2/+4
|
* Consistently use __FBSDIDobrien2002-06-301-2/+2
|
* Fix warnings inspired by lint, a commercial lint and WARNS=4.markm2002-02-221-10/+6
|
* Modernization effort for bin/c*:imp2002-02-021-16/+6
| | | | | | | | | | | | o __P has been reoved o Old-style K&R declarations have been converted to new C89 style o register has been removed o prototype for main() has been removed (gcc3 makes it an error) o int main(int argc, char *argv[]) is the preferred main definition. o Attempt to not break style(9) conformance for declarations more than they already are. Approved by: arch@, new style(9)
* Typo in warning message (chown should be chmod).mckay2001-12-111-1/+1
|
* Add more headers that are required with -fno-builtin (stdlib and strings)des2001-06-191-0/+1
|
* Removed the broken code which claimed to lose the set[ug]id bits inbde2001-06-111-17/+3
| | | | | | | | | | | | | | | | | | | | | the !(pflag && setfile()) case for regular files unless the copy is owned by the same user and group. These bits have already been lost (or never gained) in the correct way. The code didn't actually lose the bits; it depended on them being lost already (apparently in all cases) and attempted to gain them as necessary, but it often gained them (and sometimes collateral bits) when wrong: - pflag && setfile() == 0 case (i.e., for a successful cp -p): setfile() copies all the attributes as correctly as possible (as specified by POSIX), and we sometimes messed up the up the mode by setting it again. Also, if the file is immutable, then setting the mode again gave spurious errors (PR 20646). - !pflag case. If the target is created, POSIX requires it to not have the set[ug]id bits, but we sometimes copied them from the source. If the target already exists, POSIX requires its mode to be unchanged, but we sometimes copied the whole mode from the source. PR: 20646 MFC after: 4 weeks
* Migrate from using MAXPATHLEN to MAX_PATH. Use strlcpy to copy theimp2001-05-161-1/+2
| | | | strings.
* Don't depend on <sys/stat.h> bogusly including <sys/time.h> (and therebywollman2000-10-101-0/+1
| | | | <time.h>).
* fix cp -vi bugmharo2000-01-231-2/+3
| | | | Submitted by: Dan Papasian (bugg_ on irc)
* brucify and move printf() to catch cases of special filesmharo1999-08-291-5/+3
|
* $Id$ -> $FreeBSD$peter1999-08-271-1/+1
|
* Add a verbose mode to show what files are being copied.mharo1999-08-261-3/+6
| | | | | | Idea taken from obrien. Reviewed by: obrien
* Various spelling/formatting changes.kris1999-05-081-2/+2
| | | | Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
* First set of fixes to keep egcs happy. These include {} around singleimp1999-04-251-2/+3
| | | | | | | | | | statement if blocks[*] when the else could be ambiguous, not defaulting to int type and removal of some unused variables. [*] This is explicitly allowed by style(9) when the single statement spans more than one line. Reviewed by: obrien, chuckr
* Don't use mmap() for non-regular files, since st_size is only meaningfulbde1998-11-181-2/+2
| | | | | | | | for regular files. This fixes recent breakage of cp'ing from /dev/zero. /dev/zero doesn't support mmap(), but the device driver mmap routines are not called for mapping 0 bytes, so the error was not detected. mmap() can't even be used for cp'ing special files that support mmap(), since there is general way to determine the file size.
* Don't attempt to change owner/mode/flags that don't need to changed.peter1998-06-101-15/+29
| | | | | | This should calm down attempts to `cp -p' to a nfs mount or some other filesystem that doesn't accept flags or all combinations of flags. It will warn if it fails to change flags though.
* Make sure we pass the length - 1 to readlink, since it adds its ownimp1998-06-091-2/+2
| | | | | NUL at the end of the path. Inspired by: OpenBSD's changes in this area by theo de raadt
* Restore Lite-2 sccsid.charnier1998-05-131-2/+2
|
* Correct use of .Nm and other cosmetics. Add rcsid. Remove unused #inc.charnier1998-05-061-5/+6
|
* Fixed syntax error in normally-unconfigured code in previous commit.bde1998-01-171-2/+2
|
* Fixed handling of short writes. Previously, we stopped copying andbde1998-01-161-5/+17
| | | | | | printed a bogus warning with a stale errno if write() returns a short count. Now we continue copying. We still print a bogus warning if write() returns an "impossible" short count of 0.
* cp(1) is too silent if used with the option -i. It shouldwosch1997-10-031-2/+5
| | | | | print which input cp(1) expect (y/n) and print a warning if the file was not overwritten.
* Revert $FreeBSD$ to $Id$peter1997-02-221-1/+1
|
* Sweep through the tree fixing mmap() usage:alex1997-01-161-1/+1
| | | | | | | | | | | | - Use MAP_FAILED instead of the constant -1 to indicate failure (required by POSIX). - Removed flag arguments of '0' (required by POSIX). - Fixed code which expected an error return of 0. - Fixed code which thought any address with the high bit set was an error. - Check for failure where no checks were present. Discussed with: bde
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Merge Lite2 mods and -Wall cleaning.steve1996-12-141-2/+2
|
OpenPOWER on IntegriCloud