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()
Definition: XrdPfc.hh:283

◆ ~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:281
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  [[fallthrough]];
117  case -ENOENT: rc = SFS_OK;
118  break;
119  case -EBUSY: ec = ENOTTY;
120  rc = SFS_ERROR;
121  msg = "file is in use";
122  break;
123  case -EAGAIN: rc = 5;
124  break;
125  default: rc = SFS_ERROR;
126  msg = "unlink failed";
127  break;
128  }
129  TRACE(Info,"Cache "<<xeq<<' '<<path<<" rc="<<ec<<" ec="<<ec<<" msg="<<msg);
130  } else {
131  ec = EINVAL;
132  rc = SFS_ERROR;
133  }
134 
135  if (!strcmp(xeq, "cached"))
136  {
137  const char* path = args.ArgP[0];
138  int rval = myCache.ConsiderCached(path);
139  if (rval == 0)
140  {
141  rc = SFS_OK;
142  ec = 0;
143  }
144  else
145  {
146  ec = ETIME;
147  rc = SFS_ERROR;
148  TRACE(Info,"Cache "<<xeq<<' '<<path<<" rc="<<ec<<" ec="<<ec<<" msg=file not in cache");
149  }
150  }
151 
152 // Return result
153 //
154  eInfo.setErrInfo(ec, msg);
155  return rc;
156 }
@ Info
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:999
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(), 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: