Skip to content

Commit

Permalink
[Server] Fix fattr interference with checksums.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 authored and simonmichal committed Jun 21, 2019
1 parent ccfbe73 commit 9b09fdf
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/XProtocol/XProtocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ const char *errNames[kXR_ERRFENCE-kXR_ArgInvalid] =
"Invalid signature", // kXR_SigVerErr
"Decryption failed", // kXR_DecryptErr
"Overloaded", // kXR_Overloaded
"Invalid payload format" // kXR_BadPayload
"Invalid payload format", // kXR_BadPayload
"File attrbute not found" // kXR_AttrNotFound
};

const char *reqNames[kXR_REQFENCE-kXR_auth] =
Expand Down
7 changes: 7 additions & 0 deletions src/XProtocol/XProtocol.hh
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ enum XErrorCode {
kXR_Overloaded, // 3024
kXR_fsReadOnly, // 3025
kXR_BadPayload, // 3026
kXR_AttrNotFound, // 3027
kXR_ERRFENCE, // Always last valid errcode + 1
kXR_noErrorYet = 10000
};
Expand Down Expand Up @@ -929,6 +930,10 @@ struct ALIGN_CHECK {char chkszreq[25-sizeof(ClientRequest)];
#define ENETUNREACH 114
#endif
#endif

#ifndef ENOATTR
#define ENOATTR ENODATA
#endif

class XProtocol
{
Expand Down Expand Up @@ -960,6 +965,7 @@ static int mapError(int rc)
case ERANGE: return kXR_DecryptErr;
case EUSERS: return kXR_Overloaded;
case EROFS: return kXR_fsReadOnly;
case ENOATTR: return kXR_AttrNotFound;
default: return kXR_FSError;
}
}
Expand Down Expand Up @@ -993,6 +999,7 @@ static int toErrno( int xerr )
case kXR_DecryptErr: return ERANGE;
case kXR_Overloaded: return EUSERS;
case kXR_fsReadOnly: return EROFS;
case kXR_AttrNotFound: return ENOATTR;
default: return ENOMSG;
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/XrdCks/XrdCksManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
#include "XrdSys/XrdSysPlugin.hh"
#include "XrdSys/XrdSysPthread.hh"

#ifndef ENOATTR
#define ENOATTR ENODATA
#endif

/******************************************************************************/
/* C o n s t r u c t o r */
/******************************************************************************/
Expand Down Expand Up @@ -455,7 +459,7 @@ int XrdCksManager::Get(const char *Pfn, XrdCksData &Cks)

// Retreive the attribute
//
if ((rc = xCS.Get(Pfn)) <= 0) return (rc ? rc : -ESRCH);
if ((rc = xCS.Get(Pfn)) <= 0) return (rc && rc != -ENOATTR ? rc : -ESRCH);

// Mark state of the name and copy the attribute over
//
Expand Down
2 changes: 1 addition & 1 deletion src/XrdOfs/XrdOfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,7 @@ int XrdOfs::chksum( csFunc Func, // In
if (rc >= 0 || rc == -ENODATA || rc == -ESTALE || rc == -ESRCH)
#endif
{if (rc >= 0) {cksData.Get(buff, MAXPATHLEN); rc = 0;}
else {*buff = 0; rc = ENOENT;}
else {*buff = 0; rc = -rc;}
einfo.setErrInfo(rc, buff);
return SFS_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/XrdSys/XrdSysFAttr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int XrdSysFAttr::Diagnose(const char *Op, const char *Var,

// Screen out common case
//
if (ec == ENOATTR || ec == ENOENT) return -ENOENT;
if (ec == ENOATTR || ec == ENOENT) return -ec;

// Format message insert and print if we can actually say anything
//
Expand Down
10 changes: 5 additions & 5 deletions src/XrdSys/XrdSysFAttrBsd.icc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int XrdSysFAttr::Get(const char *Aname, void *Aval, int Avsz,
// Obtain the attribute.
//
ec = (fd < 0 ? extattr_get_file(Path,EXTATTR_NAMESPACE_USER,Aname,Aval,Avsz)
extattr_get_fd( fd, EXTATTR_NAMESPACE_USER,Aname,Aval,Avsz));
: extattr_get_fd( fd, EXTATTR_NAMESPACE_USER,Aname,Aval,Avsz));

// Diagnose errors.
//
Expand All @@ -90,9 +90,9 @@ int XrdSysFAttr::List(AList **aPL, const char *Path, int fd, int getSz)
//
*aPL = 0;
Tlen = (fd < 0 ? extattr_get_file(Path,EXTATTR_NAMESPACE_USER, 0, 0)
extattr_list_fd( fd,EXTATTR_NAMESPACE_USER, 0, 0));
: extattr_list_fd( fd,EXTATTR_NAMESPACE_USER, 0, 0));
if (Tlen < 0)
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOENT) ec = 0;
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOATTR) ec = 0;
return ec;
}

Expand All @@ -110,9 +110,9 @@ int XrdSysFAttr::List(AList **aPL, const char *Path, int fd, int getSz)
// since the time we actual determined the size of the buffer we need.
//
Tlen = (fd < 0 ? extattr_get_file(Path,EXTATTR_NAMESPACE_USER, Buff, Tlen)
extattr_list_fd( fd,EXTATTR_NAMESPACE_USER, Buff, Tlen));
: extattr_list_fd( fd,EXTATTR_NAMESPACE_USER, Buff, Tlen));
if (Tlen < 0)
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOENT) ec = 0;
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOATTR) ec = 0;
free(Buff);
return ec;
}
Expand Down
4 changes: 2 additions & 2 deletions src/XrdSys/XrdSysFAttrLnx.icc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int XrdSysFAttr::List(AList **aPL, const char *Path, int fd, int getSz)
*aPL = 0;
Tlen = (fd < 0 ? listxattr(Path, Buff, 0) : flistxattr(fd, Buff, 0));
if (Tlen < 0)
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOENT) ec = 0;
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOATTR) ec = 0;
return ec;
}

Expand All @@ -125,7 +125,7 @@ int XrdSysFAttr::List(AList **aPL, const char *Path, int fd, int getSz)
//
Tlen = (fd < 0 ? listxattr(Path, Buff, Tlen) : flistxattr(fd, Buff, Tlen));
if (Tlen < 0)
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOENT) ec = 0;
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOATTR) ec = 0;
free(Buff);
return ec;
}
Expand Down
4 changes: 2 additions & 2 deletions src/XrdSys/XrdSysFAttrMac.icc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int XrdSysFAttr::List(AList **aPL, const char *Path, int fd, int getSz)
*aPL = 0;
Tlen = (fd < 0 ? listxattr(Path, 0, 0, 0) : flistxattr(fd, 0, 0, 0));
if (Tlen < 0)
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOENT) ec = 0;
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOATTR) ec = 0;
return ec;
}

Expand All @@ -110,7 +110,7 @@ int XrdSysFAttr::List(AList **aPL, const char *Path, int fd, int getSz)
//
Tlen = (fd < 0 ? listxattr(Path,Buff,Tlen,0) : flistxattr(fd,Buff,Tlen,0));
if (Tlen < 0)
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOENT) ec = 0;
{if ((ec = Diagnose("list", "*", Path, errno)) == -ENOATTR) ec = 0;
free(Buff);
return ec;
}
Expand Down
14 changes: 11 additions & 3 deletions src/XrdSys/XrdSysFAttrSun.icc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@

#include "XrdSys/XrdSysFAttr.hh"

/******************************************************************************/
/* P l a t f o r m D e p e n d e n c i e s */
/******************************************************************************/

#ifndef ENOATTR
#define ENOATTR ENODATA
#endif

/******************************************************************************/
/* X r d S y s F A t t r : : D e l */
/******************************************************************************/
Expand Down Expand Up @@ -125,18 +133,18 @@ int XrdSysFAttr::List(AList **aPL, const char *Path, int fd, int getSz)
fd = (fd < 0 ? attropen(Path, ".", O_RDONLY)
: openat( fd, ".", O_RDONLY|O_XATTR));

// If the preceeding open failed, diagnose the problem. We ignore ENOENT.
// If the preceeding open failed, diagnose the problem. We ignore ENOATTR.
//
if (fd < 0)
{if (errno == ENOENT) return 0;
{if (errno == ENOATTR) return 0;
return Diagnose("open to list", "*", Path, errno);
}

// Now open the attribute directory
//
if (!(dP = fdopendir(fd)))
{rc = errno; close(fd);
if (rc == ENOENT) return 0;
if (rc == ENOATTR) return 0;
return Diagnose("open to list", "*", Path, rc);
}

Expand Down
2 changes: 2 additions & 0 deletions src/XrdXrootd/XrdXrootdXeqFAttr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ int SendErr(XrdXrootdResponse &Resp, faCTL &ctl, XErrorCode eCode)
}


/* For future use
int SendErr(XrdXrootdResponse &Resp, const char *what, const char *path, int rc)
{
int eCode = XProtocol::mapError(rc);
Expand All @@ -219,6 +220,7 @@ int SendErr(XrdXrootdResponse &Resp, const char *what, const char *path, int rc)
return Resp.Send((XErrorCode)eCode, eBuff);
}
*/
}

/******************************************************************************/
Expand Down

0 comments on commit 9b09fdf

Please sign in to comment.