Skip to content

Commit

Permalink
Move implementation of osx posix_fallocate to XrdSysFallocate.
Browse files Browse the repository at this point in the history
  • Loading branch information
osschar committed Sep 20, 2018
1 parent 34395bc commit fbbae41
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/XrdFileCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ add_library(
XrdFileCache/XrdFileCacheIO.cc XrdFileCache/XrdFileCacheIO.hh
XrdFileCache/XrdFileCacheIOEntireFile.cc XrdFileCache/XrdFileCacheIOEntireFile.hh
XrdFileCache/XrdFileCacheIOFileBlock.cc XrdFileCache/XrdFileCacheIOFileBlock.hh
XrdFileCache/XrdFileCacheDecision.hh
XrdFileCache/posix_fallocate_osx.hh)
XrdFileCache/XrdFileCacheDecision.hh)

target_link_libraries(
${LIB_XRD_FILECACHE}
Expand Down
5 changes: 1 addition & 4 deletions src/XrdFileCache/XrdFileCacheCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "XrdOuc/XrdOucEnv.hh"
#include "XrdOuc/XrdOucStream.hh"
#include "XrdSys/XrdSysLogger.hh"
#include "XrdSys/XrdSysFallocate.hh"

#include <algorithm>
#include <cstring>
Expand All @@ -35,10 +36,6 @@
#include <vector>
#include <sys/time.h>

#ifdef __APPLE__
#include "posix_fallocate_osx.hh"
#endif

using namespace XrdFileCache;

//______________________________________________________________________________
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------------

// Implementation of posix_allocate for OSX.

#ifdef __APPLE__

#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
Expand Down Expand Up @@ -69,7 +73,7 @@
// file descriptions associated with the file.


static int posix_fallocate(int fd, off_t offset, off_t len)
int posix_fallocate(int fd, off_t offset, off_t len)
{
off_t c_test;
int ret;
Expand All @@ -92,3 +96,5 @@ static int posix_fallocate(int fd, off_t offset, off_t len)
}
return ret;
}

#endif
35 changes: 35 additions & 0 deletions src/XrdSys/XrdSysFallocate.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//----------------------------------------------------------------------------------
// 1. The Original Code is Mozilla code.
// The Initial Developer of the Original Code is Mozilla Foundation.
// Portions created by the Initial Developer are Copyright (C) 2010 the Initial Developer. All Rights Reserved.
// Contributor(s): Taras Glek <tglek@mozilla.com>
// 2. Created from the OSX-specific code from Mozilla's mozilla::fallocation() function.
// Adaptation (C) 2015,2016 R.J.V. Bertin for KDE, project.
//
// Original license allows modification / redistribution under LGPL 2.1 or higher.
//----------------------------------------------------------------------------------
// XRootD is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// XRootD is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------------

// Implementation of posix_allocate for OSX.

#ifdef __APPLE__

extern int posix_fallocate(int fd, off_t offset, off_t len);

#else

#include <fcntl.h>

#endif
2 changes: 2 additions & 0 deletions src/XrdUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ add_library(
XrdSys/XrdSysLogPI.hh
XrdSys/XrdSysLinuxSemaphore.hh
XrdSys/XrdSysXAttr.cc XrdSys/XrdSysXAttr.hh
XrdSys/XrdSysFallocate.cc XrdSys/XrdSysFallocate.hh


#-----------------------------------------------------------------------------
# XrdOuc
Expand Down

1 comment on commit fbbae41

@abh3
Copy link
Member

@abh3 abh3 commented on fbbae41 Sep 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost. I see that the obvioous place in the cmakle file is not so obvious. Normally, we list these in alphabetic order could you rearrange the "XrdSys/XrdSysFallocate.cc XrdSys/XrdSysFallocate.hh" to be in the right collating sequence?

Please sign in to comment.