Re: [PATCH] make swsusp produce nicer screen output

Stefan Seyfried
2004-08-21T23:43:11Z

Hi,

Erik Rigtorp wrote:
> Hi!
>
> I made a small patch that makes swsusp produce a bit nicer screen output,
> it's still a little rough though.

generally not a bad idea, but....

> diff -Nru linux-2.6.8.1-mm2/kernel/power/swsusp.c linux-2.6.8.1-mm2-erkki/kernel/power/swsusp.c
> --- linux-2.6.8.1-mm2/kernel/power/swsusp.c 2004-08-20 17:10:58.000000000 +0200
> +++ linux-2.6.8.1-mm2-erkki/kernel/power/swsusp.c 2004-08-20 16:13:29.000000000 +0200
> @@ -296,15 +296,16 @@
> {
> int error = 0;
> int i;
> -
> - printk( "Writing data to swap (%d pages): ", nr_copy_pages );
> + int mod = nr_copy_pages / 100;
> +
> + printk( "Writing data to swap (%d pages): ", nr_copy_pages );
> for (i = 0; i < nr_copy_pages && !error; i++) {
> - if (!(i%100))
> - printk( "." );
> + if (!(i%mod))
> + printk( "\b\b\b\b%3d%%", i / mod );

what will happen here if nr_copy_pages < 100?

> error = write_page((pagedir_nosave+i)->address,
> &((pagedir_nosave+i)->swap_address));
> }
> - printk(" %d Pages done.\n",i);
> + printk("\b\b\b\bdone\n");
> return error;
> }
>
> @@ -1150,14 +1151,15 @@
> struct pbe * p;
> int error;
> int i;
> -
> + int mod = nr_copy_pages / 100;
> +
> if ((error = swsusp_pagedir_relocate()))
> return error;
>
> - printk( "Reading image data (%d pages): ", nr_copy_pages );
> + printk( "Reading image data (%d pages): ", nr_copy_pages );
> for(i = 0, p = pagedir_nosave; i < nr_copy_pages && !error; i++, p++) {
> - if (!(i%100))
> - printk( "." );
> + if (!(i%mod))
> + printk( "\b\b\b\b%3d%%", i / mod );

...and here...

> error = bio_read_page(swp_offset(p->swap_address),
> (void *)p->address);
> }

Stefan