git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Replacing the system call pread() with lseek()/xread()/lseek() sequence.

From
Nicolas Pitre <nico@cam.org>
Date
Jan 9, 2007, 19:48 UTC
Message-ID
<Pine.LNX.4.64.0701091446150.4964@xanadu.home>
In-Reply-To
<11683687161239-git-send-email-@videotron.ca>
On Tue, 9 Jan 2007, Stefan-W. Hahn wrote:
Show 11 quoted lines
> --- /dev/null
> +++ b/compat/pread.c
> @@ -0,0 +1,15 @@
> +#include "../git-compat-util.h"
> +
> +ssize_t git_pread(int fd,void *buf,size_t count,off_t offset)
> +{
> +        off_t current_offset = lseek(fd, 0, SEEK_CUR);
> +
> +        if (lseek(fd, offset, SEEK_SET) < 0)
> +                return EINVAL;
You certainly wanted to return -1 here.
Show 5 quoted lines
> +
> +        ssize_t rc=xread(fd, buf, count);
> +
> +        if (current_offset != lseek(fd, current_offset, SEEK_SET))
> +                return EINVAL;
Ditto here.
> +        return rc;
> +}
Nicolas
Message 1 of 1 in “Re: [PATCH] Replacing the system call pread() with lseek()/xread()/lseek() sequence.”
  1. Nicolas PitreJan 9, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.