vfs: do bulk POLL* -> EPOLL* replacement
[linux-2.6-block.git] / kernel / trace / trace.c
index 32c069bbf41bd8ac73eb05f13484cac254d3e9a7..20a2300ae4e8671629e9b516b389c0e6c4dee2db 100644 (file)
@@ -530,8 +530,6 @@ int trace_pid_write(struct trace_pid_list *filtered_pids,
                ubuf += ret;
                cnt -= ret;
 
-               parser.buffer[parser.idx] = 0;
-
                ret = -EINVAL;
                if (kstrtoul(parser.buffer, 0, &val))
                        break;
@@ -1236,18 +1234,18 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
                        cnt--;
                }
 
+               parser->idx = 0;
+
                /* only spaces were written */
-               if (isspace(ch)) {
+               if (isspace(ch) || !ch) {
                        *ppos += read;
                        ret = read;
                        goto out;
                }
-
-               parser->idx = 0;
        }
 
        /* read the non-space input */
-       while (cnt && !isspace(ch)) {
+       while (cnt && !isspace(ch) && ch) {
                if (parser->idx < parser->size - 1)
                        parser->buffer[parser->idx++] = ch;
                else {
@@ -1262,12 +1260,14 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
        }
 
        /* We either got finished input or we have to wait for another call. */
-       if (isspace(ch)) {
+       if (isspace(ch) || !ch) {
                parser->buffer[parser->idx] = 0;
                parser->cont = false;
        } else if (parser->idx < parser->size - 1) {
                parser->cont = true;
                parser->buffer[parser->idx++] = ch;
+               /* Make sure the parsed string always terminates with '\0'. */
+               parser->buffer[parser->idx] = 0;
        } else {
                ret = -EINVAL;
                goto out;
@@ -5623,13 +5623,13 @@ trace_poll(struct trace_iterator *iter, struct file *filp, poll_table *poll_tabl
 
        /* Iterators are static, they should be filled or empty */
        if (trace_buffer_iter(iter, iter->cpu_file))
-               return POLLIN | POLLRDNORM;
+               return EPOLLIN | EPOLLRDNORM;
 
        if (tr->trace_flags & TRACE_ITER_BLOCK)
                /*
                 * Always select as readable when in blocking mode
                 */
-               return POLLIN | POLLRDNORM;
+               return EPOLLIN | EPOLLRDNORM;
        else
                return ring_buffer_poll_wait(iter->trace_buffer->buffer, iter->cpu_file,
                                             filp, poll_table);