Skip to content

Commit

Permalink
[XrdCl] Support aData flag in fattr list operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal authored and osschar committed Oct 10, 2019
1 parent 9c34165 commit a2ef11b
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/XrdCl/XrdClFS.cc
Expand Up @@ -1682,7 +1682,7 @@ XRootDStatus DoXAttr( FileSystem *fs,
return XRootDStatus( stError, errInvalidArgs );
}

std::vector<std::string> *result = 0;
std::vector<XAttr> *result = 0;
XRootDStatus status = fs->ListXAttr( path, result );

if( !status.IsOK() )
Expand All @@ -1693,7 +1693,7 @@ XRootDStatus DoXAttr( FileSystem *fs,
std::cout << "# file: " << path << '\n';
auto itr = result->begin();
for( ; itr != result->end(); ++itr )
std::cout << *itr << '\n';
std::cout << itr->name << "=\"" << itr->value << "\"\n";
delete result;
}

Expand Down
4 changes: 2 additions & 2 deletions src/XrdCl/XrdClFile.cc
Expand Up @@ -548,8 +548,8 @@ namespace XrdCl
//------------------------------------------------------------------------
// List extended attributes - sync
//------------------------------------------------------------------------
XRootDStatus File::ListXAttr( std::vector<std::string> *&result,
uint16_t timeout )
XRootDStatus File::ListXAttr( std::vector<XAttr> *&result,
uint16_t timeout )
{
SyncResponseHandler handler;
Status st = ListXAttr( &handler, timeout );
Expand Down
4 changes: 2 additions & 2 deletions src/XrdCl/XrdClFile.hh
Expand Up @@ -557,8 +557,8 @@ namespace XrdCl
//!
//! @return : status of the operation
//------------------------------------------------------------------------
XRootDStatus ListXAttr( std::vector<std::string> *&result,
uint16_t timeout = 0 );
XRootDStatus ListXAttr( std::vector<XAttr> *&result,
uint16_t timeout = 0 );

//------------------------------------------------------------------------
//! Check if the file is open
Expand Down
11 changes: 7 additions & 4 deletions src/XrdCl/XrdClFileStateHandler.cc
Expand Up @@ -1121,7 +1121,7 @@ namespace XrdCl
//--------------------------------------------------------------------------
// Issue a new fattr get request
//--------------------------------------------------------------------------
return XAttrOperationImpl( kXR_fattrSet, attrs, handler, timeout );
return XAttrOperationImpl( kXR_fattrSet, 0, attrs, handler, timeout );
}

//------------------------------------------------------------------------
Expand All @@ -1144,7 +1144,7 @@ namespace XrdCl
//--------------------------------------------------------------------------
// Issue a new fattr get request
//--------------------------------------------------------------------------
return XAttrOperationImpl( kXR_fattrGet, attrs, handler, timeout );
return XAttrOperationImpl( kXR_fattrGet, 0, attrs, handler, timeout );
}

//------------------------------------------------------------------------
Expand All @@ -1167,7 +1167,7 @@ namespace XrdCl
//--------------------------------------------------------------------------
// Issue a new fattr del request
//--------------------------------------------------------------------------
return XAttrOperationImpl( kXR_fattrDel, attrs, handler, timeout );
return XAttrOperationImpl( kXR_fattrDel, 0, attrs, handler, timeout );
}

//------------------------------------------------------------------------
Expand All @@ -1190,7 +1190,8 @@ namespace XrdCl
// Issue a new fattr get request
//--------------------------------------------------------------------------
static const std::vector<std::string> nothing;
return XAttrOperationImpl( kXR_fattrList, nothing, handler, timeout );
return XAttrOperationImpl( kXR_fattrList, ClientFattrRequest::aData,
nothing, handler, timeout );
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -1674,6 +1675,7 @@ namespace XrdCl
//------------------------------------------------------------------------
template<typename T>
Status FileStateHandler::XAttrOperationImpl( kXR_char subcode,
kXR_char options,
const std::vector<T> &attrs,
ResponseHandler *handler,
uint16_t timeout )
Expand All @@ -1688,6 +1690,7 @@ namespace XrdCl
req->requestid = kXR_fattr;
req->subcode = subcode;
req->numattr = attrs.size();
req->options = options;
memcpy( req->fhandle, pFileHandle, 4 );
XRootDStatus st = MessageUtils::CreateXAttrBody( msg, attrs );
if( !st.IsOK() ) return st;
Expand Down
1 change: 1 addition & 0 deletions src/XrdCl/XrdClFileStateHandler.hh
Expand Up @@ -435,6 +435,7 @@ namespace XrdCl
//------------------------------------------------------------------------
template<typename T>
Status XAttrOperationImpl( kXR_char subcode,
kXR_char options,
const std::vector<T> &attrs,
ResponseHandler *handler,
uint16_t timeout = 0 );
Expand Down
17 changes: 10 additions & 7 deletions src/XrdCl/XrdClFileSystem.cc
Expand Up @@ -1771,7 +1771,7 @@ namespace XrdCl
if( pPlugIn )
return XRootDStatus( stError, errNotSupported );

return XAttrOperationImpl( kXR_fattrSet, path, attrs, handler, timeout );
return XAttrOperationImpl( kXR_fattrSet, 0, path, attrs, handler, timeout );
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -1801,7 +1801,7 @@ namespace XrdCl
if( pPlugIn )
return XRootDStatus( stError, errNotSupported );

return XAttrOperationImpl( kXR_fattrGet, path, attrs, handler, timeout );
return XAttrOperationImpl( kXR_fattrGet, 0, path, attrs, handler, timeout );
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -1831,7 +1831,7 @@ namespace XrdCl
if( pPlugIn )
return XRootDStatus( stError, errNotSupported );

return XAttrOperationImpl( kXR_fattrDel, path, attrs, handler, timeout );
return XAttrOperationImpl( kXR_fattrDel, 0, path, attrs, handler, timeout );
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -1861,15 +1861,16 @@ namespace XrdCl
return XRootDStatus( stError, errNotSupported );

static const std::vector<std::string> nothing;
return XAttrOperationImpl( kXR_fattrList, path, nothing, handler, timeout );
return XAttrOperationImpl( kXR_fattrList, ClientFattrRequest::aData,
path, nothing, handler, timeout );
}

//------------------------------------------------------------------------
// List extended attributes - sync
//------------------------------------------------------------------------
XRootDStatus FileSystem::ListXAttr( const std::string &path,
std::vector<std::string> *&result,
uint16_t timeout )
XRootDStatus FileSystem::ListXAttr( const std::string &path,
std::vector<XAttr> *&result,
uint16_t timeout )
{
SyncResponseHandler handler;
Status st = ListXAttr( path, &handler, timeout );
Expand Down Expand Up @@ -1960,6 +1961,7 @@ namespace XrdCl
//------------------------------------------------------------------------
template<typename T>
Status FileSystem::XAttrOperationImpl( kXR_char subcode,
kXR_char options,
const std::string &path,
const std::vector<T> &attrs,
ResponseHandler *handler,
Expand All @@ -1971,6 +1973,7 @@ namespace XrdCl

req->requestid = kXR_fattr;
req->subcode = subcode;
req->options = options;
req->numattr = attrs.size();
memset( req->fhandle, 0, 4 );
XRootDStatus st = MessageUtils::CreateXAttrBody( msg, attrs, path );
Expand Down
7 changes: 4 additions & 3 deletions src/XrdCl/XrdClFileSystem.hh
Expand Up @@ -821,9 +821,9 @@ namespace XrdCl
//!
//! @return : status of the operation
//------------------------------------------------------------------------
XRootDStatus ListXAttr( const std::string &path,
std::vector<std::string> *&result,
uint16_t timeout = 0 );
XRootDStatus ListXAttr( const std::string &path,
std::vector<XAttr> *&result,
uint16_t timeout = 0 );

//------------------------------------------------------------------------
//! Set filesystem property
Expand Down Expand Up @@ -883,6 +883,7 @@ namespace XrdCl
//------------------------------------------------------------------------
template<typename T>
Status XAttrOperationImpl( kXR_char subcode,
kXR_char options,
const std::string &path,
const std::vector<T> &attrs,
ResponseHandler *handler,
Expand Down
15 changes: 12 additions & 3 deletions src/XrdCl/XrdClXRootDMsgHandler.cc
Expand Up @@ -1869,20 +1869,29 @@ namespace XrdCl
case kXR_fattrList:
{
Status status;
std::vector<std::string> resp;
std::vector<XAttr> resp;

while( len > 0 )
{
std::string name;
if( !( status = ReadFromBuffer( data, len, name ) ).IsOK() )
return status;

resp.push_back( name );
kXR_int32 vlen = 0;
if( !( status = ReadFromBuffer( data, len, vlen ) ).IsOK() )
return status;
vlen = ntohl( vlen );

std::string value;
if( !( status = ReadFromBuffer( data, len, vlen, value ) ).IsOK() )
return status;

resp.push_back( XAttr( name, value ) );
}

// set up the response object
response = new AnyObject();
response->Set( new std::vector<std::string>( std::move( resp ) ) );
response->Set( new std::vector<XAttr>( std::move( resp ) ) );

return Status();
}
Expand Down
6 changes: 6 additions & 0 deletions src/XrdCl/XrdClXRootDResponses.hh
Expand Up @@ -315,6 +315,12 @@ namespace XrdCl

}

XAttr( const std::string &name, const std::string &value ) :
XAttrStatus( name, XRootDStatus() ), value( value )
{

}

std::string value;
};

Expand Down

0 comments on commit a2ef11b

Please sign in to comment.