public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Erik Rigtorp <erik@rigtorp.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] make swsusp produce nicer screen output
Date: Fri, 20 Aug 2004 17:23:17 +0200	[thread overview]
Message-ID: <20040820152317.GA7118@linux.nu> (raw)

[-- Attachment #1: Type: text/plain, Size: 120 bytes --]

Hi!

I made a small patch that makes swsusp produce a bit nicer screen output,
it's still a little rough though.

/Erik

[-- Attachment #2: swsusp-nicer-output.patch --]
[-- Type: text/plain, Size: 1963 bytes --]

diff -Nru linux-2.6.8.1-mm2/kernel/power/disk.c linux-2.6.8.1-mm2-erkki/kernel/power/disk.c
--- linux-2.6.8.1-mm2/kernel/power/disk.c	2004-08-20 17:10:58.000000000 +0200
+++ linux-2.6.8.1-mm2-erkki/kernel/power/disk.c	2004-08-20 15:47:00.000000000 +0200
@@ -85,10 +85,17 @@
 
 static void free_some_memory(void)
 {
-	printk("Freeing memory: ");
-	while (shrink_all_memory(10000))
-		printk(".");
-	printk("|\n");
+	int i = 0;
+	char *p = "-\\|/";
+	
+	printk("Freeing memory:  ");
+	while (shrink_all_memory(10000)) {
+		printk("\b%c", p[i]);
+		i++;
+		if (i > 3)
+			i = 0;
+	}
+	printk("\bdone\n");
 }
 
 
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 );
 		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 );
 		error = bio_read_page(swp_offset(p->swap_address),
 				  (void *)p->address);
 	}

             reply	other threads:[~2004-08-20 15:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-20 15:23 Erik Rigtorp [this message]
2004-08-21 23:42 ` [PATCH] make swsusp produce nicer screen output Stefan Seyfried
2004-08-23 17:42 ` Pavel Machek
2004-08-23 20:08   ` Erik Rigtorp
2004-08-24 21:49     ` Pavel Machek
2004-08-27 10:55       ` Stefan Seyfried
2004-08-28 22:58         ` Pavel Machek
2004-08-29 13:54       ` Erik Rigtorp
2004-08-29 14:59         ` Stefan Seyfried
2004-08-29 15:20         ` Pavel Machek
2004-08-29 16:36         ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040820152317.GA7118@linux.nu \
    --to=erik@rigtorp.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox