Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/bin/mv Pull up following revision(s) (requested by mrg in...
details: https://anonhg.NetBSD.org/src/rev/b1ffcde5b690
branches: netbsd-7
changeset: 799839:b1ffcde5b690
user: martin <martin%NetBSD.org@localhost>
date: Sun Mar 06 18:40:09 2016 +0000
description:
Pull up following revision(s) (requested by mrg in ticket #1129):
bin/mv/mv.c: revision 1.45
add SIGINFO for mv(1), largely based upon the support in cp(1).
diffstat:
bin/mv/mv.c | 30 ++++++++++++++++++++++++++----
1 files changed, 26 insertions(+), 4 deletions(-)
diffs (82 lines):
diff -r 45f0f9b118a2 -r b1ffcde5b690 bin/mv/mv.c
--- a/bin/mv/mv.c Sun Mar 06 18:17:55 2016 +0000
+++ b/bin/mv/mv.c Sun Mar 06 18:40:09 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mv.c,v 1.43.22.1 2016/03/04 21:25:36 martin Exp $ */
+/* $NetBSD: mv.c,v 1.43.22.2 2016/03/06 18:40:09 martin Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: mv.c,v 1.43.22.1 2016/03/04 21:25:36 martin Exp $");
+__RCSID("$NetBSD: mv.c,v 1.43.22.2 2016/03/06 18:40:09 martin Exp $");
#endif
#endif /* not lint */
@@ -67,12 +67,20 @@
static int fflg, iflg, vflg;
static int stdin_ok;
+static sig_atomic_t pinfo;
static int copy(char *, char *);
static int do_move(char *, char *);
static int fastcopy(char *, char *, struct stat *);
__dead static void usage(void);
+static void
+progress(int sig __unused)
+{
+
+ pinfo++;
+}
+
int
main(int argc, char *argv[])
{
@@ -109,6 +117,8 @@
stdin_ok = isatty(STDIN_FILENO);
+ (void)signal(SIGINFO, progress);
+
/*
* If the stat on the target fails or the target isn't a directory,
* try the move. More than 2 arguments is an error in this case.
@@ -262,7 +272,9 @@
#endif
static blksize_t blen;
static char *bp;
- int nread, from_fd, to_fd;
+ int from_fd, to_fd;
+ ssize_t nread;
+ off_t total = 0;
if ((from_fd = open(from, O_RDONLY, 0)) < 0) {
warn("%s", from);
@@ -281,11 +293,21 @@
(void)close(to_fd);
return (1);
}
- while ((nread = read(from_fd, bp, blen)) > 0)
+ while ((nread = read(from_fd, bp, blen)) > 0) {
if (write(to_fd, bp, nread) != nread) {
warn("%s", to);
goto err;
}
+ total += nread;
+ if (pinfo) {
+ int pcent = (int)((100.0 * total) / sbp->st_size);
+
+ pinfo = 0;
+ (void)fprintf(stderr, "%s => %s %llu/%llu bytes %d%% "
+ "written\n", from, to, (unsigned long long)total,
+ (unsigned long long)sbp->st_size, pcent);
+ }
+ }
if (nread < 0) {
warn("%s", from);
err: if (unlink(to))
- Prev by Date:
[src/netbsd-7]: src/bin/cp Pull up following revision(s) (requested by mrg in...
- Next by Date:
[src/netbsd-7]: src/doc Tickets #1103, #1117 - #1121, #1123, #1124, #1126, #1...
- Previous by Thread:
[src/netbsd-7]: src/bin/cp Pull up following revision(s) (requested by mrg in...
- Next by Thread:
[src/netbsd-7]: src/doc Tickets #1103, #1117 - #1121, #1123, #1124, #1126, #1...
- Indexes:
Home |
Main Index |
Thread Index |
Old Index