You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2019/06/15 16:22:43 UTC

[trafficserver] 13/23: Step 13: Removes openFile() and closeFile()

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit af5c885368fe5175902ba196f74a522cbe7dbd47
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Fri May 24 16:52:10 2019 -0600

    Step 13: Removes openFile() and closeFile()
---
 mgmt/Rollback.cc | 45 ---------------------------------------------
 mgmt/Rollback.h  |  5 -----
 2 files changed, 50 deletions(-)

diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 6fa04f2..b89f17a 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -158,51 +158,6 @@ Rollback::statFile(version_t version, struct stat *buf)
   return statResult;
 }
 
-//
-// int Rollback::openFile(version_t)
-//
-//  a wrapper for open()
-//
-int
-Rollback::openFile(version_t version, int oflags, int *errnoPtr)
-{
-  int fd;
-
-  ats_scoped_str filePath(createPathStr(version));
-  // TODO: Use the original permissions
-  //       Anyhow the _1 files should not be created inside Syconfdir.
-  //
-  fd = mgmt_open_mode_elevate(filePath, oflags, 0644, root_access_needed);
-
-  if (fd < 0) {
-    if (errnoPtr != nullptr) {
-      *errnoPtr = errno;
-    }
-    mgmt_log("[Rollback::openFile] Open of %s failed: %s\n", fileName, strerror(errno));
-  } else {
-    fcntl(fd, F_SETFD, FD_CLOEXEC);
-  }
-
-  return fd;
-}
-
-int
-Rollback::closeFile(int fd, bool callSync)
-{
-  int result = 0;
-  if (callSync && fsync(fd) < 0) {
-    result = -1;
-    mgmt_log("[Rollback::closeFile] fsync failed for file '%s' (%d: %s)\n", fileName, errno, strerror(errno));
-  }
-
-  if (result == 0) {
-    result = close(fd);
-  } else {
-    close(fd);
-  }
-  return result;
-}
-
 bool
 Rollback::setLastModifiedTime()
 {
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index ae6d990..8b8d5a5 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -85,9 +85,6 @@ struct versionInfo {
 //    refers to a file with an _version which does not exist for the active
 //    version.
 //
-//  openFile(version_t version, int oflags) - a wrapper for open
-//    opens a file based on version number
-//
 //  statFile(version_t, struct stat*) - a wrapper for stat that
 //    that stats the specified version
 //
@@ -175,8 +172,6 @@ public:
   Rollback &operator=(const Rollback &) = delete;
 
 private:
-  int openFile(version_t version, int oflags, int *errnoPtr = nullptr);
-  int closeFile(int fd, bool callSync);
   int statFile(version_t version, struct stat *buf);
   char *createPathStr(version_t version);
   ink_mutex fileAccessLock;