XRootD
XrdPfcFSctl Class Reference

#include <XrdPfcFSctl.hh>

+ Inheritance diagram for XrdPfcFSctl:
+ Collaboration diagram for XrdPfcFSctl:

Public Member Functions

 XrdPfcFSctl (XrdPfc::Cache &cInst, XrdSysLogger *logP)
 Constructor. More...
 
virtual ~XrdPfcFSctl ()
 Destructor. More...
 
virtual bool Configure (const char *CfgFN, const char *Parms, XrdOucEnv *envP, const Plugins &plugs) override
 
virtual int FSctl (const int cmd, int alen, const char *args, XrdSfsFile &file, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0) override
 
virtual int FSctl (const int cmd, XrdSfsFSctl &args, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0) override
 
- Public Member Functions inherited from XrdOfsFSctl_PI
 XrdOfsFSctl_PI ()
 Constructor. More...
 
virtual ~XrdOfsFSctl_PI ()
 Destructor. More...
 

Additional Inherited Members

- Protected Attributes inherited from XrdOfsFSctl_PI
XrdSysErroreDest
 
XrdOfsFSctl_PIprvPI
 

Detailed Description

Definition at line 46 of file XrdPfcFSctl.hh.

Constructor & Destructor Documentation

◆ XrdPfcFSctl()

XrdPfcFSctl::XrdPfcFSctl ( XrdPfc::Cache cInst,
XrdSysLogger logP 
)

Constructor.

Definition at line 49 of file XrdPfcFSctl.cc.

50  : myCache(cInst), hProc(0), Log(logP, "PfcFsctl"),
51  sysTrace(cInst.GetTrace()), m_traceID("PfcFSctl") {}
XrdSysTrace * GetTrace() const
Definition: XrdPfc.hh:295

◆ ~XrdPfcFSctl()

virtual XrdPfcFSctl::~XrdPfcFSctl ( )
inlinevirtual

Destructor.

Definition at line 76 of file XrdPfcFSctl.hh.

76 {}

Member Function Documentation

◆ Configure()

bool XrdPfcFSctl::Configure ( const char *  CfgFN,
const char *  Parms,
XrdOucEnv envP,
const Plugins plugs 
)
overridevirtual

Configure plugin.

Parameters
CfgFN- Path of the configuration file.
Parms- Any parameters specified on the directive (may be null).
envP- Pointer to environmental information
plugs- Reference to the struct containing plugin pointers. Unloaded plugins have a nil pointer.
Returns
True upon success and false otherwise.

Reimplemented from XrdOfsFSctl_PI.

Definition at line 57 of file XrdPfcFSctl.cc.

61 {
62 // All we are interested in is getting the file handle handler pointer
63 //
64  hProc = (XrdOfsHandle*)envP->GetPtr("XrdOfsHandle*");
65  return hProc != 0;
66 }
void * GetPtr(const char *varname)
Definition: XrdOucEnv.cc:263
XrdOucEnv * envP
Definition: XrdPss.cc:109

References XrdProxy::envP, and XrdOucEnv::GetPtr().

+ Here is the call graph for this function:

◆ FSctl() [1/2]

int XrdPfcFSctl::FSctl ( const int  cmd,
int  alen,
const char *  args,
XrdSfsFile file,
XrdOucErrInfo eInfo,
const XrdSecEntity client = 0 
)
overridevirtual

Perform a file control operation

Parameters
cmd- The operation to be performed: SFS_FCTL_SPEC1 Return Implementation Dependent Data
alen- The length of args.
args- Arguments specific to cmd. SFS_FCTL_SPEC1 Unscreened args string.
file- Reference to the target file object.
eInfo- The object where error info or results are to be returned.
client- Client's identify (see common description).
Returns
SFS_OK a null response is sent. SFS_DATA error.code length of the data to be sent. error.message contains the data to be sent. o/w one of SFS_ERROR, SFS_REDIRECT, or SFS_STALL.

Implements XrdOfsFSctl_PI.

Definition at line 72 of file XrdPfcFSctl.cc.

78 {
79  eInfo.setErrInfo(ENOTSUP, "File based fstcl not supported for a cache.");
80  return SFS_ERROR;
81 }
#define SFS_ERROR
int setErrInfo(int code, const char *emsg)

References XrdOucErrInfo::setErrInfo(), and SFS_ERROR.

+ Here is the call graph for this function:

◆ FSctl() [2/2]

int XrdPfcFSctl::FSctl ( const int  cmd,
XrdSfsFSctl args,
XrdOucErrInfo eInfo,
const XrdSecEntity client = 0 
)
overridevirtual

Perform a filesystem control operation (version 2)

Parameters
cmd- The operation to be performed: SFS_FSCTL_PLUGIN Return Implementation Dependent Data v1 SFS_FSCTL_PLUGIO Return Implementation Dependent Data v2
args- Arguments specific to cmd. SFS_FSCTL_PLUGIN path and opaque information, fileP == 0 SFS_FSCTL_PLUGIO Unscreened argument string, fileP == 0
eInfo- The object where error info or results are to be returned.
client- Client's identify (see common description).
Returns
SFS_OK a null response is sent. SFS_DATA error.code length of the data to be sent. error.message contains the data to be sent. o/w one of SFS_ERROR, SFS_REDIRECT, or SFS_STALL.

Implements XrdOfsFSctl_PI.

Definition at line 87 of file XrdPfcFSctl.cc.

91 {
92  const char *msg = "", *xeq = args.Arg1;
93  int ec, rc;
94 
95 // Verify command
96 //
97  if (cmd != SFS_FSCTL_PLUGXC)
98  {eInfo.setErrInfo(EIDRM, "None-cache command issued to a cache.");
99  return SFS_ERROR;
100  }
101 
102 // Very that we have a command
103 //
104  if (!xeq || args.Arg1Len < 1)
105  {eInfo.setErrInfo(EINVAL, "Missing cache command or argument.");
106  return SFS_ERROR;
107  }
108 
109 // Process command
110 //
111  if ((!strcmp(xeq, "evict") || !strcmp(xeq, "fevict")) && args.Arg2Len == -2)
112  {std::string path = args.ArgP[0];
113  ec = myCache.UnlinkFile(path, *xeq != 'f');
114  switch(ec)
115  {case 0: if (hProc) hProc->Hide(path.c_str());
116  rc = SFS_OK;
117  break;
118  case -ENOENT: ec = ENOENT;
119  rc = SFS_ERROR;
120  msg = "file does not exist";
121  break;
122  case -EBUSY: ec = ENOTTY;
123  rc = SFS_ERROR;
124  msg = "file is in use";
125  break;
126  case -EAGAIN: rc = 5;
127  break;
128  default: rc = SFS_ERROR;
129  msg = "unlink failed";
130  break;
131  }
132  TRACE(Info,"Cache "<<xeq<<' '<<path<<" rc="<<ec<<" ec="<<ec<<" msg="<<msg);
133  } else {
134  ec = EINVAL;
135  rc = SFS_ERROR;
136  }
137 
138  if (!strcmp(xeq, "cached"))
139  {
140  const char* path = args.ArgP[0];
141  int rval = myCache.ConsiderCached(path);
142  if (rval == 0)
143  {
144  rc = SFS_OK;
145  ec = 0;
146  }
147  else
148  {
149  ec = ETIME;
150  rc = SFS_ERROR;
151  TRACE(Info,"Cache "<<xeq<<' '<<path<<" rc="<<ec<<" ec="<<ec<<" msg=file not in cache");
152  }
153  }
154 
155 // Return result
156 //
157  eInfo.setErrInfo(ec, msg);
158  return rc;
159 }
const char * Arg1
PLUGINO, PLUGION, PLUGXC.
int Arg2Len
Length or -count of args in extension.
int Arg1Len
Length.
#define SFS_OK
#define SFS_FSCTL_PLUGXC
#define TRACE(act, x)
Definition: XrdTrace.hh:63
static void Hide(const char *thePath)
virtual int ConsiderCached(const char *url)
Definition: XrdPfc.cc:1000
int UnlinkFile(const std::string &f_name, bool fail_if_open)
Remove cinfo and data files from cache.
Definition: XrdPfc.cc:1188

References XrdSfsFSctl::Arg1, XrdSfsFSctl::Arg1Len, XrdSfsFSctl::Arg2Len, XrdPfc::Cache::ConsiderCached(), ec, ETIME, XrdOfsHandle::Hide(), TPC::Info, XrdOucErrInfo::setErrInfo(), SFS_ERROR, SFS_FSCTL_PLUGXC, SFS_OK, TRACE, and XrdPfc::Cache::UnlinkFile().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: