[sorry for late reply, I'm catching up a bit on old list mail]

[Lucian Adrian Grijincu]
> apr_dir_read puts the returned data in and apr_finfo_t structure, which
> has an apr_ino_t field. This field is 4 or 8 bytes in size dependent on
> _FILE_OFFSET_BITS=64 being either undefined or defined.

Indeed - but forcing every apr-using application to also use LFS is not
optimal either.

We ran into this issue in Debian, and kludged it by patching
apr_file_info.h not to use ino_t at all, but instead 'unsigned int' or
'unsigned long' depending on platform.  I also added a build-time test
to ensure we're using the same field size on each platform that we did
before the patch, so as not to change our ABI (so apps did not need to
be recompiled).
#! /bin/sh /usr/share/dpatch/dpatch-run
## 020_lfs_ino_t.dpatch by <[EMAIL PROTECTED]>
##
## DP: Use 'unsigned long' instead of 'ino_t'.  We do this for LFS
## DP: purposes - specifically, so that an app (such as php4) can
## DP: define _FILE_OFFSET_BITS=64 without affecting the apr ABI.
## DP:
## DP: See also debian/ino_t_test.c, which we use to verify that
## DP: it is safe to do this.

@DPATCH@
Index: include/apr_file_info.h
--- a/include/apr_file_info.h
+++ b/include/apr_file_info.h
@@ -134,7 +134,13 @@
 typedef apr_uint32_t              apr_dev_t;
 #else
 /** The inode of the file. */
-typedef ino_t                     apr_ino_t;
+/* NOTE: this should be ino_t, except that in that case the ABI changes
+ * if you compile an app with LFS defines. */
+#if defined(__alpha__) || defined(__FreeBSD_kernel__)
+typedef unsigned int              apr_ino_t;
+#else
+typedef unsigned long int         apr_ino_t;
+#endif
 /**
  * Structure for determining the device the file is on.
  */
#include <stdio.h>
#include <sys/types.h>

/* keep this in sync with the patch to apr_file_info.h */
#if defined(__alpha__) || defined(__FreeBSD_kernel__)
typedef unsigned int              apr_ino_t;
#else
typedef unsigned long int         apr_ino_t;
#endif

int main (void)
{
	size_t s0 = sizeof(ino_t), s1 = sizeof(apr_ino_t);
	if (s0 == s1)
		return 0;
	fprintf(stderr, "***\n"
			"*** 'ino_t' size is %zu, expected %zu\n"
			"*** Please report this to the Debian Apache maintainers\n"
			"***\n", s0, s1);
	return 1;
}

Attachment: signature.asc
Description: Digital signature

Reply via email to