From: Alexander Aring <alex.aring@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/2] fs: add pread and pwrite functions
Date: Mon, 18 Feb 2013 16:13:00 +0100 [thread overview]
Message-ID: <20130218151219.GA1077@x61s.8.8.8.8> (raw)
In-Reply-To: <20130218101733.GP1906@pengutronix.de>
Hi Sascha,
On Mon, Feb 18, 2013 at 11:17:33AM +0100, Sascha Hauer wrote:
> On Sun, Feb 17, 2013 at 10:05:01PM +0100, Alexander Aring wrote:
> > Add pread and pwrite functions.
> >
> > Split read and write functions to save some space.
> > The functions pread and pwrite saves and sets the file
> > position to a given offset and restore them afterwards.
> >
> > Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> > ---
> > fs/fs.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++----------
> > include/fs.h | 2 ++
> > 2 files changed, 77 insertions(+), 14 deletions(-)
> >
> > diff --git a/fs/fs.c b/fs/fs.c
> > index 48d1c89..497a2ea 100644
> > --- a/fs/fs.c
> > +++ b/fs/fs.c
> > @@ -754,17 +754,12 @@ int ioctl(int fd, int request, void *buf)
> > return ret;
> > }
> >
> > -ssize_t read(int fd, void *buf, size_t count)
> > +static ssize_t __read(FILE *f, void *buf, size_t count)
> > {
> > struct device_d *dev;
> > struct fs_driver_d *fsdrv;
> > - FILE *f;
> > int ret;
> >
> > - if (check_fd(fd))
> > - return -errno;
> > -
> > - f = &files[fd];
> > dev = f->dev;
> >
> > fsdrv = dev_to_fs_driver(dev);
> > @@ -777,18 +772,34 @@ ssize_t read(int fd, void *buf, size_t count)
> >
> > ret = fsdrv->read(dev, f, buf, count);
> >
> > - if (ret > 0)
> > - f->pos += ret;
> > if (ret < 0)
> > errno = -ret;
> > return ret;
> > }
> > -EXPORT_SYMBOL(read);
> > +EXPORT_SYMBOL(pread);
> >
> > -ssize_t write(int fd, const void *buf, size_t count)
> > +ssize_t pread(int fd, void *buf, size_t count, loff_t offset)
> > +{
> > + loff_t pos;
> > + FILE *f;
> > + int ret;
> > +
> > + if (check_fd(fd))
> > + return -errno;
> > +
> > + f = &files[fd];
> > +
> > + pos = f->pos;
> > + f->pos = offset;
> > + ret = __read(f, buf, count);
> > + f->pos = pos;
> > +
> > + return ret;
> > +}
> > +EXPORT_SYMBOL(pread);
>
> pread is exported twice with this patch. I fixed this while applying.
>
Ooops, sry. Thanks for applying.
Regards
Alex
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-02-18 15:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-17 21:04 [RFC PATCH v2 0/2] " Alexander Aring
2013-02-17 21:05 ` [PATCH 1/2] fs: fix return type of read Alexander Aring
2013-02-17 21:05 ` [PATCH 2/2] fs: add pread and pwrite functions Alexander Aring
2013-02-18 10:17 ` Sascha Hauer
2013-02-18 15:13 ` Alexander Aring [this message]
2013-02-19 19:33 ` Sascha Hauer
2013-02-19 20:30 ` Alexander Aring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130218151219.GA1077@x61s.8.8.8.8 \
--to=alex.aring@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox