mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Alexander Aring <alex.aring@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/4] fs: add pread and pwrite functions
Date: Thu, 14 Feb 2013 22:13:05 +0100	[thread overview]
Message-ID: <20130214211305.GF1906@pengutronix.de> (raw)
In-Reply-To: <1360847311-16931-2-git-send-email-alex.aring@gmail.com>

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@gmail.com>
> ---
>  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.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

  reply	other threads:[~2013-02-14 21:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14 13:08 [PATCH 1/4] fs: fix return type of read Alexander Aring
2013-02-14 13:08 ` [PATCH 2/4] fs: add pread and pwrite functions Alexander Aring
2013-02-14 21:13   ` Sascha Hauer [this message]
2013-02-14 22:23     ` Alexander Aring
2013-02-14 13:08 ` [PATCH 3/4] nandtest: use new " Alexander Aring
2013-02-14 13:08 ` [PATCH 4/4] nandtest: fix length calculation 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=20130214211305.GF1906@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=alex.aring@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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