Commit Graph

76 Commits

Author SHA1 Message Date
Pawel Jakub Dawidek
b4b2596b97 - Make 'flags' argument to chflags(2), fchflags(2) and lchflags(2) of type
u_long. Before this change it was of type int for syscalls, but prototypes
  in sys/stat.h and documentation for chflags(2) and fchflags(2) (but not
  for lchflags(2)) stated that it was u_long. Now some related functions
  use u_long type for flags (strtofflags(3), fflagstostr(3)).
- Make path argument of type 'const char *' for consistency.

Discussed on:	arch
Sponsored by:	The FreeBSD Foundation
2013-03-21 22:44:33 +00:00
Joel Dahl
e9e3a1ab1f Add a few examples.
Obtained from:	OpenBSD
2013-03-15 20:12:54 +00:00
Eitan Adler
b7d1b37159 Follow the behavior as specified in POSIX:
if (exists AND (NOT f_option) AND
	((not_writable AND input_is_terminal) OR i_option))
		prompt

in particular, add the test for input_is_terminal

PR:		bin/173039
Submitted by:	Mark Johnston <markjdb@gmail.com>
Approved by:	cperciva
MFC after:	3 days
2012-11-15 15:05:51 +00:00
John Baldwin
6ce6b6c1d4 Add a -h flag similar to the -h flag for ln to force mv(1) to treat a
symbolic link to a directory for the target as a symbolic link instead of
a directory.  This makes it possible to atomically update a symbolic
link using rename().

Reviewed by:	gj
MFC after:	2 weeks
2012-08-31 14:35:01 +00:00
Ed Schouten
f9d4afb439 Put some static keywords in the source code.
For these simple utilities, it doesn't harm to make all global variables
static. In fact, this allows the compiler to perform better forms of
optimisation and analysis.
2011-10-31 08:59:17 +00:00
Ivan Voras
a23ffe9673 Don't chop IO into small pieces, follow cp(1) and just use MAXPHYS. 2011-10-03 21:48:10 +00:00
Edward Tomasz Napierala
62efc229e7 Add NFSv4 ACL support to mv(1).
Reviewed by:	rwatson
2009-09-04 21:49:37 +00:00
Xin LI
95aaf2e8a4 Staticify symbols that will not be used in other
places.
2008-07-19 00:13:26 +00:00
Diomidis Spinellis
961fdc4fac - Roll-back attempts to mimic rename(2) atomicity introduced in 1.47,
and follow the letter of the POSIX specification.

- Moving a directory to an existing non-empty directory will now fail,
  as required.

- Improve consistency and remove some style bugs of earlier versions.

This version passes all tests of tools/regression/bin/mv/regress.sh 1.6

Reviewed by:	bde
MFC after:	1 month
2007-12-27 11:33:42 +00:00
Diomidis Spinellis
3db8241bb4 Calling any function from vfork other than exec* and _exit yields
undefined behavior.

Noted by:	alfred
2007-12-17 09:02:42 +00:00
Diomidis Spinellis
2ec43f35f4 Eliminate gcc "variable clobbered" warnings by declaring the variables
living across the vfork as volatile.

Noted by:	kan
2007-12-16 17:47:34 +00:00
Diomidis Spinellis
3a44a28835 When moving a directory across devices to a place where a directory
with the same name exists, delete that directory first, before performing
the copy.  This ensures that mv(1) across devices follows the semantics
of rename(2), as required by POSIX.

This change could introduce the potential of data loss, even if the
copy fails, violating the atomicity properties of rename(2).  This is
(mostly) mitigated by first renaming the destination and obliterating
it only after a succesfull copy.

The above logic also led to the introduction of code that will cleanup
the results of a partial copy, if a cross-device copy fails.

PR:		bin/118367
MFC after:	1 month
2007-12-16 14:14:31 +00:00
Ruslan Ermilov
c930322c40 Bump document date on behalf of previous revision. 2007-11-01 09:49:45 +00:00
Pav Lucistnik
a3f58dae59 Replace a fairly opaque sentence with a much clearer wording from NetBSD.
PR:		docs/101330 (inspired by)
Submitted by:	Peter Gildea <peter@gildea.com>
Obtained from:	NetBSD
2007-05-12 22:18:27 +00:00
Christian S.J. Peron
9b4261c9b4 Attempt to complete the userspace integration of POSIX.1e extended ACLs.
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
2005-09-05 04:36:08 +00:00
Maxime Henrion
8835fa2759 Correct a few places where we called warn() when warnx() should have
been used.

Submitted by:	"Liam J. Foy" <liamfoy@sepulcrum.org>
Obtained from:	DragonFlyBSD
2005-05-19 21:33:48 +00:00
Ruslan Ermilov
6fca4c7c3f Add the new standard EXIT STATUS section where appropriate.
Sort standard sections in the (documented) preferred order.
2005-01-16 16:41:59 +00:00
Warner Losh
9ddb49cbe4 /*- or .\"- or #- to begin license clauses. 2005-01-10 08:39:26 +00:00
Mark Murray
6195fb4102 Remove clause 3 from the UCB licenses.
OK'ed by:	imp, core
2004-04-06 20:06:54 +00:00
Pawel Jakub Dawidek
3184e92100 When symbolic link is pointed onto a mount point, it can't be moved
to a different file system.
Patch in PR was incorrect.

PR:		bin/64430
Submitted by:	Samuel Tardieu
MFC after:	3 days
2004-03-21 13:38:37 +00:00
David E. O'Brien
8d5c19ffbc Centralize _PATH_* definitions.
Submitted by:	Tim Kientzle <kientzle@acm.org> (embellished by me)
2003-05-05 22:49:23 +00:00
David E. O'Brien
09a80d4867 Quiet warnings about copyright[]. 2003-05-01 16:58:57 +00:00
Giorgos Keramidas
99479039bb Grammar fix.
PR:		docs/42021
Submitted by:	Jeff Ito <jeffi@rcn.com>
MFC after:	3 days
2002-08-26 06:16:51 +00:00
Tom Rhodes
7d971bbf29 s/filesystem/file system/ as discussed on -developers 2002-08-21 17:32:44 +00:00
Ruslan Ermilov
ca38f0ddf7 mdoc(7) police: tidy up, bump document date on behalf of the -n option. 2002-08-09 10:46:00 +00:00
Johan Karlsson
0f7109e8c2 Update usage for the addition of -n in rev 1.35 of mv.c.
Approved by:	obrien, sheldonh (mentor).
2002-07-09 17:45:13 +00:00
Tim J. Robbins
9a81395d08 When trying to emulate a cross-device move operation with cp and rm, add
a "--" argument after the options so filenames with leading dashes are
handled correctly.

PR:		39318
Submitted by:	Serge van den Boom <svdb@stack.nl>
MFC after:	1 week
2002-06-16 04:06:58 +00:00
Juli Mallett
71e092d1bb Remove local definition of _PATH_CP, and use <paths.h>, _PATH_CP is in the
CURRENT <paths.h>.
2002-05-17 11:38:48 +00:00
Tom Rhodes
ebd4324457 Consistancy check s/file system/filesystem/
Reviewed by:	brian
2002-05-16 01:57:20 +00:00
David E. O'Brien
0302f42b51 Update SCM ID. 2002-03-22 19:52:59 +00:00
David E. O'Brien
12767b8463 Note that -n is non-standard. 2002-03-22 19:52:48 +00:00
David E. O'Brien
dce742c573 Add the -n option, which automatically answers "no" to the overwrite question. 2002-03-22 07:45:36 +00:00
Mark Murray
4b23bd7c2a Warnings fixes. 2002-02-22 21:13:31 +00:00
Warner Losh
fc69394f0a Move user_from_uid to pwd.h
Move group_from_gid to grp.h
Remove from stdlib.h
Make the prototypes match the code
Fix rm and mv to include new files.

NetBSD has these defined in those files, and others too that I've not
done.

Approved by: terminal room kabal
Reviewed by: jhb, phk
2002-02-14 01:59:47 +00:00
Warner Losh
b75c76877e missed a few registers 2002-02-02 07:09:30 +00:00
Warner Losh
46251dde8f 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.
2002-02-02 06:48:10 +00:00
David E. O'Brien
a748290789 Default to WARNS=2. Binary builds that cannot handle this must explicitly
set WARNS=0.

Reviewed by:	mike
2001-12-04 01:57:47 +00:00
Ruslan Ermilov
d628d776c4 mdoc(7) police: utilize the new .Ex macro. 2001-08-15 09:09:47 +00:00
Dima Dorfman
b91c884fda Set WARNS=2 on programs which compile cleanly.
Submitted by:	Mike Barcroft <mike@q9media.com>
2001-07-15 10:30:46 +00:00
Dima Dorfman
7ebcc426ef Remove whitespace at EOL. 2001-07-15 07:53:42 +00:00
Brian Somers
7bc6d0158f Fix the type of the NULL arg to execl()
Idea from: Theo de Raadt <deraadt@openbsd.org>
2001-07-09 09:24:06 +00:00
Warner Losh
422a64eac7 Use PATH_MAX in preference to MAXPATHLEN. 2001-05-29 18:20:36 +00:00
Kris Kennaway
29e13abe4c Silence WARNS=2 and BDECFLAGS on alpha and i386, except for mode_t
warnings.

MFC after:	1 week
2001-05-20 05:00:16 +00:00
Ruslan Ermilov
be8b149795 mdoc(7) police: use the new features of the Nm macro. 2000-11-20 11:39:41 +00:00
SADA Kenji
f698dde983 Don't emit a warning message if fchflags() returns EOPNOTSUPP
Requested by:	FUJISHIMA Satsuki <k5@cheerful.com>
Obtained from:	OpenBSD
2000-07-20 18:30:00 +00:00
SADA Kenji
3c2ddcf514 To make inherit file flags when mv(1) moves file between directories
on different file systems.

PR:		bin/12375
Submitted by:	Takashi SHIRAI <shirai@nintendo.co.jp>
No response by:	steve
No problem with:	building 5-current world
2000-07-15 14:59:02 +00:00
David Malone
a95d6fda80 Use lstat(2) instead of stat(2) when deciding if we should fastcopy
a file. This fixes moving symlinks across partitions.

PR:		17847
Reviewed by:	bde
2000-07-11 18:01:42 +00:00
Josef Karthauser
6a9a6f05ed Removed bogus dependancy on libutil.
Noticed by:	bde
2000-01-01 15:40:40 +00:00
Michael Haro
234c2f5b6e mention that -v is non-standard
Reviewed-by:	obrien
1999-09-04 03:33:18 +00:00
Michael Haro
46fedeb096 add verbose flag 1999-08-29 08:21:16 +00:00