Re: [PATCH 5/5] tracing: add binary buffer files for use withsplice

From: Steven Rostedt
Date: Tue Mar 03 2009 - 22:43:51 EST



On Tue, 3 Mar 2009, Andrew Morton wrote:

> On Tue, 03 Mar 2009 21:49:26 -0500 Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> > +static ssize_t
> > +tracing_buffers_read(struct file *filp, char __user *ubuf,
> > + size_t count, loff_t *ppos)
> > +{
> > + struct ftrace_buffer_info *info = filp->private_data;
> > + unsigned int pos;
> > + ssize_t ret;
> > + size_t size;
> > +
> > + /* Do we have previous read data to read? */
> > + if (info->read < PAGE_SIZE)
> > + goto read;
> > +
> > + info->read = 0;
> > +
> > + ret = ring_buffer_read_page(info->tr->buffer,
> > + &info->spare,
> > + count,
> > + info->cpu, 0);
> > + if (ret < 0)
> > + return 0;
> > +
> > + pos = ring_buffer_page_len(info->spare);
> > +
> > + if (pos < PAGE_SIZE)
> > + memset(info->spare + pos, 0, PAGE_SIZE - pos);
> > +
> > +read:
> > + size = PAGE_SIZE - info->read;
> > + if (size > count)
> > + size = count;
> > +
> > + ret = copy_to_user(ubuf, info->spare + info->read, size);
> > + if (ret)
> > + return -EFAULT;
>
> Conventionally a read() system call will return the number of bytes
> copied, and will only return -EFOO if the number of bytes copied was
> zero.
>
> Lots of parts of the kernel break this, but it's usually device drivers
> and scruffy pseudo files, in which case a partial file read doesn't
> make much sense. This doesn't make the broken behaviour right, but at
> least we have a bit of a weaselly excuse in that case.
>

I just went by the read man page:

EFAULT buf is outside your accessible address space.

-- Steve

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/