]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/DiskIO/Mmapped/MmappedFile.cc
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / DiskIO / Mmapped / MmappedFile.cc
index 314c934bdab6b4eadef34933f0980609701601d1..9eb6228ee244006cbdcb1b7b906fbe068fa89a34 100644 (file)
@@ -1,25 +1,29 @@
 /*
- * DEBUG: section 47    Store Directory Routines
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
+/* DEBUG: section 47    Store Directory Routines */
+
 #include "squid.h"
 #include "Debug.h"
 #include "DiskIO/IORequestor.h"
 #include "DiskIO/Mmapped/MmappedFile.h"
 #include "DiskIO/ReadRequest.h"
 #include "DiskIO/WriteRequest.h"
-#include "disk.h"
+#include "fs_io.h"
 #include "globals.h"
 
+#include <cerrno>
 #if HAVE_SYS_MMAN_H
 #include <sys/mman.h>
 #endif
 #if HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
 
 // Some systems such as Hurd provide mmap() API but do not support MAP_NORESERVE
 #ifndef MAP_NORESERVE
@@ -50,7 +54,7 @@ private:
 };
 
 MmappedFile::MmappedFile(char const *aPath): fd(-1),
-        minOffset(0), maxOffset(-1), error_(false)
+    minOffset(0), maxOffset(-1), error_(false)
 {
     assert(aPath);
     path_ = xstrdup(aPath);
@@ -65,20 +69,21 @@ MmappedFile::~MmappedFile()
 
 // XXX: almost a copy of BlockingFile::open
 void
-MmappedFile::open(int flags, mode_t mode, RefCount<IORequestor> callback)
+MmappedFile::open(int flags, mode_t, RefCount<IORequestor> callback)
 {
     assert(fd < 0);
 
     /* Simulate async calls */
-    fd = file_open(path_ , flags);
+    fd = file_open(path_, flags);
     ioRequestor = callback;
 
     if (fd < 0) {
-        debugs(79,3, HERE << "open error: " << xstrerror());
+        int xerrno = errno;
+        debugs(79,3, "open error: " << xstrerr(xerrno));
         error_ = true;
     } else {
         ++store_open_disk_fd;
-        debugs(79,3, HERE << "FD " << fd);
+        debugs(79,3, "FD " << fd);
 
         // setup mapping boundaries
         struct stat sb;
@@ -213,8 +218,8 @@ MmappedFile::ioInProgress() const
 }
 
 Mmapping::Mmapping(int aFd, size_t aLength, int aProt, int aFlags, off_t anOffset):
-        fd(aFd), length(aLength), prot(aProt), flags(aFlags), offset(anOffset),
-        delta(-1), buf(NULL)
+    fd(aFd), length(aLength), prot(aProt), flags(aFlags), offset(anOffset),
+    delta(-1), buf(NULL)
 {
 }
 
@@ -265,3 +270,4 @@ Mmapping::unmap()
 }
 
 // TODO: check MAP_NORESERVE, consider MAP_POPULATE and MAP_FIXED
+