65 faCTL(
char *bp,
char *bz,
int anum)
66 : info(new XrdSfsFAInfo[anum]), buff(bp), bend(bz),
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'
82XErrorCode 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));
182struct 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;}
207 snprintf(eBuff,
sizeof(eBuff),
"%s processing fattr %s argument #%d",
210 return Resp.
Send(eCode, eBuff);
232int XrdXrootdProtocol::do_FAttr()
236 int faCode =
static_cast<int>(
Request.fattr.subcode);
237 int popt, ropt, n, dlen =
Request.header.dlen;
254 eTxt =
"Inspecting file attributes";
257 eTxt =
"Modifying file attributes";
264 "Required arguments for fattr request not present");
270 if (!dlen ||
argp->buff[0] == 0)
272 XrdXrootdFHandle fh(
Request.fattr.fhandle);
273 char *theArg =
argp->buff;
275 if (!
FTab || !(fp =
FTab->Get(fh.handle)))
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);
289 n = strlen(
argp->buff);
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);
308int XrdXrootdProtocol::ProcFAttr(
char *faPath,
char *faCgi,
char *faArgs,
309 int faALen,
int faCode,
bool doAChk)
311 int fNumAttr =
static_cast<int>(
Request.fattr.numattr);
321 XrdSfsFACtl sfsCtl(faPath, faCgi, fNumAttr);
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);
355int XrdXrootdProtocol::XeqFADel(
XrdSfsFACtl &ctl,
char *faVars,
int faVLen)
368 if ((rc =
osFS->FAttr(&ctl, eInfo,
CRED)))
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;
381 return Response.Send(iov, 3,
sizeof(faRC) + faVLen);
388int XrdXrootdProtocol::XeqFAGet(
XrdSfsFACtl &ctl,
char *faVars,
int faVLen)
395 int k, rc, dlen, vLen;
403 if ((rc =
osFS->FAttr(&ctl, eInfo,
CRED)))
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++)
427 {iov[k ].iov_base = &ctl.
info[i].
VLen;
428 iov[k++].iov_len =
sizeof(ctl.
info[i].
VLen);
433 iov[k ].iov_base = (
void *)ctl.
info[i].
Value;
434 iov[k++].iov_len = vLen;
439 if ((rc =
Response.Send(rcode, iov, k, dlen)))
return rc;
446 return (dlen ?
Response.Send(iov, k, dlen) : 0);
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++)
474 iov[k ].iov_base = ctl.
info[i].
Name;
475 iov[k++].iov_len = ctl.
info[i].
NLen+1;
480 iov[k ].iov_base = &ctl.
info[i].
VLen;
481 iov[k++].iov_len =
sizeof(ctl.
info[i].
VLen);
484 iov[k ].iov_base = (
void *)ctl.
info[i].
Value;
485 iov[k++].iov_len = vLen;
490 if ((rc =
Response.Send(rcode, iov, k, dlen)))
return rc;
491 k = 1; dlen = 0; xresp =
true;
497 return (dlen ?
Response.Send(iov, k, dlen) : 0);
501 return (xresp ? 0 :
Response.Send());
510 struct iovec iov[16];
525 if ((rc =
osFS->FAttr(&ctl, eInfo,
CRED)))
541 XrdSfsFABuff *dP = ctl.
fabP;
544 {iov[i].iov_base = dP->
data;
545 iov[i].iov_len = dP->
dlen;
549 if (i == (
int)
sizeof(iov))
551 if (rc || dP == 0)
return rc;
559 return (dlen ?
Response.Send(iov, i, dlen) : 0);
566int XrdXrootdProtocol::XeqFASet(
XrdSfsFACtl &ctl,
char *faVars,
int faVLen)
581 if ((rc =
osFS->FAttr(&ctl, eInfo,
CRED)))
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;
594 return Response.Send(iov, 3,
sizeof(faRC) + faVLen);
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)
static XrdXrootdXPath RPList
XrdXrootdFileTable * FTab
XrdXrootdMonitor::User Monitor
XrdXrootdResponse Response
static struct XrdXrootdProtocol::RD_Table Route[RD_Num]
static XrdSfsFileSystem * osFS
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.