Loading...
Searching...
No Matches
XrdOssSIgpfsT.cc
Go to the documentation of this file.
/******************************************************************************/
/* */
/* X r d O s s S I g p f s T . c c */
/* */
/* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */
/* All Rights Reserved */
/* Produced by Andrew Hanushevsky for Stanford University under contract */
/* DE-AC02-76-SFO0515 with the Department of Energy */
/* */
/* This file is part of the XRootD software suite. */
/* */
/* 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 Lesser General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
/* */
/* The copyright holder's institutional names and contributor's names may not */
/* be used to endorse or promote products derived from this software without */
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <strings.h>
#include <cstring>
#include <cstdlib>
#include "XrdVersion.hh"
#include "XrdOss/XrdOss.hh"
#include "XrdOss/XrdOssStatInfo.hh"
#include "XrdOuc/XrdOucEnv.hh"
#include "XrdSys/XrdSysError.hh"
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
extern "C"
{
/******************************************************************************/
/* X r d O s s S t a t I n f o R e s O n l y */
/******************************************************************************/
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int XrdOssStatInfoResOnly = ENOENT;
/******************************************************************************/
/* X r d O s s S t a t I n f o */
/******************************************************************************/
int XrdOssStatInfo(const char *path, struct stat *buff,
int opts, XrdOucEnv *envP)
{
// Do a regular stat and if it fails return immediately
//
if (stat(path, buff)) return -1;
// Check if this is an online file, return success
//
if (buff->st_size == 0 || buff->st_blocks) return 0;
// If caller only wants resident files, then return ENOENT. If we are
// restricting the caller to residdent only files, return the proper errno.
// Otherwise, we indicate the file actually exists.
//
if (opts & XRDOSS_resonly) errno = ENOENT;
else errno = XrdOssStatInfoResOnly;
return (errno ? -1 : 0);
}
/******************************************************************************/
/* X r d O s s S t a t I n f o P a r m */
/******************************************************************************/
int XrdOssStatInfoParm(XrdSysError &eDest, const char *var, const char *val)
{
if (!strcmp(val, "all")) return 0;
else if (!strcmp(val, "online")) return ENOENT;
else if (!strcmp(val, "online:eperm")) return EPERM;
eDest.Say("Config", " Invalid statlib parameter, '",var,"=",val,"'.");
return -1;
}
/******************************************************************************/
/* X r d O s s S t a t I n f o I n i t */
/******************************************************************************/
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
XrdOssStatInfo_t XrdOssStatInfoInit(XrdOss *native_oss,
XrdSysLogger *Logger,
const char *config_fn,
const char *parms)
{
const char *myProg = getenv("XRDPROG");
const char *myRole = getenv("XRDROLE");
const char *xWhat = " only online ";
XrdSysError Say(Logger, "");
XrdOucEnv myEnv(parms);
char zRole[16], vChk[512], *val;
int offLine = 0;
// Readjust the role to be backwards compatible
//
if (myRole)
{ if (!strncmp("proxy", myRole, 5))
{strcpy(zRole, "proxy"); myRole = zRole;}
else if (!strncmp("meta", myRole, 4))
{strcpy(zRole, "manager"); myRole = zRole;}
}
// Check for global parms first
//
strcpy(vChk, "stat");
if ((val = myEnv.Get(vChk))
&& (offLine = XrdOssStatInfoParm(Say, vChk, val)) < 0) return 0;
// Check for program specific variable
//
if (myProg)
{strcat(vChk, "."); strcat(vChk, myProg);
if ((val = myEnv.Get(vChk))
&& (offLine = XrdOssStatInfoParm(Say, vChk, val)) < 0) return 0;
}
// Check for role specific variable
//
if (myProg && myRole)
{strcat(vChk, "."); strcat(vChk, myRole);
if ((val = myEnv.Get(vChk))
&& (offLine = XrdOssStatInfoParm(Say, vChk, val)) < 0) return 0;
}
// Now set the global variable indicate whether we will only allow online
// files or all files (i.e. online and offline).
//
XrdOssStatInfoResOnly = offLine;
// Record in the log what stat will stat
//
if (myProg) strncpy(vChk, " for ", 6);
else *vChk = 0;
if (!XrdOssStatInfoResOnly) xWhat = " all ";
Say.Say("Config", " stat() allows", xWhat, "files", vChk);
// Return the stat function
//
return (XrdOssStatInfo_t)XrdOssStatInfo;
}
};
/******************************************************************************/
/* V e r s i o n I n f o r m a t i o n */
/******************************************************************************/
XrdVERSIONINFO(XrdOssStatInfoInit,Stat-GPFS+TAPE);
Stat
struct stat Stat
Definition XrdCks.cc:49
Say
XrdOucPup XrdCmsParser::Pup & Say
Definition XrdCmsParser.cc:124
Logger
static XrdSysLogger Logger
Definition XrdCryptoAux.cc:37
eDest
static XrdSysError eDest(0,"crypto_")
XrdOssStatInfoParm
int XrdOssStatInfoParm(XrdSysError &eDest, const char *var, const char *val)
Definition XrdOssSIgpfsT.cc:109
XrdOssStatInfoResOnly
int XrdOssStatInfoResOnly
Definition XrdOssSIgpfsT.cc:78
XrdOssStatInfo
int XrdOssStatInfo(const char *path, struct stat *buff, int opts, XrdOucEnv *envP)
Definition XrdOssSIgpfsT.cc:84
XrdOssStatInfoInit
XrdOssStatInfo_t XrdOssStatInfoInit(XrdOss *native_oss, XrdSysLogger *Logger, const char *config_fn, const char *parms)
Definition XrdOssSIgpfsT.cc:132
XrdVERSIONINFO
XrdVERSIONINFO(XrdOssStatInfoInit, Stat-GPFS+TAPE)
XrdOssStatInfo.hh
XrdOssStatInfo_t
int(* XrdOssStatInfo_t)(const char *path, struct stat *buff, int opts, XrdOucEnv *envP)
Definition XrdOssStatInfo.hh:90
XrdOss.hh
XRDOSS_resonly
#define XRDOSS_resonly
Definition XrdOss.hh:486
XrdOucEnv.hh
stat
#define stat(a, b)
Definition XrdPosix.hh:101
opts
struct myOpts opts
XrdSysError.hh
XrdOss
Definition XrdOss.hh:499
XrdOucEnv
Definition XrdOucEnv.hh:42
XrdOucEnv::Get
char * Get(const char *varname)
Definition XrdOucEnv.hh:69
XrdSysError
Definition XrdSysError.hh:90
XrdSysLogger
Definition XrdSysLogger.hh:53