[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4857CA71.3020004@davidnewall.com>
Date: Wed, 18 Jun 2008 00:00:09 +0930
From: David Newall <davidn@...idnewall.com>
To: palani saravanan <busybeesaravanan0072003@...oo.co.in>
CC: linux-kernel@...r.kernel.org
Subject: Re: Behavior of lseek() on a fd opened with 'RDONLY' flag, when seeking
goes beyond file size.
palani saravanan wrote:
> In linux, I see that it just goes beyond the file size and returns the resulting offset.
> For example, 'rc = lseek(fd, 4L, SEEK_END);' on a file which has 5 byte contents,
> it returns rc as 9.
>
Sounds right. It's documented that way, too:
"The lseek() function allows the file offset to be set beyond the
end of the file (but this
does not change the size of the file)."
-- man 2 lseek
> I expect that it would return size of the file, i.e.) 5.
>
Only if you pass (0,SEEK_END).
> Does the file pointer internally really points to the new location.?
>
So the documentation promises.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists