aboutsummaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
authorPaul Eggert2017-10-01 22:31:39 -0700
committerPaul Eggert2017-10-01 22:33:20 -0700
commit135bca574c31b7bf6df6c63d28f180956928dde7 (patch)
tree1259c514b5304e7b1dbb8a9098f0a6dd63e00003 /m4
parent4829a3b033b119b088947d14b73efc197b2547fa (diff)
downloademacs-135bca574c31b7bf6df6c63d28f180956928dde7.tar.gz
emacs-135bca574c31b7bf6df6c63d28f180956928dde7.zip
Port file-system-info to non-Microsoft
* admin/merge-gnulib (GNULIB_MODULES): Add fsusage. * doc/emacs/files.texi (Directories): Remove documentation of now-obsolete directory-free-space-program and directory-free-space-args. * etc/NEWS: Mention change. * etc/PROBLEMS: Slow df is no longer a problem. * lib/fsusage.c, lib/fsusage.h, m4/fsusage.m4: New files, copied from Gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lisp/dired.el (dired-free-space-program) (dired-free-space-args): These aliases are now obsolete. * lisp/files.el (directory-free-space-program) (directory-free-space-args): Now obsolete. (get-free-disk-space): Just call file-system-info instead of the now-obsolete directory-free-space-program. * nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_fsusage): New macro. * src/fileio.c: Include fsusage.h. (blocks_to_bytes, Ffile_system_info) [!DOS_NT]: New functions. (syms_of_fileio) [!DOS_NT]: Defsubr file-system-info.
Diffstat (limited to 'm4')
-rw-r--r--m4/fsusage.m4336
-rw-r--r--m4/gnulib-comp.m49
2 files changed, 345 insertions, 0 deletions
diff --git a/m4/fsusage.m4 b/m4/fsusage.m4
new file mode 100644
index 00000000000..1d6ad41cd3c
--- /dev/null
+++ b/m4/fsusage.m4
@@ -0,0 +1,336 @@
1# serial 32
2# Obtaining file system usage information.
3
4# Copyright (C) 1997-1998, 2000-2001, 2003-2017 Free Software Foundation, Inc.
5#
6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10# Written by Jim Meyering.
11
12AC_DEFUN([gl_FSUSAGE],
13[
14 AC_CHECK_HEADERS_ONCE([sys/param.h])
15 AC_CHECK_HEADERS_ONCE([sys/vfs.h sys/fs_types.h])
16 AC_CHECK_HEADERS([sys/mount.h], [], [],
17 [AC_INCLUDES_DEFAULT
18 [#if HAVE_SYS_PARAM_H
19 #include <sys/param.h>
20 #endif]])
21 gl_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no])
22])
23
24# Try to determine how a program can obtain file system usage information.
25# If successful, define the appropriate symbol (see fsusage.c) and
26# execute ACTION-IF-FOUND. Otherwise, execute ACTION-IF-NOT-FOUND.
27#
28# gl_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
29
30AC_DEFUN([gl_FILE_SYSTEM_USAGE],
31[
32dnl Enable large-file support. This has the effect of changing the size
33dnl of field f_blocks in 'struct statvfs' from 32 bit to 64 bit on
34dnl glibc/Hurd, HP-UX 11, Solaris (32-bit mode). It also changes the size
35dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on
36dnl Mac OS X >= 10.5 (32-bit mode).
37AC_REQUIRE([AC_SYS_LARGEFILE])
38
39AC_MSG_CHECKING([how to get file system space usage])
40ac_fsusage_space=no
41
42# Perform only the link test since it seems there are no variants of the
43# statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs])
44# because that got a false positive on SCO OSR5. Adding the declaration
45# of a 'struct statvfs' causes this test to fail (as it should) on such
46# systems. That system is reported to work fine with STAT_STATFS4 which
47# is what it gets when this test fails.
48if test $ac_fsusage_space = no; then
49 # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
50 # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS.
51 AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs],
52 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
53#ifdef __osf__
54"Do not use Tru64's statvfs implementation"
55#endif
56
57#include <sys/statvfs.h>
58
59struct statvfs fsd;
60
61#if defined __APPLE__ && defined __MACH__
62#include <limits.h>
63/* On Mac OS X >= 10.5, f_blocks in 'struct statvfs' is a 32-bit quantity;
64 that commonly limits file systems to 4 TiB. Whereas f_blocks in
65 'struct statfs' is a 64-bit type, thanks to the large-file support
66 that was enabled above. In this case, don't use statvfs(); use statfs()
67 instead. */
68int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1];
69#endif
70]],
71 [[statvfs (0, &fsd);]])],
72 [fu_cv_sys_stat_statvfs=yes],
73 [fu_cv_sys_stat_statvfs=no])])
74 if test $fu_cv_sys_stat_statvfs = yes; then
75 ac_fsusage_space=yes
76 # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs.
77 # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems
78 # statvfs with large-file support is already equivalent to statvfs64.
79 AC_CACHE_CHECK([whether to use statvfs64],
80 [fu_cv_sys_stat_statvfs64],
81 [AC_LINK_IFELSE(
82 [AC_LANG_PROGRAM(
83 [[#include <sys/types.h>
84 #include <sys/statvfs.h>
85 struct statvfs64 fsd;
86 int check_f_blocks_larger_in_statvfs64
87 [sizeof (((struct statvfs64 *) 0)->f_blocks)
88 > sizeof (((struct statvfs *) 0)->f_blocks)
89 ? 1 : -1];
90 ]],
91 [[statvfs64 (0, &fsd);]])],
92 [fu_cv_sys_stat_statvfs64=yes],
93 [fu_cv_sys_stat_statvfs64=no])
94 ])
95 if test $fu_cv_sys_stat_statvfs64 = yes; then
96 AC_DEFINE([STAT_STATVFS64], [1],
97 [ Define if statvfs64 should be preferred over statvfs.])
98 else
99 AC_DEFINE([STAT_STATVFS], [1],
100 [ Define if there is a function named statvfs. (SVR4)])
101 fi
102 fi
103fi
104
105# Check for this unconditionally so we have a
106# good fallback on glibc/Linux > 2.6 < 2.6.36
107AC_MSG_CHECKING([for two-argument statfs with statfs.f_frsize member])
108AC_CACHE_VAL([fu_cv_sys_stat_statfs2_frsize],
109[AC_RUN_IFELSE([AC_LANG_SOURCE([[
110#ifdef HAVE_SYS_PARAM_H
111#include <sys/param.h>
112#endif
113#ifdef HAVE_SYS_MOUNT_H
114#include <sys/mount.h>
115#endif
116#ifdef HAVE_SYS_VFS_H
117#include <sys/vfs.h>
118#endif
119 int
120 main ()
121 {
122 struct statfs fsd;
123 fsd.f_frsize = 0;
124 return statfs (".", &fsd) != 0;
125 }]])],
126 [fu_cv_sys_stat_statfs2_frsize=yes],
127 [fu_cv_sys_stat_statfs2_frsize=no],
128 [fu_cv_sys_stat_statfs2_frsize=no])])
129AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_frsize])
130if test $fu_cv_sys_stat_statfs2_frsize = yes; then
131 ac_fsusage_space=yes
132 AC_DEFINE([STAT_STATFS2_FRSIZE], [1],
133[ Define if statfs takes 2 args and struct statfs has a field named f_frsize.
134 (glibc/Linux > 2.6)])
135fi
136
137if test $ac_fsusage_space = no; then
138 # DEC Alpha running OSF/1
139 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
140 AC_CACHE_VAL([fu_cv_sys_stat_statfs3_osf1],
141 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
142#include <sys/param.h>
143#include <sys/types.h>
144#include <sys/mount.h>
145 int
146 main ()
147 {
148 struct statfs fsd;
149 fsd.f_fsize = 0;
150 return statfs (".", &fsd, sizeof (struct statfs)) != 0;
151 }]])],
152 [fu_cv_sys_stat_statfs3_osf1=yes],
153 [fu_cv_sys_stat_statfs3_osf1=no],
154 [fu_cv_sys_stat_statfs3_osf1=no])])
155 AC_MSG_RESULT([$fu_cv_sys_stat_statfs3_osf1])
156 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
157 ac_fsusage_space=yes
158 AC_DEFINE([STAT_STATFS3_OSF1], [1],
159 [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
160 fi
161fi
162
163if test $ac_fsusage_space = no; then
164 # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4.
165 # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
166 # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.)
167 # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and
168 # <sys/vfs.h>.)
169 # (On Solaris, statfs has 4 arguments.)
170 AC_MSG_CHECKING([for two-argument statfs with statfs.f_bsize dnl
171member (AIX, 4.3BSD)])
172 AC_CACHE_VAL([fu_cv_sys_stat_statfs2_bsize],
173 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
174#ifdef HAVE_SYS_PARAM_H
175#include <sys/param.h>
176#endif
177#ifdef HAVE_SYS_MOUNT_H
178#include <sys/mount.h>
179#endif
180#ifdef HAVE_SYS_VFS_H
181#include <sys/vfs.h>
182#endif
183 int
184 main ()
185 {
186 struct statfs fsd;
187 fsd.f_bsize = 0;
188 return statfs (".", &fsd) != 0;
189 }]])],
190 [fu_cv_sys_stat_statfs2_bsize=yes],
191 [fu_cv_sys_stat_statfs2_bsize=no],
192 [fu_cv_sys_stat_statfs2_bsize=no])])
193 AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_bsize])
194 if test $fu_cv_sys_stat_statfs2_bsize = yes; then
195 ac_fsusage_space=yes
196 AC_DEFINE([STAT_STATFS2_BSIZE], [1],
197[ Define if statfs takes 2 args and struct statfs has a field named f_bsize.
198 (4.3BSD, SunOS 4, HP-UX, AIX PS/2)])
199 fi
200fi
201
202if test $ac_fsusage_space = no; then
203 # SVR3
204 # (Solaris already handled above.)
205 AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
206 AC_CACHE_VAL([fu_cv_sys_stat_statfs4],
207 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
208#include <sys/types.h>
209#include <sys/statfs.h>
210 int
211 main ()
212 {
213 struct statfs fsd;
214 return statfs (".", &fsd, sizeof fsd, 0) != 0;
215 }]])],
216 [fu_cv_sys_stat_statfs4=yes],
217 [fu_cv_sys_stat_statfs4=no],
218 [fu_cv_sys_stat_statfs4=no])])
219 AC_MSG_RESULT([$fu_cv_sys_stat_statfs4])
220 if test $fu_cv_sys_stat_statfs4 = yes; then
221 ac_fsusage_space=yes
222 AC_DEFINE([STAT_STATFS4], [1],
223 [ Define if statfs takes 4 args. (SVR3, Dynix, old Irix, old AIX, Dolphin)])
224 fi
225fi
226
227if test $ac_fsusage_space = no; then
228 # 4.4BSD and older NetBSD
229 # (OSF/1 already handled above.)
230 # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.)
231 # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in
232 # <sys/mount.h>.)
233 AC_MSG_CHECKING([for two-argument statfs with statfs.f_fsize dnl
234member (4.4BSD and NetBSD)])
235 AC_CACHE_VAL([fu_cv_sys_stat_statfs2_fsize],
236 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
237#include <sys/types.h>
238#ifdef HAVE_SYS_PARAM_H
239#include <sys/param.h>
240#endif
241#ifdef HAVE_SYS_MOUNT_H
242#include <sys/mount.h>
243#endif
244 int
245 main ()
246 {
247 struct statfs fsd;
248 fsd.f_fsize = 0;
249 return statfs (".", &fsd) != 0;
250 }]])],
251 [fu_cv_sys_stat_statfs2_fsize=yes],
252 [fu_cv_sys_stat_statfs2_fsize=no],
253 [fu_cv_sys_stat_statfs2_fsize=no])])
254 AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_fsize])
255 if test $fu_cv_sys_stat_statfs2_fsize = yes; then
256 ac_fsusage_space=yes
257 AC_DEFINE([STAT_STATFS2_FSIZE], [1],
258[ Define if statfs takes 2 args and struct statfs has a field named f_fsize.
259 (4.4BSD, NetBSD)])
260 fi
261fi
262
263if test $ac_fsusage_space = no; then
264 # Ultrix
265 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
266 AC_CACHE_VAL([fu_cv_sys_stat_fs_data],
267 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
268#include <sys/types.h>
269#ifdef HAVE_SYS_PARAM_H
270#include <sys/param.h>
271#endif
272#ifdef HAVE_SYS_MOUNT_H
273#include <sys/mount.h>
274#endif
275#ifdef HAVE_SYS_FS_TYPES_H
276#include <sys/fs_types.h>
277#endif
278 int
279 main ()
280 {
281 struct fs_data fsd;
282 /* Ultrix's statfs returns 1 for success,
283 0 for not mounted, -1 for failure. */
284 return statfs (".", &fsd) != 1;
285 }]])],
286 [fu_cv_sys_stat_fs_data=yes],
287 [fu_cv_sys_stat_fs_data=no],
288 [fu_cv_sys_stat_fs_data=no])])
289 AC_MSG_RESULT([$fu_cv_sys_stat_fs_data])
290 if test $fu_cv_sys_stat_fs_data = yes; then
291 ac_fsusage_space=yes
292 AC_DEFINE([STAT_STATFS2_FS_DATA], [1],
293[ Define if statfs takes 2 args and the second argument has
294 type struct fs_data. (Ultrix)])
295 fi
296fi
297
298AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
299
300])
301
302
303# Check for SunOS statfs brokenness wrt partitions 2GB and larger.
304# If <sys/vfs.h> exists and struct statfs has a member named f_spare,
305# enable the work-around code in fsusage.c.
306AC_DEFUN([gl_STATFS_TRUNCATES],
307[
308 AC_MSG_CHECKING([for statfs that truncates block counts])
309 AC_CACHE_VAL([fu_cv_sys_truncating_statfs],
310 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
311#if !defined(sun) && !defined(__sun)
312choke -- this is a workaround for a Sun-specific problem
313#endif
314#include <sys/types.h>
315#include <sys/vfs.h>]],
316 [[struct statfs t; long c = *(t.f_spare);
317 if (c) return 0;]])],
318 [fu_cv_sys_truncating_statfs=yes],
319 [fu_cv_sys_truncating_statfs=no])])
320 if test $fu_cv_sys_truncating_statfs = yes; then
321 AC_DEFINE([STATFS_TRUNCATES_BLOCK_COUNTS], [1],
322 [Define if the block counts reported by statfs may be truncated to 2GB
323 and the correct values may be stored in the f_spare array.
324 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
325 SunOS 4.1.1 seems not to be affected.)])
326 fi
327 AC_MSG_RESULT([$fu_cv_sys_truncating_statfs])
328])
329
330
331# Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE.
332AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
333[
334 AC_CHECK_HEADERS([dustat.h sys/fs/s5param.h sys/statfs.h])
335 gl_STATFS_TRUNCATES
336])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index c5517529f09..cb255fcf6d9 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -87,6 +87,7 @@ AC_DEFUN([gl_EARLY],
87 # Code from module flexmember: 87 # Code from module flexmember:
88 # Code from module fpending: 88 # Code from module fpending:
89 # Code from module fstatat: 89 # Code from module fstatat:
90 # Code from module fsusage:
90 # Code from module fsync: 91 # Code from module fsync:
91 # Code from module getdtablesize: 92 # Code from module getdtablesize:
92 # Code from module getgroups: 93 # Code from module getgroups:
@@ -256,6 +257,11 @@ AC_DEFUN([gl_INIT],
256 AC_LIBOBJ([fstatat]) 257 AC_LIBOBJ([fstatat])
257 fi 258 fi
258 gl_SYS_STAT_MODULE_INDICATOR([fstatat]) 259 gl_SYS_STAT_MODULE_INDICATOR([fstatat])
260 gl_FSUSAGE
261 if test $gl_cv_fs_space = yes; then
262 AC_LIBOBJ([fsusage])
263 gl_PREREQ_FSUSAGE_EXTRA
264 fi
259 gl_FUNC_FSYNC 265 gl_FUNC_FSYNC
260 if test $HAVE_FSYNC = 0; then 266 if test $HAVE_FSYNC = 0; then
261 AC_LIBOBJ([fsync]) 267 AC_LIBOBJ([fsync])
@@ -864,6 +870,8 @@ AC_DEFUN([gl_FILE_LIST], [
864 lib/fpending.c 870 lib/fpending.c
865 lib/fpending.h 871 lib/fpending.h
866 lib/fstatat.c 872 lib/fstatat.c
873 lib/fsusage.c
874 lib/fsusage.h
867 lib/fsync.c 875 lib/fsync.c
868 lib/ftoastr.c 876 lib/ftoastr.c
869 lib/ftoastr.h 877 lib/ftoastr.h
@@ -995,6 +1003,7 @@ AC_DEFUN([gl_FILE_LIST], [
995 m4/flexmember.m4 1003 m4/flexmember.m4
996 m4/fpending.m4 1004 m4/fpending.m4
997 m4/fstatat.m4 1005 m4/fstatat.m4
1006 m4/fsusage.m4
998 m4/fsync.m4 1007 m4/fsync.m4
999 m4/getdtablesize.m4 1008 m4/getdtablesize.m4
1000 m4/getgroups.m4 1009 m4/getgroups.m4