Whamcloud - gitweb
logsave: Don't send the ^A and ^B delimiters to the console
authorTheodore Ts'o <tytso@mit.edu>
Mon, 29 Jun 2009 18:58:07 +0000 (14:58 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 29 Jun 2009 19:09:29 +0000 (15:09 -0400)
Some terminal programs may print wierd characters when they see the
\001 or \002 characters.  So filter them out if the -s option
(skip_mode) is enabled.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/logsave.c

index 81ac9f6..43eb6f7 100644 (file)
@@ -74,13 +74,32 @@ static int write_all(int fd, const char *buf, size_t count)
 
 static void send_output(const char *buffer, int c, int flag)
 {
-       char    *n;
+       const char      *cp;
+       char            *n;
+       int             cnt, d, del;
 
        if (c == 0)
                c = strlen(buffer);
 
-       if (flag & SEND_CONSOLE)
-               write_all(1, buffer, c);
+       if (flag & SEND_CONSOLE) {
+               cnt = c;
+               cp = buffer;
+               while (cnt) {
+                       del = 0;
+                       for (d=0; d < cnt; d++) {
+                               if (skip_mode &&
+                                   (cp[d] == '\001' || cp[d] == '\002')) {
+                                       del = 1;
+                                       break;
+                               }
+                       }
+                       write_all(1, cp, d);
+                       if (del)
+                               d++;
+                       cnt -= d;
+                       cp += d;
+               }
+       }
        if (!(flag & SEND_LOG))
                return;
        if (outfd > 0)