]> Zhao Yanbai Git Server - minix.git/commitdiff
Need separate 'prev_next' pointers for kernel and TTY.
authorPhilip Homburg <philip@cs.vu.nl>
Mon, 25 Feb 2008 11:53:37 +0000 (11:53 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Mon, 25 Feb 2008 11:53:37 +0000 (11:53 +0000)
drivers/log/diag.c

index 3e72a59f9222024afcaafe9ea3f7ae79576e9227..eb8da9e0001e64c2e406fa8c6bd8c99e5b14c0f2 100644 (file)
@@ -26,20 +26,26 @@ message *m;                                 /* notification message */
 /* Notification for a new kernel message. */
   struct kmessages kmess;              /* entire kmess structure */
   char print_buf[KMESS_BUF_SIZE];      /* copy new message here */
-  static int prev_next = 0;
   int bytes;
   int i, r;
+  int *prev_nextp;
+
+  static int kernel_prev_next = 0;
+  static int tty_prev_next = 0;
 
   if (m->m_source == TTY_PROC_NR)
   {
        cp_grant_id_t gid;
        message mess;
 
+       prev_nextp= &tty_prev_next;
        gid= cpf_grant_direct(TTY_PROC_NR, (vir_bytes)&kmess, sizeof(kmess),
                CPF_WRITE);
        if (gid == -1)
        {
+#if 0
                report("LOG","cpf_grant_direct failed for TTY", errno);
+#endif
                return EDONTREPLY;
        }
 
@@ -63,6 +69,7 @@ message *m;                                   /* notification message */
                report("LOG","couldn't get copy of kmessages", r);
                return EDONTREPLY;
        }
+       prev_nextp= &kernel_prev_next;
   }
 
   /* Print only the new part. Determine how many new bytes there are with 
@@ -72,8 +79,9 @@ message *m;                                   /* notification message */
    * Check for size being positive, the buffer might as well be emptied!
    */
   if (kmess.km_size > 0) {
-      bytes = ((kmess.km_next + KMESS_BUF_SIZE) - prev_next) % KMESS_BUF_SIZE;
-      r=prev_next;                             /* start at previous old */ 
+      bytes = ((kmess.km_next + KMESS_BUF_SIZE) - (*prev_nextp)) %
+       KMESS_BUF_SIZE;
+      r= *prev_nextp;                          /* start at previous old */ 
       i=0;
       while (bytes > 0) {                      
           print_buf[i] = kmess.km_buf[(r%KMESS_BUF_SIZE)];
@@ -89,7 +97,7 @@ message *m;                                   /* notification message */
   /* Almost done, store 'next' so that we can determine what part of the
    * kernel messages buffer to print next time a notification arrives.
    */
-  prev_next = kmess.km_next;
+  *prev_nextp = kmess.km_next;
   return EDONTREPLY;
 }