aboutsummaryrefslogtreecommitdiffstats
path: root/extension
diff options
context:
space:
mode:
Diffstat (limited to 'extension')
-rw-r--r--extension/ChangeLog7
-rw-r--r--extension/configh.in3
-rwxr-xr-xextension/configure2
-rw-r--r--extension/configure.ac2
-rw-r--r--extension/filefuncs.c31
5 files changed, 43 insertions, 2 deletions
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 4d2d69b8..02b426ee 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,10 @@
+2013-05-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * configure.ac: Add <sys/param.h> header check.
+ * filefuncs.c: Include <sys/param.h> if there.
+ (device_blocksize): New function.
+ (fill_stat_array): Call it.
+
2013-05-27 Arnold D. Robbins <arnold@skeeve.com>
* configure.ac (AC_STRUCT_ST_BLKSIZE): Replaced with call to
diff --git a/extension/configh.in b/extension/configh.in
index ac8ad05f..8da69306 100644
--- a/extension/configh.in
+++ b/extension/configh.in
@@ -90,6 +90,9 @@
/* Define to 1 if `st_blksize' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
/* Define to 1 if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
diff --git a/extension/configure b/extension/configure
index 26cde4b0..1adb8dd5 100755
--- a/extension/configure
+++ b/extension/configure
@@ -13952,7 +13952,7 @@ else
$as_echo "no" >&6; }
fi
-for ac_header in dirent.h fnmatch.h time.h sys/time.h sys/select.h
+for ac_header in dirent.h fnmatch.h time.h sys/time.h sys/select.h sys/param.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
diff --git a/extension/configure.ac b/extension/configure.ac
index 82742860..f5b03e06 100644
--- a/extension/configure.ac
+++ b/extension/configure.ac
@@ -66,7 +66,7 @@ else
AC_MSG_RESULT([no])
fi
-AC_CHECK_HEADERS(dirent.h fnmatch.h time.h sys/time.h sys/select.h)
+AC_CHECK_HEADERS(dirent.h fnmatch.h time.h sys/time.h sys/select.h sys/param.h)
AC_CHECK_FUNCS(fdopendir fnmatch gettimeofday \
getdtablesize nanosleep select GetSystemTimeAsFileTime)
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 9d4b2258..0afed056 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -45,6 +45,9 @@
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif /* HAVE_SYS_PARAM_H */
#include "gawkapi.h"
@@ -265,6 +268,31 @@ read_symlink(const char *fname, size_t bufsize, ssize_t *linksize)
return NULL;
}
+
+/* device_blocksize --- try to figure out units of st_blocks */
+
+static int
+device_blocksize()
+{
+ /* some of this derived from GNULIB stat-size.h */
+#if defined(DEV_BSIZE)
+ /* <sys/param.h>, most systems */
+ return DEV_BSIZE;
+#elif defined(S_BLKSIZE)
+ /* <sys/stat.h>, BSD systems */
+ return S_BLKSIZE;
+#elif defined hpux || defined __hpux__ || defined __hpux
+ return 1024;
+#elif defined _AIX && defined _I386
+ /* AIX PS/2 counts st_blocks in 4K units. */
+ return 4 * 1024;
+#elif defined __MINGW32__
+ return 1024;
+#else
+ return 512;
+#endif
+}
+
/* array_set --- set an array element */
static void
@@ -357,6 +385,9 @@ fill_stat_array(const char *name, awk_array_t array, struct stat *sbuf)
array_set_numeric(array, "blksize", 4096);
#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
+ /* the size of a block for st_blocks */
+ array_set_numeric(array, "devbsize", device_blocksize());
+
pmode = format_mode(sbuf->st_mode);
array_set(array, "pmode", make_const_string(pmode, strlen(pmode), & tmp));