summaryrefslogtreecommitdiff
path: root/src/stat.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2006-04-12 20:14:42 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2006-04-12 20:14:42 +0000
commiteda15d7cca6bed0547decacfb118fc80cf977bb6 (patch)
treed49e22c0685485367dc7acef5f30fcc7e4d2f921 /src/stat.c
parent2e16cd4302d6881963c29f7d28209da8a4a226ea (diff)
downloadcoreutils-eda15d7cca6bed0547decacfb118fc80cf977bb6.tar.xz
(USE_STATVFS): New macro.
Include <sys/statvfs.h> and use statvfs only if USE_STATVFS. (NAMEMAX_FORMAT): define a bit more clearly, now that the statvfs-using code is a bit more regular.
Diffstat (limited to 'src/stat.c')
-rw-r--r--src/stat.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/stat.c b/src/stat.c
index 0ce83d173..fd5f8bd31 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -1,5 +1,5 @@
/* stat.c -- display file or file system status
- Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,11 +19,18 @@
#include <config.h>
+#if (STAT_STATVFS \
+ && (HAVE_STRUCT_STATVFS_F_BASETYPE || ! HAVE_STRUCT_STATFS_F_FSTYPENAME))
+# define USE_STATVFS 1
+#else
+# define USE_STATVFS 0
+#endif
+
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
-#if HAVE_SYS_STATVFS_H && HAVE_STRUCT_STATVFS_F_BASETYPE
+#if USE_STATVFS
# include <sys/statvfs.h>
#elif HAVE_SYS_VFS_H
# include <sys/vfs.h>
@@ -56,35 +63,29 @@
#include "strftime.h"
#include "xreadlink.h"
-#define NAMEMAX_FORMAT PRIuMAX
-
-#if HAVE_STRUCT_STATVFS_F_BASETYPE
+#if USE_STATVFS
# define STRUCT_STATVFS struct statvfs
# define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATVFS_F_TYPE
# if HAVE_STRUCT_STATVFS_F_NAMEMAX
# define SB_F_NAMEMAX(S) ((uintmax_t) ((S)->f_namemax))
# endif
-# if STAT_STATVFS
-# define STATFS statvfs
-# define STATFS_FRSIZE(S) ((S)->f_frsize)
-# endif
+# define STATFS statvfs
+# define STATFS_FRSIZE(S) ((S)->f_frsize)
#else
# define STRUCT_STATVFS struct statfs
# define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATFS_F_TYPE
# if HAVE_STRUCT_STATFS_F_NAMELEN
# define SB_F_NAMEMAX(S) ((uintmax_t) ((S)->f_namelen))
# endif
-#endif
-
-#ifndef STATFS
# define STATFS statfs
# define STATFS_FRSIZE(S) 0
#endif
-#ifndef SB_F_NAMEMAX
+#ifdef SB_F_NAMEMAX
+# define NAMEMAX_FORMAT PRIuMAX
+#else
/* NetBSD 1.5.2 has neither f_namemax nor f_namelen. */
# define SB_F_NAMEMAX(S) "*"
-# undef NAMEMAX_FORMAT
# define NAMEMAX_FORMAT "s"
#endif