Skip to content

Commit

Permalink
Implement Fstat.
Browse files Browse the repository at this point in the history
  • Loading branch information
alja authored and abh3 committed Jun 30, 2016
1 parent 87ea7dd commit 006240b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/XrdFileCache/XrdFileCacheIOEntireFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//----------------------------------------------------------------------------------

#include <stdio.h>
#include <fcntl.h>

//#include "XrdClient/XrdClientConst.hh"
#include "XrdSys/XrdSysError.hh"
Expand All @@ -26,6 +27,8 @@
#include "XrdFileCacheIOEntireFile.hh"
#include "XrdFileCacheStats.hh"

#include "XrdOuc/XrdOucEnv.hh"

using namespace XrdFileCache;

//______________________________________________________________________________
Expand All @@ -46,6 +49,31 @@ IOEntireFile::IOEntireFile(XrdOucCacheIO2 *io, XrdOucCacheStats &stats, Cache &
IOEntireFile::~IOEntireFile()
{}

int IOEntireFile::Fstat(struct stat &sbuff)
{
XrdCl::URL url(m_io->Path());
std::string name = url.GetPath();
name += ".cinfo";
printf("AMT IOEntireFile::Fstat get stat for path%s \n", name.c_str());
if (m_cache.GetOss()->Stat(name.c_str(), &sbuff) == XrdOssOK) {
XrdOssDF* infoFile = m_cache.GetOss()->newFile(Cache::GetInstance().RefConfiguration().m_username.c_str());
XrdOucEnv myEnv;
int res = infoFile->Open(name.c_str(), O_RDONLY, 0600, myEnv);
if (res < 0) return res;
Info info(0);
if (info.Read(infoFile) < 0) return -1;

sbuff.st_size = info.GetFileSize();
printf("AMT IONETIREFILE::Stat %ld\n", sbuff.st_size);
infoFile->Close();
delete infoFile;
return 0;
}
else {
return m_io->Fstat(sbuff);
}
}

bool IOEntireFile::ioActive()
{
return m_file->InitiateClose();
Expand All @@ -72,12 +100,8 @@ void IOEntireFile::Read (XrdOucCacheIOCB &iocb, char *buff, long long offs, int

int IOEntireFile::Read (char *buff, long long off, int size)
{


clLog()->Debug(XrdCl::AppMsg, "IOEntireFile::Read() [%p] %lld@%d %s", this, off, size, m_io->Path());

return m_io->Read(buff, off, size);

// protect from reads over the file size
// if (off >= m_io->FSize())
// return 0;
Expand Down
3 changes: 3 additions & 0 deletions src/XrdFileCache/XrdFileCacheIOEntireFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ namespace XrdFileCache
//! Called to check if destruction needs to be done in a separate task.
virtual bool ioActive();

virtual int Fstat(struct stat &sbuff);


private:
File* m_file;
};
Expand Down

0 comments on commit 006240b

Please sign in to comment.