aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-09-18 13:27:45 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-09-18 13:27:45 +0000
commitf6d42e679369f55c11463ba8d76dc0c1c8b15d07 (patch)
tree9060bb449a6a4f5a933d62844976a400fbc153ed
parent4b2a0426fd647a7e2ae8b6dfeba53e4f9939a871 (diff)
parent869e8201b51136266d67cd9458af455620efa07f (diff)
downloadxen-f6d42e679369f55c11463ba8d76dc0c1c8b15d07.tar.gz
xen-f6d42e679369f55c11463ba8d76dc0c1c8b15d07.tar.bz2
xen-f6d42e679369f55c11463ba8d76dc0c1c8b15d07.zip
bitkeeper revision 1.436 (3f69b2d120CU1z4hbX7WxfOeof-Srg)
Merge scramble.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk into scramble.cl.cam.ac.uk:/local/scratch/kaf24/xeno
-rw-r--r--xen/common/kernel.c72
1 files changed, 43 insertions, 29 deletions
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 9c0bb47dbd..ac80a5ff3f 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -538,44 +538,58 @@ int console_export(char *str, int len)
long do_console_write(char *str, unsigned int count)
{
#define SIZEOF_BUF 256
- unsigned char safe_str[SIZEOF_BUF];
- unsigned char exported_str[SIZEOF_BUF+1];
+ unsigned char safe_str[SIZEOF_BUF+1];
+ unsigned char exported_str[SIZEOF_BUF+2];
unsigned char dom_id[5];
+ unsigned char *p;
unsigned long flags;
- int i=0;
- int j=0;
- unsigned char prev = '\n';
+ int j;
- if ( count > SIZEOF_BUF ) count = SIZEOF_BUF;
+ if ( count == 0 )
+ return 0;
+
+ if ( count > SIZEOF_BUF )
+ count = SIZEOF_BUF;
if ( copy_from_user(safe_str, str, count) )
return -EFAULT;
+ safe_str[count] = '\0';
- spin_lock_irqsave(&console_lock, flags);
-
- __putstr("DOM");
- sprintf(dom_id, "%d", current->domain);
- __putstr(dom_id);
- __putstr(": ");
-
- for ( i = 0; i < count; i++ )
+ p = safe_str;
+ while ( *p != '\0' )
{
- exported_str[j++]=safe_str[i];
-
- if ( !safe_str[i] ) break;
- putchar(prev = safe_str[i]);
+ j = 0;
+
+ spin_lock_irqsave(&console_lock, flags);
+
+ __putstr("DOM");
+ sprintf(dom_id, "%d", current->domain);
+ __putstr(dom_id);
+ __putstr(": ");
+
+ while ( (*p != '\0') && (*p != '\n') )
+ {
+ exported_str[j++] = *p;
+ putchar(*p);
+ p++;
+ }
+
+ if ( *p == '\n' )
+ p++;
+
+ putchar('\n');
+
+ spin_unlock_irqrestore(&console_lock, flags);
+
+ if ( current->domain != 0 )
+ {
+ exported_str[j++] = '\n';
+ exported_str[j++] = '\0';
+ console_export(exported_str, j);
+ }
}
-
- if ( prev != '\n' ) putchar('\n');
-
- spin_unlock_irqrestore(&console_lock, flags);
-
- exported_str[j++]='\0';
-
- if ( current->domain != 0 )
- console_export(exported_str, j);
-
- return(0);
+
+ return 0;
}