Commit cfd65df2 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Added the Murray bit (a.k.a. the Archive bit) in the listing

parent c376fafb
......@@ -43,8 +43,10 @@ cta::ArchiveDirEntry::ArchiveDirEntry() {
cta::ArchiveDirEntry::ArchiveDirEntry(
const EntryType type,
const std::string &name,
const ArchiveFileStatus &status):
const ArchiveFileStatus &status,
const std::list<NameServerTapeFile> &tapeCopies):
type(type),
name(name),
status(status) {
status(status),
tapeCopies(tapeCopies) {
}
......@@ -19,8 +19,10 @@
#pragma once
#include "common/archiveNS/ArchiveFileStatus.hpp"
#include "nameserver/NameServerTapeFile.hpp"
#include <string>
#include <list>
namespace cta {
......@@ -63,7 +65,7 @@ struct ArchiveDirEntry {
* @param status The status of the entry.
*/
ArchiveDirEntry(const EntryType type, const std::string &name,
const ArchiveFileStatus &status);
const ArchiveFileStatus &status, const std::list<NameServerTapeFile> &tapeCopies);
/**
* The type of the directory entry.
......@@ -79,6 +81,11 @@ struct ArchiveDirEntry {
* The status of the entry.
*/
ArchiveFileStatus status;
/**
* The tape copies associated to this file.
*/
std::list<NameServerTapeFile> tapeCopies;
}; // class ArchiveDirEntry
......
......@@ -116,7 +116,7 @@ void cta::CastorNameServer::addTapeFile(
//------------------------------------------------------------------------------
std::list<cta::NameServerTapeFile> cta::CastorNameServer::getTapeFiles(
const SecurityIdentity &requester,
const std::string &path) {
const std::string &path) const {
throw exception::Exception(std::string(__FUNCTION__) + " not implemented");
}
......@@ -335,8 +335,9 @@ cta::ArchiveDirEntry cta::CastorNameServer::getArchiveDirEntry(const SecurityIde
const Checksum checksum(Checksum::CHECKSUMTYPE_ADLER32, std::string(statbuf.csumvalue));
const uint64_t size(statbuf.filesize);
ArchiveFileStatus status(owner, statbuf.filemode, size, checksum, storageClassName);
const std::list<NameServerTapeFile> tapeCopies = getTapeFiles(requester, path);
return ArchiveDirEntry(entryType, name, status);
return ArchiveDirEntry(entryType, name, status, tapeCopies);
}
//------------------------------------------------------------------------------
......
......@@ -101,7 +101,7 @@ public:
*/
std::list<NameServerTapeFile> getTapeFiles(
const SecurityIdentity &requester,
const std::string &path);
const std::string &path) const;
/**
* Delete the specified tape file entry from the archive namespace.
......
......@@ -284,7 +284,7 @@ public:
*/
virtual std::list<NameServerTapeFile> getTapeFiles(
const SecurityIdentity &requester,
const std::string &path) = 0;
const std::string &path) const = 0;
}; // class NameServer
......
......@@ -250,7 +250,7 @@ void cta::MockNameServer::addTapeFile(const SecurityIdentity &requester, const s
//------------------------------------------------------------------------------
// getTapeFiles
//------------------------------------------------------------------------------
std::list<cta::NameServerTapeFile> cta::MockNameServer::getTapeFiles(const SecurityIdentity &requester, const std::string &path) {
std::list<cta::NameServerTapeFile> cta::MockNameServer::getTapeFiles(const SecurityIdentity &requester, const std::string &path) const {
Utils::assertAbsolutePathSyntax(path);
const std::string fsPath = m_fsDir + path;
assertFsFileExists(fsPath);
......@@ -624,8 +624,9 @@ cta::ArchiveDirEntry cta::MockNameServer::getArchiveDirEntry(
const uint64_t size = 1234;
ArchiveFileStatus status(owner, statResult.st_mode, size, checksum,
storageClassName);
const std::list<NameServerTapeFile> tapeCopies = getTapeFiles(requester, path);
return ArchiveDirEntry(entryType, name, status);
return ArchiveDirEntry(entryType, name, status, tapeCopies);
}
//------------------------------------------------------------------------------
......
......@@ -102,7 +102,7 @@ public:
*/
std::list<NameServerTapeFile> getTapeFiles(
const SecurityIdentity &requester,
const std::string &path);
const std::string &path) const;
/**
* Delete the specified tape file entry from the archive namespace.
......
......@@ -1141,7 +1141,22 @@ void XrdProFile::xCom_ls(const std::vector<std::string> &tokens, const cta::Secu
auto mode = dirEntry.status.mode;
const auto &owner = dirEntry.status.owner;
const auto storageClassName = dirEntry.status.storageClassName;
responseSS << ((dirEntry.type==dirEntry.ENTRYTYPE_DIRECTORY) ? "d" : "-")
std::string firstModeCharacter;
if(dirEntry.type==dirEntry.ENTRYTYPE_DIRECTORY) {
firstModeCharacter="d";
}
else if(dirEntry.type==dirEntry.ENTRYTYPE_FILE) {
if(dirEntry.tapeCopies.empty()) {
firstModeCharacter="-";
}
else{
firstModeCharacter="a"; //the Murray bit (a.k.a. the Archive bit: true if the file has at least one tape copy)
}
}
else {
firstModeCharacter="U"; //unknown directory entry type
}
responseSS << firstModeCharacter
<< ((mode & S_IRUSR) ? "r" : "-")
<< ((mode & S_IWUSR) ? "w" : "-")
<< ((mode & S_IXUSR) ? "x" : "-")
......@@ -1157,6 +1172,12 @@ void XrdProFile::xCom_ls(const std::vector<std::string> &tokens, const cta::Secu
<< " " << dirEntry.name
<< " " << dirEntry.status.checksum.str()
<< " " << dirEntry.status.size << std::endl;
for(auto i=dirEntry.tapeCopies.begin(); i!=dirEntry.tapeCopies.end(); i++) {
responseSS << " " << i->tapeFileLocation.copyNb
<< " " << i->tapeFileLocation.vid
<< " " << i->tapeFileLocation.fSeq
<< " " << i->tapeFileLocation.blockId << std::endl;
}
}
m_data = responseSS.str();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment