Re: vfs changes for pread/pwrite

Linus Torvalds (torvalds@transmeta.com)
Mon, 13 Oct 1997 08:37:34 -0700 (PDT)


On Mon, 13 Oct 1997, Richard Henderson wrote:
>
> Single Unix adds two new system calls, pread and pwrite, that take
> an extra argument for the location to do the I/O. The "p" stands
> for "positioned" I guess.

This is something that I've wanted for other reasons for a long time:
async IO. When doing aio with threads rather than with special aio system
calls the thread must not change the file position in the parent, so we
need the pio versions regardless of any single-UNIX issues.

> I've got patches partly done, but it is a lot of work changing things
> up, and I thought I'd run things by folks before I finish. I've
> changed the VFS read/write functions to be
>
> ssize_t (*read)(struct file *file, char *buf, size_t n, loff_t *ppos)
>
> and similar for write. In the normal case ppos==&file->f_pos, and
> for pread, ppos points to a stack variable. This is also how non-
> seekable files know to return -ESPIPE.

Fair enough.

> Note the actual use of the posix types. Is there any reason why
> we weren't using these before? I've found quite a number of places
> so far that the code doesn't even use long, but int. True, it isn't
> going to be every day that someone writes more than 2GB in one syscall,
> but it seems Wrong in any case.

There's nothing wrong with the POSIX types, it just wasn't ever very high
on my priority of things to fix. The above looks fine.

> Oh, one last thing. Am I right in assuming that file->f_dentry->d_inode
> is always there? You'll notice I got rid of the inode argument like
> many of the other VFS functions have recently.

Yes. This was a cleanup that needed to be done eventually anyway.

Linus