Re: [PATCH 2/4] fs: add pread and pwrite functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sascha,

On Thu, Feb 14, 2013 at 10:13:05PM +0100, Sascha Hauer wrote:
> On Thu, Feb 14, 2013 at 02:08:29PM +0100, Alexander Aring wrote:
> > Add pread and pwrite functions.
> > 
> > These functions setting file pointer to a given
> > offset with lseek and call read or write afterwards.
> > 
> > Signed-off-by: Alexander Aring <alex.aring@xxxxxxxxx>
> > ---
> >  fs/fs.c      | 28 ++++++++++++++++++++++++++++
> >  include/fs.h |  2 ++
> >  2 files changed, 30 insertions(+)
> > 
> > diff --git a/fs/fs.c b/fs/fs.c
> > index 48d1c89..fea7e02 100644
> > --- a/fs/fs.c
> > +++ b/fs/fs.c
> > @@ -785,6 +785,20 @@ ssize_t read(int fd, void *buf, size_t count)
> >  }
> >  EXPORT_SYMBOL(read);
> >  
> > +ssize_t pread(int fd, void *buf, size_t count, loff_t offset)
> > +{
> > +	int ret;
> > +
> > +	ret = lseek(fd, offset, SEEK_SET);
> > +	if (ret < 0)
> > +		goto out;
> > +
> > +	ret = read(fd, buf, count);
> > +out:
> > +	return ret;
> > +}
> 
> The man page says that the file offset is not modified by pread/pwrite.
> If we add a standard function with a standard prototype I think it
> should have the same behaviour.
> Maybe this can be implemented similar to the current read() function
> is implemented. read() could then call pread() internally and advances
> the file offset afterwards.

Ok I will change this. Thanks.

Regards
Alex

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox


[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux