You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by "William A. Rowe, Jr." <wr...@rowe-clan.net> on 2003/02/28 20:45:19 UTC

Re: apr_lstat() fails on linux for large files

Please don't make Linux's problem every APR user's headache,
such as autoindex you describe below.

Short of turning on largefile support here and now, what about a simple
APR hack?  Keep an overflow flag for apr_dir_t, and when the lstat()
call from apr_dir_read returns EOVERFLOW, set that flag but loop and
grab the next legal file.

Once we hit eof with readdir(), look at the overflow flag.  Go ahead and
return some APR_EOVERFLOW condition rather than EOF.  Unset
the flag so that if the user calls again, they will see the EOF.

Does that sound like it would solve this Linux issue without causing
every application undue pain?

Bill


At 01:23 PM 2/28/2003, Cliff Woolley wrote:

>I was trying to track down the cause of PR#17357, and came across
>something interesting-slash-annoying.
>
>mod_autoindex in Apache loops over the directory entries it's indexing
>using apr_dir_read().  Among other things, apr_dir_read() does an
>apr_lstat() call (which in turn calls apr_stat() with the APR_FINFO_LINK
>wanted flag) on the next entry in the directory.  If you have a large file
>(>2GB) in the directory, though, on linux the lstat() will fail with
>errno==EOVERFLOW (75) (Value too large for defined data type).  This
>causes the apr_lstat() to fail which causes the apr_dir_read() to fail
>which makes mod_autoindex think it's hit the end of the directory.
>
>
>Of course, if I go and explictly compile Apache with
>CFLAGS=-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64, then it works.
>
>So I guess the ultimate questions are these:
>
>(a) Why doesn't Apache automatically include largefile support?
>Performance reasons?  Shouldn't there at least be an easy ./configure
>option to turn it on?
>
>(b) If it's not turned on, shouldn't mod_autoindex detect the EOVERFLOW
>return code and special-case it?
>
>--Cliff
>
>
>http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17357



Re: apr_lstat() fails on linux for large files

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 02:11 PM 2/28/2003, Cliff Woolley wrote:
>On Fri, 28 Feb 2003, William A. Rowe, Jr. wrote:
>
>> Short of turning on largefile support here and now, what about a simple
>> APR hack?  Keep an overflow flag for apr_dir_t, and when the lstat()
>> call from apr_dir_read returns EOVERFLOW, set that flag but loop and
>> grab the next legal file.
>
>Works for me.  :)

Actually, the 'right answer' is to leave the apr_fileinfo_t ->valid bits unset
if all you can recover is the name itself ;-)  All apps *should* respect those
bits if they are looking for anything other than the name.

But I still like the general idea proposed above :-)

Bill 


Re: apr_lstat() fails on linux for large files

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 02:11 PM 2/28/2003, Cliff Woolley wrote:
>On Fri, 28 Feb 2003, William A. Rowe, Jr. wrote:
>
>> Short of turning on largefile support here and now, what about a simple
>> APR hack?  Keep an overflow flag for apr_dir_t, and when the lstat()
>> call from apr_dir_read returns EOVERFLOW, set that flag but loop and
>> grab the next legal file.
>
>Works for me.  :)

Actually, the 'right answer' is to leave the apr_fileinfo_t ->valid bits unset
if all you can recover is the name itself ;-)  All apps *should* respect those
bits if they are looking for anything other than the name.

But I still like the general idea proposed above :-)

Bill 


Re: apr_lstat() fails on linux for large files

Posted by Cliff Woolley <jw...@virginia.edu>.
On Fri, 28 Feb 2003, William A. Rowe, Jr. wrote:

> Short of turning on largefile support here and now, what about a simple
> APR hack?  Keep an overflow flag for apr_dir_t, and when the lstat()
> call from apr_dir_read returns EOVERFLOW, set that flag but loop and
> grab the next legal file.

Works for me.  :)

Re: apr_lstat() fails on linux for large files

Posted by Cliff Woolley <jw...@virginia.edu>.
On Fri, 28 Feb 2003, William A. Rowe, Jr. wrote:

> Short of turning on largefile support here and now, what about a simple
> APR hack?  Keep an overflow flag for apr_dir_t, and when the lstat()
> call from apr_dir_read returns EOVERFLOW, set that flag but loop and
> grab the next legal file.

Works for me.  :)