You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2013/10/23 06:35:10 UTC

git commit: TS-2295: update statvfs usage

Updated Branches:
  refs/heads/master 5460ce5b5 -> f760dac42


TS-2295: update statvfs usage

Use statvfs(2) everywhere. Clean up headers so that ink_file.h has
enough includes to use statvfs(2).


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f760dac4
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f760dac4
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f760dac4

Branch: refs/heads/master
Commit: f760dac42f6cbdba37259a2f57e37f55e8cb2228
Parents: 5460ce5
Author: James Peach <jp...@apache.org>
Authored: Tue Sep 24 21:40:31 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Tue Oct 22 21:33:25 2013 -0700

----------------------------------------------------------------------
 CHANGES                    |  3 +++
 configure.ac               |  4 +++-
 iocore/cache/Store.cc      | 46 +++++++++++++++--------------------------
 lib/ts/ink_file.h          | 18 ++++++++++++++--
 proxy/logging/LogConfig.cc | 36 ++++----------------------------
 5 files changed, 43 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f760dac4/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 77a834f..c66e53e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.1.0
 
+
+  *) [ TS-2295] update statvfs usage
+
   *) [TS-2139] Fix PURGE twice to remove object in cache if enable-interim-cache
 
   *) [TS-2216] Fix cquuh log tag, which does not calculate the right

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f760dac4/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index bb23933..b25a6fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1419,7 +1419,7 @@ AM_CONDITIONAL([BUILD_HTTP_LOAD], [test x"$ac_cv_func_epoll_ctl" = x"yes"])
 # -----------------------------------------------------------------------------
 # 5. CHECK FOR HEADER FILES
 
-AC_CHECK_HEADERS([sys/types.h sys/mman.h])
+TS_FLAG_HEADERS([sys/types.h sys/mman.h])
 TS_FLAG_HEADERS([sys/epoll.h \
                   sys/event.h \
                   sys/param.h \
@@ -1504,6 +1504,8 @@ AC_SUBST(net_ppp_defsh)
 AC_SUBST(ifaddrsh)
 AC_SUBST(readline_readlineh)
 
+TS_FLAG_HEADERS([sys/statfs.h sys/statvfs.h sys/disk.h sys/disklabel.h])
+
 TS_FLAG_HEADERS([sys/sysctl.h], [], [],
                  [[#ifdef HAVE_SYS_PARAM_H
                     #include <sys/param.h>

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f760dac4/iocore/cache/Store.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Store.cc b/iocore/cache/Store.cc
index 55c35b7..bd13bfd 100644
--- a/iocore/cache/Store.cc
+++ b/iocore/cache/Store.cc
@@ -25,6 +25,18 @@
 #include "P_Cache.h"
 #include "I_Layout.h"
 
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+
+#if HAVE_SYS_DISK_H
+#include <sys/disk.h>
+#endif
+
+#if HAVE_SYS_DISKLABEL_H
+#include <sys/disklabel.h>
+#endif
+
 // Global
 Store theStore;
 
@@ -449,19 +461,6 @@ Store::write_config_data(int fd)
 }
 
 #if defined(freebsd) || defined(darwin) || defined(openbsd)
-// TODO: Those are probably already included from the ink_platform.h
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#if defined(freebsd)
-#include <sys/disk.h>
-#include <sys/disklabel.h>
-#elif defined(darwin)
-#include <sys/disk.h>
-#include <sys/statvfs.h>
-#endif
-#include <string.h>
 
 const char *
 Span::init(char *an, int64_t size)
@@ -511,11 +510,11 @@ Span::init(char *an, int64_t size)
     return "unable to open";
   }
 
-  struct statfs fs;
-  if ((ret = fstatfs(fd, &fs)) < 0) {
-    Warning("unable to statfs '%s': %d %d, %s", n, ret, errno, strerror(errno));
+  struct statvfs fs;
+  if ((ret = fstatvfs(fd, &fs)) < 0) {
+    Warning("unable to statvfs '%s': %d %d, %s", n, ret, errno, strerror(errno));
     socketManager.close(fd);
-    return "unable to statfs";
+    return "unable to statvfs";
   }
 
   hw_sector_size = fs.f_bsize;
@@ -581,17 +580,10 @@ Lfail:
   socketManager.close(fd);
   return err;
 }
+
 #endif
 
 #if defined(solaris)
-// TODO: Those are probably already included from the ink_platform.h
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <string.h>
 
 const char *
 Span::init(char *filename, int64_t size)
@@ -679,10 +671,6 @@ Lfail:
 #endif
 
 #if defined(linux)
-// TODO: Axe extra includes
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
 #include <unistd.h>             /* for close() */
 #include <sys/ioctl.h>
 #include <linux/hdreg.h>        /* for struct hd_geometry */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f760dac4/lib/ts/ink_file.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_file.h b/lib/ts/ink_file.h
index 5aa08bf..a22e33d 100644
--- a/lib/ts/ink_file.h
+++ b/lib/ts/ink_file.h
@@ -32,8 +32,24 @@
 #ifndef _ink_file_h_
 #define	_ink_file_h_
 
+#include "ink_config.h"
+
 #include <stdio.h>
 #include <sys/types.h>
+#include <dirent.h>
+
+#if HAVE_SYS_STATFS_H
+#include <sys/statfs.h>
+#endif
+
+#if HAVE_SYS_STATVFS_H
+#include <sys/statvfs.h>
+#endif
+
+// Darwin keeps statafs(2) in <sys/mount.h> ...
+#if HAVE_SYS_MOUNT_H
+#include <sys/mount.h>
+#endif
 
 /*===========================================================================*
 
@@ -41,8 +57,6 @@
 
  *===========================================================================*/
 
-#include <dirent.h>
-
 // Cause ink_filepath_merge to fail if addpath is above rootpath
 //
 #define INK_FILEPATH_NOTABOVEROOT   0x01

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f760dac4/proxy/logging/LogConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogConfig.cc b/proxy/logging/LogConfig.cc
index 40e0069..aa874d5 100644
--- a/proxy/logging/LogConfig.cc
+++ b/proxy/logging/LogConfig.cc
@@ -27,22 +27,9 @@
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
-#ifdef HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
-
-#include <dirent.h>
-
-#if defined(linux)
-#include <sys/statfs.h>
-#elif defined(solaris)
-#include <sys/statfs.h>
-#include <sys/statvfs.h>
-#elif !defined(freebsd)
-#include <sys/statvfs.h>
-#endif  // linux
 
 #include "ink_platform.h"
+#include "ink_file.h"
 
 #include "Main.h"
 #include "List.h"
@@ -65,15 +52,6 @@
 #include "LogCollationAccept.h"
 #endif
 
-#if defined(linux)
-#include <sys/vfs.h>
-#else
-extern "C"
-{
-  int statvfs(const char *, struct statvfs *);
-}
-#endif
-
 #define DISK_IS_CONFIG_FULL_MESSAGE \
     "Access logging to local log directory suspended - " \
     "configured space allocation exhausted."
@@ -1550,16 +1528,10 @@ LogConfig::update_space_used()
   // Now check the partition to see if there is enough *actual* space.
   //
   partition_space_left = m_partition_space_left;
-#if defined(solaris)
+
   struct statvfs fs;
-  ::memset(&fs, 0, sizeof(fs));
-  int ret =::statvfs(logfile_dir, &fs);
-#else
-  struct statfs fs;
-  ::memset(&fs, 0, sizeof(fs));
-  int ret =::statfs(logfile_dir, &fs);
-#endif
-  if (ret >= 0) {
+
+  if (::statvfs(logfile_dir, &fs) >= 0) {
     partition_space_left = (int64_t) fs.f_bavail * (int64_t) fs.f_bsize;
   }