View | Details | Raw Unified | Return to bug 225993 | Differences between
and this patch

Collapse All | Expand All

(-)usr.sbin/mfiutil/mfi_cmd.c (-11 / +20 lines)
Lines 29-45 Link Here
29
 * $FreeBSD$
29
 * $FreeBSD$
30
 */
30
 */
31
31
32
#include <sys/errno.h>
32
#include <sys/param.h>
33
#include <sys/ioctl.h>
33
#include <sys/ioctl.h>
34
#include <sys/param.h>
35
#include <sys/sysctl.h>
34
#include <sys/sysctl.h>
36
#include <sys/uio.h>
35
#include <sys/uio.h>
37
36
38
#include <err.h>
37
#include <err.h>
38
#include <errno.h>
39
#include <fcntl.h>
39
#include <fcntl.h>
40
#include <stdio.h>
40
#include <stdio.h>
41
#include <stdlib.h>
41
#include <stdlib.h>
42
#include <string.h>
42
#include <string.h>
43
#include <time.h>
43
#include <unistd.h>
44
#include <unistd.h>
44
45
45
#include "mfiutil.h"
46
#include "mfiutil.h"
Lines 309-332 Link Here
309
	return (open(path, acs));
310
	return (open(path, acs));
310
}
311
}
311
312
313
static void
314
print_time_humanized(uint seconds)
315
{
316
317
	if (seconds > 3600)
318
		printf("%u:", seconds / 3600);
319
	if (seconds > 60) {
320
		seconds %= 3600;
321
		printf("%02u:%02u", seconds / 60, seconds % 60);
322
	} else
323
		printf("%us", seconds);
324
}
325
312
void
326
void
313
mfi_display_progress(const char *label, struct mfi_progress *prog)
327
mfi_display_progress(const char *label, struct mfi_progress *prog)
314
{
328
{
315
	uint seconds;
329
	uint seconds;
316
330
317
	printf("%s: %.2f%% complete, after %ds", label,
331
	printf("%s: %.2f%% complete after ", label,
318
	    (float)prog->progress * 100 / 0xffff, prog->elapsed_seconds);
332
	    (float)prog->progress * 100 / 0xffff);
333
	print_time_humanized(prog->elapsed_seconds);
319
	if (prog->progress != 0 && prog->elapsed_seconds > 10) {
334
	if (prog->progress != 0 && prog->elapsed_seconds > 10) {
320
		printf(" finished in ");
335
		printf(" finished in ");
321
		seconds = (0x10000 * (uint32_t)prog->elapsed_seconds) /
336
		seconds = (0x10000 * (uint32_t)prog->elapsed_seconds) /
322
		    prog->progress - prog->elapsed_seconds;
337
		    prog->progress - prog->elapsed_seconds;
323
		if (seconds > 3600)
338
		print_time_humanized(seconds);
324
			printf("%u:", seconds / 3600);
325
		if (seconds > 60) {
326
			seconds %= 3600;
327
			printf("%02u:%02u", seconds / 60, seconds % 60);
328
		} else
329
			printf("%us", seconds);
330
	}
339
	}
331
	printf("\n");
340
	printf("\n");
332
}
341
}

Return to bug 225993