Re: Make pipe data structure be a circular list of pages, rather

From: Linus Torvalds
Date: Fri Jan 14 2005 - 16:39:31 EST




On Fri, 14 Jan 2005, Ingo Oeser wrote:
>
> But we have currently no suitable interface for this.
>
> We have socketpair(), we have pipe(), but we don't have
> dev_pipe() creating a pipe with the driver sitting in the middle.

Not exactly that, no.

But realize that what you are asking for is actually a _much_ simpler
thing than even "fifo_open()". What you ask for (if somebody really starts
doing this, and I'd love to see it) is not much more difficult than

int device_open(struct inode *inode, struct file *filp)
{
if (!pipe_new(inode))
return -ENOMEM;

/* The hardware is a writer */
PIPE_WRITERS(*inode)++;

/* The new fd is a reader of the data the hardware generates */
file->f_op = read_fifo_fops;

/*
* This starts the hardware capture - although in real
* life there might be a "start it" ioctl or something
* that actually does that together with the parameters
* for capture..
*/
start_capture_process(inode);

return 0;
}

ie we're definitely not talking rocket science here.

(Yes, I'm sure there are some details missing in the above, but you get
the idea: the infrastructure really _is_ pretty much there, and any lack
comes from the fact that nobody has actually ever _used_ it).

> Usage: "processing devices" like crypto processors, DSPs,
> MPEG-Encoding/-Decoding hardware, smart cards and the like.
>
> Synopsys: int dev_pipe(const char *dev_path, int fd_vec[2]);

No, I do NOT think that's what you'd want.

What you want is more of a

fd = open("/dev/mpeginput", O_RDONLY);

and then that device driver open just does the thing outlined above.

> We also don't have wire_fds(), which would wire up two fds by
> connecting the underlying file pointers with each other and closing the fds.

But that is _exactly_ what splice() would do.

So you could have the above open of "/dev/mpeginput", and then you just
sit and splice the result into a file or whatever.

See?

(Or maybe it's me who doesn't see what it is you want).

Linus
-
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/