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 committed Oct 8, 2018
1 parent c500b87 commit a008312
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
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,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 @@ -1633,7 +1633,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,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 @@ -1130,7 +1130,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 @@ -1153,7 +1153,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 @@ -1176,7 +1176,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 @@ -1660,6 +1661,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 @@ -1674,6 +1676,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,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 @@ -1699,7 +1699,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 @@ -1729,7 +1729,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 @@ -1759,15 +1759,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 @@ -1858,6 +1859,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 @@ -1869,6 +1871,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
Original file line number Diff line number Diff line change
Expand Up @@ -815,9 +815,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 @@ -877,6 +877,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
Original file line number Diff line number Diff line change
Expand Up @@ -1753,20 +1753,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
Original file line number Diff line number Diff line change
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 a008312

Please sign in to comment.