Re: [PATCH] btrfs-convert: show progress

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday 2012-09-29 03:08, Alfredo Esteban wrote:

>+	__u32 progressunit;
>+	__u32 halfprogunit;
>+	__u32 progressperc;
>+	int istty;
>+	int progress;
>+	int flagprint;
>+	float perc;
>+	char msg[128];
>+	char bar[256];
>+} progress_bar;

>+	sprintf(pb->msg, "Creating btrfs metadata");
>+	
>+	if (isatty(fileno(stdout)) != 0)
>+		pb->istty = 1;
>+	else
>+		pb->istty = 0;

	pb->istty = isatty(fileno(stdout));

>+	pb->inoinuse = ext2_fs->super->s_inodes_count
>+		- ext2_fs->super->s_free_inodes_count;
>+	pb->inocopied = 0;
>+	pb->progressunit = pb->inoinuse / PROGRESS_BAR_LENGTH;
>+	pb->halfprogunit = (int)(pb->progressunit/2);

	Pointless cast.

>+	pb->progressperc = pb->inoinuse / 100;
>+	pb->progress = 0;
>+	pb->flagprint = 0;
>+	pb->perc = 0;
>+	pb->bar[0] = '[';
>+	for (i = 1; i < PROGRESS_BAR_LENGTH+1; i++) pb->bar[i] = ' ';
>+	pb->bar[PROGRESS_BAR_LENGTH+1] = ']';
>+	pb->bar[PROGRESS_BAR_LENGTH+2] = '\0';
>+	if (pb->istty) {
>+		printf("\e[?25l"); // hide the cursor

I would not go to the hassle of hiding the cursor, because then you
would also have to handle SIGINT and restore the cursor there.
Just leave the cursor as-is, like everybody else.

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux