From 7e3e879a76a2425de593880d745a7c204f30d93c Mon Sep 17 00:00:00 2001 From: Alja Mrak-Tadel Date: Thu, 2 Apr 2015 10:33:38 -0700 Subject: [PATCH] Support path with root:// prefix and check oss.localroot in configiration file. --- src/XrdFileCache/XrdFileCachePrint.cc | 41 +++++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/XrdFileCache/XrdFileCachePrint.cc b/src/XrdFileCache/XrdFileCachePrint.cc index 9a46536038f..56e8b0a590f 100644 --- a/src/XrdFileCache/XrdFileCachePrint.cc +++ b/src/XrdFileCache/XrdFileCachePrint.cc @@ -126,25 +126,20 @@ void Print::printDir(XrdOssDF* iOssDF, const std::string& path) //______________________________________________________________________________ - int main(int argc, char *argv[]) { - static const char* usage = "Usage: pfc_print [-c config_file] [-v] path\n\n"; bool verbose = false; const char* cfgn = 0; XrdOucEnv myEnv; - int efs = open("/dev/null",O_RDWR, 0); - XrdSysLogger ossLog(efs); - XrdSysError ossErr(&ossLog, "print"); XrdSysLogger log; XrdSysError err(&log); - XrdOucStream Config(&ossErr, getenv("XRDINSTANCE"), &myEnv, "=====> "); - XrdOucArgs Spec(&ossErr, "pfc_print: ", "", + XrdOucStream Config(&err, getenv("XRDINSTANCE"), &myEnv, "=====> "); + XrdOucArgs Spec(&err, "pfc_print: ", "", "verbose", 1, "v", "config", 1, "c", (const char *)0); @@ -159,6 +154,8 @@ int main(int argc, char *argv[]) { case 'c': { cfgn = Spec.getarg(); + int fd = open(cfgn, O_RDONLY, 0); + Config.Attach(fd); break; } case 'v': { @@ -172,6 +169,11 @@ int main(int argc, char *argv[]) } } + + // suppress oss init messages + int efs = open("/dev/null",O_RDWR, 0); + XrdSysLogger ossLog(efs); + XrdSysError ossErr(&ossLog, "print"); XrdOss *oss; XrdOfsConfigPI *ofsCfg = XrdOfsConfigPI::New(cfgn,&Config,&ossErr); bool ossSucc = ofsCfg->Load(XrdOfsConfigPI::theOssLib); @@ -181,14 +183,35 @@ int main(int argc, char *argv[]) } ofsCfg->Plugin(oss); - const char* path = Spec.getarg(); if (!path) { printf("%s", usage); exit(1); } - XrdFileCache::Print p(oss, verbose, path); + // append oss.localroot if path starts with 'root://' + if (!strncmp(&path[0], "root://", 7)) { + if (Config.FDNum() < 0) { + printf("Configuration file not specified.\n"); + exit(1); + } + char *var; + while((var = Config.GetFirstWord())) + { + // printf("var %s \n", var); + if (!strncmp(var,"oss.localroot", strlen("oss.localroot"))) + { + std::string tmp = Config.GetWord(); + tmp += "/"; + tmp += &path[7]; + // printf("Absolute path %s \n", tmp.c_str()); + XrdFileCache::Print p(oss, verbose, tmp.c_str()); + } + } + } + else { + XrdFileCache::Print p(oss, verbose, path); + } }