From dev-return-16369-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Wed May 17 15:48:40 2006 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 49162 invoked from network); 17 May 2006 15:48:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 May 2006 15:48:39 -0000 Received: (qmail 18623 invoked by uid 500); 17 May 2006 15:48:38 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 18565 invoked by uid 500); 17 May 2006 15:48:37 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 18553 invoked by uid 99); 17 May 2006 15:48:37 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 May 2006 08:48:37 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [209.17.183.249] (HELO smtp1.ActiveState.com) (209.17.183.249) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 May 2006 08:48:35 -0700 Received: from smtp3.activestate.com (smtp3.activestate.com [192.168.3.19]) by smtp1.ActiveState.com (8.12.10/8.12.10) with ESMTP id k4HFmD0t007557; Wed, 17 May 2006 08:48:13 -0700 (envelope-from tyler@yi.org) Received: from pipewrench (pipewrench.activestate.com [192.168.99.112]) by smtp3.ActiveState.com (8.13.4/8.13.4) with ESMTP id k4HFmC5j005181; Wed, 17 May 2006 08:48:13 -0700 (envelope-from tyler@yi.org) Received: by pipewrench (Postfix, from userid 1000) id 35B78E0558; Wed, 17 May 2006 08:48:12 -0700 (PDT) Date: Wed, 17 May 2006 08:48:12 -0700 From: Tyler MacDonald To: "William A. Rowe, Jr." Cc: dev@apr.apache.org Subject: Re: apr_stat / apr_file_info_get misbehaving? Message-ID: <20060517154811.GC10752@yi.org> References: <20060516232009.GH14382@yi.org> <446A696D.3000907@rowe-clan.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="/9DWx/yDrRhgMJTb" Content-Disposition: inline In-Reply-To: <446A696D.3000907@rowe-clan.net> User-Agent: Mutt/1.5.11+cvs20060403 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --/9DWx/yDrRhgMJTb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline William A. Rowe, Jr. 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 --/9DWx/yDrRhgMJTb Content-Type: text/x-csrc; charset=us-ascii Content-Disposition: attachment; filename="apr_stat.t.c" #include #include #include #include #include #include int main(int argc, char ** argv) { apr_pool_t* pool; apr_pool_t* subpool; apr_pool_t* subpool2; apr_finfo_t finfo; struct stat sinfo; if(argc != 2) { printf("usage: %s file\n", argv[0]); exit(19); } if(apr_app_initialize(NULL, NULL, NULL) != APR_SUCCESS) { fprintf(stderr, "apr_app_initialize() failed!\n"); fflush(stderr); exit(20); } atexit(apr_terminate); if(apr_pool_initialize() != APR_SUCCESS) { fprintf(stderr, "apr_pool_initialize() failed!\n"); fflush(stderr); exit(2); } if(apr_pool_create(&pool, NULL) != APR_SUCCESS) { fprintf(stderr, "apr_pool_create() failed!\n"); fflush(stderr); exit(3); } if(apr_pool_create(&subpool, NULL) != APR_SUCCESS) { fprintf(stderr, "apr_pool_create(subpool) failed!\n"); fflush(stderr); exit(4); } if(apr_pool_create(&subpool2, NULL) != APR_SUCCESS) { fprintf(stderr, "apr_pool_create(subpool) failed!\n"); fflush(stderr); exit(4); } bzero(&finfo, sizeof(apr_finfo_t)); bzero(&sinfo, sizeof(struct stat)); if(apr_stat(&finfo, argv[1], APR_FINFO_NORM, subpool2) != APR_SUCCESS) { fprintf(stderr, "apr_stat(%s) failed!\n", argv[1]); fflush(stderr); exit(5); } if(stat(argv[1], &sinfo)) { fprintf(stderr, "stat(%s) failed!\n", argv[1]); fflush(stderr); exit(6); } printf("1..2\n"); if(sinfo.st_size == finfo.size) { printf("ok 1 - stat and apr_stat return same size (%lu)\n", finfo.size); } else { printf("not ok 1 - stat and apr_stat return same size (%lu != %lu)\n", sinfo.st_size, finfo.size); } if(finfo.valid & APR_FINFO_SIZE) { printf("ok 2 - finfo.valid includes APR_FINFO_SIZE\n"); } else { printf("not ok 2 - finfo.valid does *not* include APR_FINFO_SIZE!\n"); } exit(0); } --/9DWx/yDrRhgMJTb--