From: Harald Hoyer Date: Thu, 16 Aug 2018 09:14:11 +0000 (+0200) Subject: logtee: reduce output X-Git-Tag: 049~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f59664a01fa9b525e211fbcb837bf8b54cac9acb;p=thirdparty%2Fdracut.git logtee: reduce output --- diff --git a/logtee.c b/logtee.c index 2f1937d47..2690e72d1 100644 --- a/logtee.c +++ b/logtee.c @@ -6,6 +6,8 @@ #include #include +#define BUFLEN 4096 + int main(int argc, char *argv[]) { @@ -25,9 +27,11 @@ main(int argc, char *argv[]) fprintf(stderr, "Logging to %s: ", argv[1]); + slen = 0; + do { len = splice(STDIN_FILENO, NULL, fd, NULL, - 65536, SPLICE_F_MOVE); + BUFLEN, SPLICE_F_MOVE); if (len < 0) { if (errno == EAGAIN) @@ -37,10 +41,14 @@ main(int argc, char *argv[]) } else if (len == 0) break; - fprintf(stderr, ".", len); + slen += len; + if ((slen/BUFLEN) > 0) { + fprintf(stderr, "."); + } + slen = slen % BUFLEN; + } while (1); close(fd); fprintf(stderr, "\n"); exit(EXIT_SUCCESS); -} - +} \ No newline at end of file