[Midnightbsd-cvs] src [11196] trunk/bin/mv/mv.c: sync mv with freebsd
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Jul 1 11:49:46 EDT 2018
Revision: 11196
http://svnweb.midnightbsd.org/src/?rev=11196
Author: laffer1
Date: 2018-07-01 11:49:45 -0400 (Sun, 01 Jul 2018)
Log Message:
-----------
sync mv with freebsd
Modified Paths:
--------------
trunk/bin/mv/Makefile
trunk/bin/mv/mv.1
trunk/bin/mv/mv.c
Property Changed:
----------------
trunk/bin/mv/mv.1
Modified: trunk/bin/mv/Makefile
===================================================================
--- trunk/bin/mv/Makefile 2018-07-01 15:49:09 UTC (rev 11195)
+++ trunk/bin/mv/Makefile 2018-07-01 15:49:45 UTC (rev 11196)
@@ -1,7 +1,13 @@
+# $MidnightBSD$
# @(#)Makefile 8.2 (Berkeley) 4/2/94
-# $FreeBSD: src/bin/mv/Makefile,v 1.8 2001/12/04 01:57:45 obrien Exp $
-# $MidnightBSD$
+# $FreeBSD: stable/10/bin/mv/Makefile 262951 2014-03-09 17:04:31Z jmmv $
+.include <bsd.own.mk>
+
PROG= mv
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.prog.mk>
Modified: trunk/bin/mv/mv.1
===================================================================
--- trunk/bin/mv/mv.1 2018-07-01 15:49:09 UTC (rev 11195)
+++ trunk/bin/mv/mv.1 2018-07-01 15:49:45 UTC (rev 11196)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"-
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -30,10 +31,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)mv.1 8.1 (Berkeley) 5/31/93
-.\" $FreeBSD: src/bin/mv/mv.1,v 1.28 2005/01/16 16:41:58 ru Exp $
-.\" $MidnightBSD: src/bin/mv/mv.1,v 1.3 2008/06/30 02:36:17 laffer1 Exp $
+.\" $FreeBSD: stable/10/bin/mv/mv.1 248342 2013-03-15 20:12:54Z joel $
.\"
-.Dd August 28, 2012
+.Dd March 15, 2013
.Dt MV 1
.Os
.Sh NAME
@@ -156,6 +156,16 @@
.Ed
.Sh EXIT STATUS
.Ex -std
+.Sh EXAMPLES
+Rename file
+.Pa foo
+to
+.Pa bar ,
+overwriting
+.Pa bar
+if it already exists:
+.Pp
+.Dl $ mv -f foo bar
.Sh COMPATIBILITY
The
.Fl h ,
@@ -165,7 +175,6 @@
options are non-standard and their use in scripts is not recommended.
.Sh SEE ALSO
.Xr cp 1 ,
-.Xr cpdup 1 ,
.Xr rm 1 ,
.Xr symlink 7
.Sh STANDARDS
Property changes on: trunk/bin/mv/mv.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/mv/mv.c
===================================================================
--- trunk/bin/mv/mv.c 2018-07-01 15:49:09 UTC (rev 11195)
+++ trunk/bin/mv/mv.c 2018-07-01 15:49:45 UTC (rev 11196)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1989, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -29,7 +30,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/mv/mv.c,v 1.45.2.1 2005/11/12 21:21:46 csjp Exp $ */
#if 0
#ifndef lint
@@ -43,7 +43,7 @@
#endif /* not lint */
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/bin/mv/mv.c 301147 2016-06-01 17:30:50Z truckman $");
#include <sys/types.h>
#include <sys/acl.h>
@@ -123,7 +123,7 @@
*/
if (stat(argv[argc - 1], &sb) || !S_ISDIR(sb.st_mode)) {
if (argc > 2)
- usage();
+ errx(1, "%s is not a directory", argv[argc - 1]);
exit(do_move(argv[0], argv[1]));
}
@@ -141,7 +141,7 @@
/* It's a directory, move each file into it. */
if (strlen(argv[argc - 1]) > sizeof(path) - 1)
errx(1, "%s: destination pathname too long", *argv);
- (void)strlcpy(path, argv[argc - 1], sizeof(path));
+ (void)strcpy(path, argv[argc - 1]);
baselen = strlen(path);
endp = &path[baselen];
if (!baselen || *(endp - 1) != '/') {
@@ -274,41 +274,36 @@
static int
fastcopy(const char *from, const char *to, struct stat *sbp)
{
- struct timeval tval[2];
- static u_int blen;
- static char *bp;
+ struct timespec ts[2];
+ static u_int blen = MAXPHYS;
+ static char *bp = NULL;
mode_t oldmode;
int nread, from_fd, to_fd;
if ((from_fd = open(from, O_RDONLY, 0)) < 0) {
- warn("%s", from);
+ warn("fastcopy: open() failed (from): %s", from);
return (1);
}
- if (blen < sbp->st_blksize) {
- if (bp != NULL)
- free(bp);
- if ((bp = malloc((size_t)sbp->st_blksize)) == NULL) {
- blen = 0;
- warnx("malloc failed");
- return (1);
- }
- blen = sbp->st_blksize;
+ if (bp == NULL && (bp = malloc((size_t)blen)) == NULL) {
+ warnx("malloc(%u) failed", blen);
+ (void)close(from_fd);
+ return (1);
}
while ((to_fd =
open(to, O_CREAT | O_EXCL | O_TRUNC | O_WRONLY, 0)) < 0) {
if (errno == EEXIST && unlink(to) == 0)
continue;
- warn("%s", to);
+ warn("fastcopy: open() failed (to): %s", to);
(void)close(from_fd);
return (1);
}
while ((nread = read(from_fd, bp, (size_t)blen)) > 0)
if (write(to_fd, bp, (size_t)nread) != nread) {
- warn("%s", to);
+ warn("fastcopy: write() failed: %s", to);
goto err;
}
if (nread < 0) {
- warn("%s", from);
+ warn("fastcopy: read() failed: %s", from);
err: if (unlink(to))
warn("%s: remove", to);
(void)close(from_fd);
@@ -344,14 +339,13 @@
* on a file that we copied, i.e., that we didn't create.)
*/
errno = 0;
- if (fchflags(to_fd, (u_long)sbp->st_flags))
+ if (fchflags(to_fd, sbp->st_flags))
if (errno != EOPNOTSUPP || sbp->st_flags != 0)
warn("%s: set flags (was: 0%07o)", to, sbp->st_flags);
- tval[0].tv_sec = sbp->st_atime;
- tval[1].tv_sec = sbp->st_mtime;
- tval[0].tv_usec = tval[1].tv_usec = 0;
- if (utimes(to, tval))
+ ts[0] = sbp->st_atim;
+ ts[1] = sbp->st_mtim;
+ if (utimensat(AT_FDCWD, to, ts, 0))
warn("%s: set times", to);
if (close(to_fd)) {
More information about the Midnightbsd-cvs
mailing list