32 #include <arpa/inet.h>
65 faCTL(
char *bp,
char *bz,
int anum)
67 vnsz(0), iNum(anum), iEnd(0), verr(false) {}
68 ~faCTL() {
if (info)
delete [] info;}
72 #define CRED (const XrdSecEntity *)Client
74 #define FATTR_NAMESPACE 'U'
82 XErrorCode Decode(faCTL &ctl,
int MaxNsz,
int MaxVsz)
84 char *bP = ctl.buff, *bend = ctl.bend;
91 for (
int i = 0; i < ctl.iNum; i++)
98 ctl.info[i].Name = bP;
105 if (!n || n > MaxNsz)
107 ctl.info[i].NLen = n;
113 ctl.vnsz = bP - ctl.buff;
119 for (
int i = 0; i < ctl.iNum; i++)
126 vsize = ntohl(vsize);
132 ctl.info[i].Value = bP;
133 ctl.info[i].VLen = vsize;
158 for (
int i = 0; i < inum; i++)
159 {
if (info[i].faRC == 0) info[i].
Name[0] = info[i].
Name[1] =
'\0';
162 memcpy(info[i].Name, &rc,
sizeof(rc));
182 struct iovec *Alloc(
int &num)
184 if (num > iovmax) num = iovmax;
185 theIOV =
new struct iovec[num];
189 IOVec() : theIOV(0) {}
190 ~IOVec() {
if (theIOV)
delete [] theIOV;}
193 struct iovec *theIOV;
207 snprintf(eBuff,
sizeof(eBuff),
"%s processing fattr %s argument #%d",
210 return Resp.
Send(eCode, eBuff);
232 int XrdXrootdProtocol::do_FAttr()
254 eTxt =
"Inspecting file attributes";
257 eTxt =
"Modifying file attributes";
264 "Required arguments for fattr request not present");
277 "fattr does not refer to an open file");
280 "fattr request modifies a file open for reading");
281 if (dlen) {dlen--; theArg++;}
283 return ProcFAttr(fp->
FileKey, 0, theArg, dlen, faCode,
false);
293 if (rpCheck(fn, &fnCgi))
return rpEmsg(eTxt, fn);
294 if (!(popt = Squash(fn)))
return vpEmsg(eTxt, fn);
301 return ProcFAttr(fn, fnCgi,
argp->
buff+n+1, dlen-n-1, faCode,
true);
308 int XrdXrootdProtocol::ProcFAttr(
char *faPath,
char *faCgi,
char *faArgs,
309 int faALen,
int faCode,
bool doAChk)
323 sfsCtl.nPfx[1] =
'.';
332 faCTL ctl(faArgs, faArgs+faALen, fNumAttr);
335 if (rc)
return SendErr(
Response, ctl, rc);
339 sfsCtl.info = ctl.info;
344 if (faCode ==
kXR_fattrDel)
return XeqFADel(sfsCtl, faArgs, ctl.vnsz);
345 if (faCode ==
kXR_fattrGet)
return XeqFAGet(sfsCtl, faArgs, ctl.vnsz);
346 if (faCode ==
kXR_fattrSet)
return XeqFASet(sfsCtl, faArgs, ctl.vnsz);
355 int XrdXrootdProtocol::XeqFADel(
XrdSfsFACtl &ctl,
char *faVars,
int faVLen)
377 iov[1].iov_base = faRC;
378 iov[1].iov_len =
sizeof(faRC);
379 iov[2].iov_base = faVars;
380 iov[2].iov_len = faVLen;
388 int XrdXrootdProtocol::XeqFAGet(
XrdSfsFACtl &ctl,
char *faVars,
int faVLen)
395 int k, rc, dlen, vLen;
412 int iovNum = ctl.
iNum*2+3;
413 iov = iovHelper.Alloc(iovNum);
417 iov[1].iov_base = faRC;
418 iov[1].iov_len =
sizeof(faRC);
419 iov[2].iov_base = faVars;
420 iov[2].iov_len = faVLen;
421 dlen =
sizeof(faRC) + faVLen;
426 for (
int i = 0; i < ctl.
iNum; i++)
434 iov[k++].iov_len = vLen;
458 int k = 1, rc = 0, dlen = 0, vLen;
467 int iovNum = ctl.
iNum*3+1;
468 iov = iovHelper.Alloc(iovNum);
472 for (
int i = 0; i < ctl.
iNum; i++)
485 iov[k++].iov_len = vLen;
491 k = 1; dlen = 0; xresp =
true;
510 struct iovec
iov[16];
549 if (i == (
int)
sizeof(
iov))
551 if (rc || dP == 0)
return rc;
566 int XrdXrootdProtocol::XeqFASet(
XrdSfsFACtl &ctl,
char *faVars,
int faVLen)
590 iov[1].iov_base = faRC;
591 iov[1].iov_len =
sizeof(faRC);
592 iov[2].iov_base = faVars;
593 iov[2].iov_len = faVLen;
struct ClientFattrRequest fattr
struct ClientRequestHdr header
char data[4]
Start of data.
int dlen
Data Length in subsequent buffer.
const kXR_char XROOTD_MON_OPENW
const kXR_char XROOTD_MON_OPENR
static const char * errName(kXR_int32 errCode)
static int mapError(int rc)
char * ID
Pointer to the client's link identity.
virtual int FAttr(XrdSfsFACtl *faReq, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0)
XrdXrootdFile * Get(int fnum)
static XrdXrootdXPath RPList
XrdXrootdFileTable * FTab
XrdXrootdMonitor::User Monitor
XrdXrootdResponse Response
static struct XrdXrootdProtocol::RD_Table Route[RD_Num]
static XrdSfsFileSystem * osFS
int Validate(const char *pd, const int pl=0)
XrdSfsFABuff * fabP
-> Additional memory that was allocated
static const int retval
Above plus return actual attr value.
const char * path
The file path to act on (logical)
unsigned char rqst
Type of file attribute request (see below)
const char * pcgi
Opaque information (null if none)
static const int accChk
Perform access check.
static const int newAtr
For set the attribute must not exist.
XrdSfsFAInfo * info
Pointer to attribute information.
unsigned char opts
Request options (see below)
unsigned short iNum
Number of info entries.
char * Name
Variable name.
int VLen
Variable value length (aligned)
char * Value
Variable value.
short NLen
Length of name not including null byte.
int faRC
Action return code for this element.