apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <...@manyfish.co.uk>
Subject RFC: APR_LARGEFILE flag for APR 0.9
Date Sat, 20 Mar 2004 11:04:26 GMT
APR 0.9.x can't change the size of apr_off_t, but it's still useful to
be able to use O_LARGEFILE in a few specific cases on LFS platforms when
the application knows it is safe: to allow writing >2Gb log files in
particular.  It's not safe to use in general, since {f,l,}stat() will
fail on a >2gb file with a 32-bit off_t, so needs to come with a big
warning sign.

(apr_file_transfer_contents() could make use of O_LARGEFILE, but
annoyingly it won't work for >2Gb files in the common case where
to_perms == APR_FILE_SOURCE_PERMS since that needs to stat() the source
file)

Any comments?

--- include/apr_file_io.h	13 Feb 2004 09:33:44 -0000	1.144.2.1
+++ include/apr_file_io.h	20 Mar 2004 10:59:11 -0000
@@ -69,6 +69,20 @@
                                         is opened */
 #define APR_SENDFILE_ENABLED 0x01000 /**< Advisory flag that this file should
                                           support apr_sendfile operation */
+#define APR_LARGEFILE   0x04000    /**< Platform dependent flag to enable large file
+                                        support; WARNING see below. */
+
+/** @warning The APR_LARGEFILE flag only has effect on some platforms
+ * where sizeof(apr_off_t) == 4.  When implemented, it allows opening
+ * and writing to a file which exceeds the size which can be
+ * represented by apr_off_t (2 gigabytes).  When a file's size does
+ * exceed 2Gb, apr_file_info_get() will fail with an error on the
+ * descriptor, likewise apr_stat()/apr_lstat() will fail on the
+ * filename.  apr_dir_read() will fail with APR_INCOMPLETE on a
+ * directory entry for a large file depending on the particular
+ * APR_FINFO_* flags.  Generally, it is not recommended to use this
+ * flag. */
+
 /** @} */
 
 /**
--- file_io/unix/open.c	13 Feb 2004 09:33:43 -0000	1.111.2.1
+++ file_io/unix/open.c	20 Mar 2004 10:59:11 -0000
@@ -98,6 +98,11 @@
         oflags |= O_BINARY;
     }
 #endif
+#ifdef O_LARGEFILE
+    if (flag & APR_LARGEFILE) {
+        oflags |= O_LARGEFILE;
+    }
+#endif
     
 #if APR_HAS_THREADS
     if ((flag & APR_BUFFERED) && (flag & APR_XTHREAD)) {

Mime
View raw message