You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Tyler MacDonald <ty...@yi.org> on 2006/05/17 01:20:10 UTC
apr_stat / apr_file_info_get misbehaving?
I'm getting this output:
APR: file is 0 bytes
stat: file is 21296 bytes
From this code:
bzero(&finfo, sizeof(finfo));
bzero(&sinfo, sizeof(sinfo));
if((rv = apr_stat(&finfo, path, APR_FINFO_NORM, p)) != APR_SUCCESS) {
fprintf(stderr, "Failed to retrieve file information for %s\n", path);
return NULL;
}
printf("APR: file is %lu bytes\n", finfo.size);
stat(path, &sinfo);
printf("stat: file is %llu bytes\n", sinfo.st_size);
Even if I change APR_FINFO_NORM to APR_FINFO_SIZE, or even open the file
first and use apr_file_info_get, APR always returns "size" as zero. Does
anybody know what could cause this?
Thanks,
Tyler
Re: apr_stat / apr_file_info_get misbehaving?
Posted by Tyler MacDonald <ty...@yi.org>.
Davi Arnaut <da...@haxent.com.br> wrote:
> > I'm getting this output:
> >
> > APR: file is 0 bytes
> > stat: file is 21296 bytes
> >
> > From this code:
> >
> > bzero(&finfo, sizeof(finfo));
> > bzero(&sinfo, sizeof(sinfo));
> >
> > if((rv = apr_stat(&finfo, path, APR_FINFO_NORM, p)) != APR_SUCCESS) {
> > fprintf(stderr, "Failed to retrieve file information for %s\n", path);
> > return NULL;
> > }
> >
> > printf("APR: file is %lu bytes\n", finfo.size);
> >
> > stat(path, &sinfo);
> >
> > printf("stat: file is %llu bytes\n", sinfo.st_size);
> >
> >
> > Even if I change APR_FINFO_NORM to APR_FINFO_SIZE, or even open the file
> > first and use apr_file_info_get, APR always returns "size" as zero. Does
> > anybody know what could cause this?
> >
>
> Platform (win32/linux/..) ?
Debian GNU/Linux.
$ ldd /usr/lib/libapr-0.so
linux-gate.so.1 => (0xffffe000)
libdb-4.3.so => /usr/lib/libdb-4.3.so (0xa7e49000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0xa7e28000)
librt.so.1 => /lib/tls/librt.so.1 (0xa7e20000)
libm.so.6 => /lib/tls/libm.so.6 (0xa7dfa000)
libcrypt.so.1 => /lib/tls/libcrypt.so.1 (0xa7dcc000)
libnsl.so.1 => /lib/tls/libnsl.so.1 (0xa7db6000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0xa7da4000)
libdl.so.2 => /lib/tls/libdl.so.2 (0xa7d9f000)
libc.so.6 => /lib/tls/libc.so.6 (0xa7c67000)
/lib/ld-linux.so.2 (0x75555000)
Thanks,
Tyler
Re: apr_stat / apr_file_info_get misbehaving?
Posted by Davi Arnaut <da...@haxent.com.br>.
On Tue, 16 May 2006 16:20:10 -0700
Tyler MacDonald <ty...@yi.org> wrote:
> I'm getting this output:
>
> APR: file is 0 bytes
> stat: file is 21296 bytes
>
> From this code:
>
> bzero(&finfo, sizeof(finfo));
> bzero(&sinfo, sizeof(sinfo));
>
> if((rv = apr_stat(&finfo, path, APR_FINFO_NORM, p)) != APR_SUCCESS) {
> fprintf(stderr, "Failed to retrieve file information for %s\n", path);
> return NULL;
> }
>
> printf("APR: file is %lu bytes\n", finfo.size);
>
> stat(path, &sinfo);
>
> printf("stat: file is %llu bytes\n", sinfo.st_size);
>
>
> Even if I change APR_FINFO_NORM to APR_FINFO_SIZE, or even open the file
> first and use apr_file_info_get, APR always returns "size" as zero. Does
> anybody know what could cause this?
>
Platform (win32/linux/..) ?
--
Davi Arnaut
Re: apr_stat / apr_file_info_get misbehaving?
Posted by Tyler MacDonald <ty...@yi.org>.
William A. Rowe, Jr. <wr...@rowe-clan.net> wrote:
> First, assure us finfo is an apr_fileinfo_t and not a unixish finfo_t?
Well, an apr_finfo_t actually. :)
> > printf("APR: file is %lu bytes\n", finfo.size);
> You might be interested in APR_OFF_T_FMT (I think that's the name)
I'll check into that, thanks!
> Are you sure apr_off_t fits in %lu in your ./configure'ation?
Yup. I did %llu the first time, but "-Wall -Werror" wouldn't let me.
:-)
> Uhm - need to tell us if finfo.valid & APR_FINFO_SIZE is set or not.
>
> _NORM includes _SIZE fwiw.
... after some more testing, I've found the problem: I'm compiling
my application with large file support, but libapr-0 was *not* compiled with
large file support. APR's headers seem to have some problem with having
"-D_FILE_OFFSET_BITS=64" passed into them if apr support was not enabled.
This really sucks!
I've attached the test I used to prove this.
If I compile it with this:
$ make apr_stat.t LDFLAGS=-lapr-0 CPPFLAGS='-I/usr/include/apr-0 -D_FILE_OFFSET_BITS=64' CFLAGS='-Werror -Wall'
I get this running it:
$ ./apr_stat.t /home/faraway/test.torrent
1..2
not ok 1 - stat and apr_stat return same size (21296 != 0)
ok 2 - finfo.valid includes APR_FINFO_SIZE
If I compile it with this (and change the %llu on line 75 to a %lu):
$ make apr_stat.t LDFLAGS=-lapr-0 CPPFLAGS='-I/usr/include/apr-0' CFLAGS='-Werror -Wall'
I get this instead:
$ ./apr_stat.t /home/faraway/test.torrent
1..2
ok 1 - stat and apr_stat return same size (21296)
ok 2 - finfo.valid includes APR_FINFO_SIZE
I guess this is a small bug in the apr header files, where they
listen to the environment of the application they're being compiled against,
instead of just the environment of APR when *it* was compiled.
I'm working on porting a lot of glibc code over to APR right now;
the APR_OFF_T_FMT mentioned above will probably help me work around this
problem.
It seems like apr_stat() is the only function that can't deal with
the application needing large file support (whether or not APR has it), but
I'm a bit concerned; could anything else in APR break because of this?
Thanks,
Tyler
Re: apr_stat / apr_file_info_get misbehaving?
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Tyler MacDonald wrote:
> I'm getting this output:
>
> APR: file is 0 bytes
> stat: file is 21296 bytes
>
> From this code:
>
> bzero(&finfo, sizeof(finfo));
> bzero(&sinfo, sizeof(sinfo));
First, assure us finfo is an apr_fileinfo_t and not a unixish finfo_t?
> if((rv = apr_stat(&finfo, path, APR_FINFO_NORM, p)) != APR_SUCCESS) {
> fprintf(stderr, "Failed to retrieve file information for %s\n", path);
> return NULL;
> }
>
> printf("APR: file is %lu bytes\n", finfo.size);
You might be interested in APR_OFF_T_FMT (I think that's the name)
Are you sure apr_off_t fits in %lu in your ./configure'ation?
> Even if I change APR_FINFO_NORM to APR_FINFO_SIZE, or even open the file
> first and use apr_file_info_get, APR always returns "size" as zero. Does
> anybody know what could cause this?
Uhm - need to tell us if finfo.valid & APR_FINFO_SIZE is set or not.
_NORM includes _SIZE fwiw.
Bill