Revert "printk: remove unused code from kernel/printk.c"
authorArve Hjønnevåg <arve@android.com>
Fri, 16 Jan 2009 03:07:27 +0000 (19:07 -0800)
committerColin Cross <ccross@android.com>
Thu, 30 Sep 2010 00:49:19 +0000 (17:49 -0700)
This reverts commit acff181d3574244e651913df77332e897b88bff4.

kernel/printk.c

index b11cffec38fc85c380a747d72c5c60ac8685f0ec..33d6dcdb4909af11f2168b152b66bbb79fe49c90 100644 (file)
@@ -265,6 +265,60 @@ static inline void boot_delay_msec(void)
 }
 #endif
 
+/*
+ * Return the number of unread characters in the log buffer.
+ */
+static int log_buf_get_len(void)
+{
+       return logged_chars;
+}
+
+/*
+ * Copy a range of characters from the log buffer.
+ */
+int log_buf_copy(char *dest, int idx, int len)
+{
+       int ret, max;
+       bool took_lock = false;
+
+       if (!oops_in_progress) {
+               spin_lock_irq(&logbuf_lock);
+               took_lock = true;
+       }
+
+       max = log_buf_get_len();
+       if (idx < 0 || idx >= max) {
+               ret = -1;
+       } else {
+               if (len > max)
+                       len = max;
+               ret = len;
+               idx += (log_end - max);
+               while (len-- > 0)
+                       dest[len] = LOG_BUF(idx + len);
+       }
+
+       if (took_lock)
+               spin_unlock_irq(&logbuf_lock);
+
+       return ret;
+}
+
+/*
+ * Commands to do_syslog:
+ *
+ *     0 -- Close the log.  Currently a NOP.
+ *     1 -- Open the log. Currently a NOP.
+ *     2 -- Read from the log.
+ *     3 -- Read all messages remaining in the ring buffer.
+ *     4 -- Read and clear all messages remaining in the ring buffer
+ *     5 -- Clear ring buffer.
+ *     6 -- Disable printk's to console
+ *     7 -- Enable printk's to console
+ *     8 -- Set level of messages printed to console
+ *     9 -- Return number of unread characters in the log buffer
+ *     10 -- Return size of the log buffer
+ */
 int do_syslog(int type, char __user *buf, int len, bool from_file)
 {
        unsigned i, j, limit, count;