diff options
author | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2004-03-27 13:11:18 +0000 |
---|---|---|
committer | jorton <jorton@13f79535-47bb-0310-9956-ffa450edef68> | 2004-03-27 13:11:18 +0000 |
commit | 263ebecba3310066882fe83f7309c4f101ff34d2 (patch) | |
tree | 5919e52a5b6b9ae68ac09f9e288751d4b6a8034f /file_io | |
parent | c3da8b59b2241ac249f2e52e06aec980a69769d8 (diff) | |
download | libapr-263ebecba3310066882fe83f7309c4f101ff34d2.tar.gz |
Add LFS support:
* configure.in: Check for off64_t and necessary LFS functions, define
apr_off_t as off64_t where available. Add --disable-lfs flag.
Forward-port changes from 0.9.5 to define apr_off_t as long on systems
systems with a 32-bit off_t which don't have LFS enabled.
* include/apr.h.in: Let configure define APR_HAS_LARGE_FILES.
* include/arch/netware/apr_arch_file_io.h: Redefine lseek and
ftruncate.
* include/arch/unix/apr_arch_file_io.h: Redefine stat, lstat, fstat,
lseek, ftruncate here; define struct_stat.
* file_io/unix/filestat.c: Use struct_stat.
* file_io/unix/mktemp.c: Use mkstemp64 where available.
* file_io/unix/open.c (apr_file_open): Use O_LARGEFILE by default when
LFS is enabled.
* file_io/unix/readwrite.c, file_io/unix/seek.c: Don't redefine lseek
and ftruncate here.
* mmap/unix/mmap.c (apr_mmap_create): Use mmap64 if available;
otherwise check for overflow when LFS is enabled.
* network_io/unix/sendrecv.c (apr_socket_sendfile) [Linux/HPUX]: Use
sendfile64 if available; otherwise check for overflow when LFS is
enabled. [solaris]: Use sendfilev64/sendfilevec64_t.
* test/Makefile.in, test/test_apr.h, test/testlfs.c: Add tests.
Reviewed by: Jeff Trawick
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@65027 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r-- | file_io/unix/filestat.c | 6 | ||||
-rw-r--r-- | file_io/unix/mktemp.c | 5 | ||||
-rw-r--r-- | file_io/unix/open.c | 4 | ||||
-rw-r--r-- | file_io/unix/readwrite.c | 4 | ||||
-rw-r--r-- | file_io/unix/seek.c | 13 |
5 files changed, 12 insertions, 20 deletions
diff --git a/file_io/unix/filestat.c b/file_io/unix/filestat.c index 85352fa9d..4e56f9948 100644 --- a/file_io/unix/filestat.c +++ b/file_io/unix/filestat.c @@ -66,7 +66,7 @@ static apr_filetype_e filetype_from_mode(mode_t mode) return type; } -static void fill_out_finfo(apr_finfo_t *finfo, struct stat *info, +static void fill_out_finfo(apr_finfo_t *finfo, struct_stat *info, apr_int32_t wanted) { finfo->valid = APR_FINFO_MIN | APR_FINFO_IDENT | APR_FINFO_NLINK @@ -94,7 +94,7 @@ APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted, apr_file_t *thefile) { - struct stat info; + struct_stat info; if (thefile->buffered) { apr_status_t rv = apr_file_flush(thefile); @@ -227,7 +227,7 @@ APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, apr_int32_t wanted, apr_pool_t *pool) { - struct stat info; + struct_stat info; int srv; if (wanted & APR_FINFO_LINK) diff --git a/file_io/unix/mktemp.c b/file_io/unix/mktemp.c index ff23a2f7b..6db13c69c 100644 --- a/file_io/unix/mktemp.c +++ b/file_io/unix/mktemp.c @@ -182,7 +182,12 @@ APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *template, apr_i return gettemp(template, fp, flags, p); #else +#ifdef HAVE_MKSTEMP64 + fd = mkstemp64(template); +#else fd = mkstemp(template); +#endif + if (fd == -1) { return errno; } diff --git a/file_io/unix/open.c b/file_io/unix/open.c index 81d622426..ee9196214 100644 --- a/file_io/unix/open.c +++ b/file_io/unix/open.c @@ -99,6 +99,10 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, } #endif +#if APR_HAS_LARGE_FILES && defined(_LARGEFILE64_SOURCE) + oflags |= O_LARGEFILE; +#endif + #if APR_HAS_THREADS if ((flag & APR_BUFFERED) && (flag & APR_XTHREAD)) { rv = apr_thread_mutex_create(&thlock, diff --git a/file_io/unix/readwrite.c b/file_io/unix/readwrite.c index 3059f670f..1e6a6e665 100644 --- a/file_io/unix/readwrite.c +++ b/file_io/unix/readwrite.c @@ -164,11 +164,7 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a */ apr_int64_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; if (offset != thefile->filePtr) -#if defined(NETWARE) && APR_HAS_LARGE_FILES - lseek64(thefile->filedes, offset, SEEK_SET); -#else lseek(thefile->filedes, offset, SEEK_SET); -#endif thefile->bufpos = thefile->dataRead = 0; thefile->direction = 1; } diff --git a/file_io/unix/seek.c b/file_io/unix/seek.c index 2ae433f9d..cac4e9331 100644 --- a/file_io/unix/seek.c +++ b/file_io/unix/seek.c @@ -31,11 +31,7 @@ static apr_status_t setptr(apr_file_t *thefile, apr_off_t pos ) rc = 0; } else { -#if defined(NETWARE) && APR_HAS_LARGE_FILES - rc = lseek64(thefile->filedes, pos, SEEK_SET); -#else rc = lseek(thefile->filedes, pos, SEEK_SET); -#endif if (rc != -1 ) { thefile->bufpos = thefile->dataRead = 0; @@ -81,12 +77,7 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t wh return rc; } else { - -#if defined(NETWARE) && APR_HAS_LARGE_FILES - rv = lseek64(thefile->filedes, *offset, where); -#else rv = lseek(thefile->filedes, *offset, where); -#endif if (rv == -1) { *offset = -1; return errno; @@ -100,11 +91,7 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, apr_seek_where_t wh apr_status_t apr_file_trunc(apr_file_t *fp, apr_off_t offset) { -#if defined(NETWARE) && APR_HAS_LARGE_FILES - if (ftruncate64(fp->filedes, offset) == -1) { -#else if (ftruncate(fp->filedes, offset) == -1) { -#endif return errno; } return setptr(fp, offset); |