Commit 00fe3547 authored by Elvin Sindrilaru's avatar Elvin Sindrilaru

MGM/CONSOLE: Display full namespace path if available in the output of the "file check"

command when we're given the fid/fxid. Fixes EOS-3269
parent ad16423a
Pipeline #706072 failed with stages
in 32 minutes and 55 seconds
......@@ -796,11 +796,11 @@ com_file(char* arg1)
int envlen = 0;
XrdOucEnv* newresult = new XrdOucEnv(result->Env(envlen));
delete result;
XrdOucString checksumattribute = "NOTREQUIRED";
bool consistencyerror = false;
if (envlen) {
XrdOucString ns_path = newresult->Get("mgm.nspath");
XrdOucString checksumtype = newresult->Get("mgm.checksumtype");
XrdOucString checksum = newresult->Get("mgm.checksum");
XrdOucString size = newresult->Get("mgm.size");
......@@ -808,7 +808,7 @@ com_file(char* arg1)
if ((option.find("%silent") == STR_NPOS) && (!silent)) {
fprintf(stdout, "path=\"%s\" fxid=\"%4s\" size=\"%s\" nrep=\"%s\" "
"checksumtype=\"%s\" checksum=\"%s\"\n",
path.c_str(), newresult->Get("mgm.fid0"),
ns_path.c_str(), newresult->Get("mgm.fid0"),
size.c_str(), newresult->Get("mgm.nrep"),
checksumtype.c_str(), newresult->Get("mgm.checksum"));
}
......@@ -855,7 +855,6 @@ com_file(char* arg1)
XrdOucString bs = newresult->Get(repbootstat.c_str());
bool down = (bs != "booted");
int retc = 0;
int oldsilent = silent;
struct eos::fst::Fmd fmd;
......@@ -1027,7 +1026,7 @@ com_file(char* arg1)
}
if (consistencyerror) {
global_retc = EFAULT;
global_retc = EFAULT;
}
delete newresult;
......
......@@ -50,7 +50,8 @@ ProcCommand::File()
XrdOucString spathid = pOpaque->Get("mgm.file.id");
if (spathid.length()) {
GetPathFromFid(spath, std::strtoull(spathid.c_str(), nullptr, 10), "Cannot get fid");
GetPathFromFid(spath, std::strtoull(spathid.c_str(), nullptr, 10),
"Cannot get fid");
} else {
spath = pOpaque->Get("mgm.path");
}
......@@ -88,7 +89,6 @@ ProcCommand::File()
unsigned long fsid = (sfsid.length()) ? strtoul(sfsid.c_str(), 0, 10) : 0;
unsigned long fid = (spathid.length()) ? strtoul(spathid.c_str(), 0, 10) : 0;
if (gOFS->_dropstripe(spath.c_str(), fid, *mError, *pVid, fsid, forceRemove)) {
stdErr += "error: unable to drop stripe";
retc = errno;
......@@ -138,8 +138,8 @@ ProcCommand::File()
if ((spath.beginswith("fid:") || (spath.beginswith("fxid:")))) {
WAIT_BOOT;
unsigned long long fid = Resolver::retrieveFileIdentifier(spath).getUnderlyingUInt64();
unsigned long long fid = Resolver::retrieveFileIdentifier(
spath).getUnderlyingUInt64();
// reference by fid+fsid
//-------------------------------------------
gOFS->eosViewRWMutex.LockWrite();
......@@ -266,7 +266,8 @@ ProcCommand::File()
if ((spath.beginswith("fid:") || (spath.beginswith("fxid:")))) {
WAIT_BOOT;
unsigned long long fid = Resolver::retrieveFileIdentifier(spath).getUnderlyingUInt64();
unsigned long long fid = Resolver::retrieveFileIdentifier(
spath).getUnderlyingUInt64();
// -------------------------------------------------------------------
// reference by fid+fsid
......@@ -288,7 +289,6 @@ ProcCommand::File()
// -------------------------------------------------------------------
// reference by path
// -------------------------------------------------------------------
try {
fmd = gOFS->eosView->getFile(spath.c_str());
} catch (eos::MDException& e) {
......@@ -474,8 +474,8 @@ ProcCommand::File()
} else {
XrdOucString httppath = "http://";
httppath += gOFS->HostName;
httppath += ":";
httppath += gOFS->mHttpdPort;
httppath += ":";
httppath += gOFS->mHttpdPort;
httppath += "/";
size_t qpos = sharepath.find("?");
std::string httpunenc = sharepath;
......@@ -587,8 +587,8 @@ ProcCommand::File()
//-------------------------------------------
// reference by fid+fsid
//-------------------------------------------
unsigned long long fid = Resolver::retrieveFileIdentifier(spath).getUnderlyingUInt64();
unsigned long long fid = Resolver::retrieveFileIdentifier(
spath).getUnderlyingUInt64();
eos::common::RWMutexReadLock lock(gOFS->eosViewRWMutex);
std::shared_ptr<eos::IFileMD> fmd;
......@@ -1240,8 +1240,8 @@ ProcCommand::File()
// Reference by fid+fsid
if ((spath.beginswith("fid:") || (spath.beginswith("fxid:")))) {
WAIT_BOOT;
unsigned long long fid = Resolver::retrieveFileIdentifier(spath).getUnderlyingUInt64();
unsigned long long fid = Resolver::retrieveFileIdentifier(
spath).getUnderlyingUInt64();
try {
fmd = gOFS->eosFileService->getFileMD(fid);
......@@ -1685,18 +1685,20 @@ ProcCommand::File()
} else {
std::shared_ptr<eos::IFileMD> fmd;
//-------------------------------------------
std::string ns_path {};
eos::common::RWMutexReadLock lock(gOFS->eosViewRWMutex);
try {
if ((spath.beginswith("fid:") || (spath.beginswith("fxid:")))) {
WAIT_BOOT;
unsigned long long fid = Resolver::retrieveFileIdentifier(spath).getUnderlyingUInt64();
unsigned long long fid = Resolver::retrieveFileIdentifier(
spath).getUnderlyingUInt64();
// reference by fid+fsid
//-------------------------------------------
fmd = gOFS->eosFileService->getFileMD(fid);
} else {
fmd = gOFS->eosView->getFile(spath.c_str());
ns_path = spath.c_str();
}
} catch (eos::MDException& e) {
errno = e.getErrno();
......@@ -1710,6 +1712,15 @@ ProcCommand::File()
if (!fmd) {
retc = errno;
} else {
if (ns_path.empty()) {
try {
ns_path = gOFS->eosView->getUri(fmd.get());
} catch (const eos::MDException& e) {
// File is no longer attached to a cointainer put only the name
ns_path = fmd->getName();
}
}
XrdOucString sizestring;
eos::IFileMD::LocationVector::const_iterator lociter;
int i = 0;
......@@ -1727,7 +1738,6 @@ ProcCommand::File()
stdOut += "&";
stdOut += "mgm.checksum=";
eos::appendChecksumOnStringAsHex(fmd.get(), stdOut, 0x00, SHA_DIGEST_LENGTH);
stdOut += "&";
stdOut += "mgm.stripes=";
stdOut += (int)(eos::common::LayoutId::GetStripeNumber(fmd->getLayoutId()) + 1);
......@@ -1782,6 +1792,9 @@ ProcCommand::File()
fullpath);
stdOut += fullpath;
stdOut += "&";
stdOut += "mgm.nspath=";
stdOut += ns_path.c_str();
stdOut += "&";
} else {
stdOut += "NA&";
}
......
Markdown is supported
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