Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

badblocks: hide the cursor during progress #206

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions misc/badblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ extern int optind;

static const char * program_name = "badblocks";
static const char * done_string = N_("done \n");
static const char * curs_off = "\e[?25l";
static const char * curs_on = "\e[?25h";

static int v_flag; /* verbose */
static int w_flag; /* do r/w test: 0=no, 1=yes,
Expand Down Expand Up @@ -125,6 +127,11 @@ static ext2_badblocks_iterate bb_iter = NULL;

enum error_types { READ_ERROR, WRITE_ERROR, CORRUPTION_ERROR };

void cursor_on(void)
{
fputs(curs_on, stderr);
}

static void *allocate_buffer(size_t size)
{
void *ret = 0;
Expand Down Expand Up @@ -1312,6 +1319,9 @@ int main (int argc, char ** argv)
else
out = stdout;

if (! atexit(cursor_on))
fputs(curs_off, stderr);

errcode = ext2fs_badblocks_list_create(&bb_list,0);
if (errcode) {
com_err(program_name, errcode, "%s",
Expand Down