Recursively get space information for given path.
101 {
102
103
104
105 LocationInfo *locationInfo = 0;
107 if( !st.IsOK() )
108 return st;
109
110 std::unique_ptr<LocationInfo> locationInfoPtr( locationInfo );
111
112 bool partial = st.code ==
suPartial ? true :
false;
113
114 std::vector<std::pair<std::string, uint64_t> > resp;
115 resp.push_back( std::make_pair( std::string("oss.space"), (uint64_t)0 ) );
116 resp.push_back( std::make_pair( std::string("oss.free"), (uint64_t)0 ) );
117 resp.push_back( std::make_pair( std::string("oss.used"), (uint64_t)0 ) );
118 resp.push_back( std::make_pair( std::string("oss.maxf"), (uint64_t)0 ) );
119
120
121
122
124 Buffer pathArg; pathArg.FromString( path );
125 for( it = locationInfo->Begin(); it != locationInfo->End(); ++it )
126 {
127
128
129
130 Buffer *spaceInfo = 0;
131 FileSystem fs1( it->GetAddress() );
133 if( !st.IsOK() )
134 return st;
135
136 std::unique_ptr<Buffer> spaceInfoPtr( spaceInfo );
137
138
139
140
141 std::string fakeUrl = "root://fake/fake?" + spaceInfo->ToString();
142 URL url( fakeUrl );
143
144 if( !url.IsValid() )
146
148
149
150
151
153 for( size_t i = 0; i < resp.size(); ++i )
154 {
155 URL::ParamsMap::iterator paramIt = params.find( resp[i].first );
156 if( paramIt == params.end() ) return st;
157 char *res;
158 uint64_t num = ::strtoll( paramIt->second.c_str(), &res, 0 );
159 if( *res != 0 ) return st;
160 if( resp[i].first == "oss.maxf" )
161 { if( num > resp[i].second ) resp[i].second = num; }
162 else
163 resp[i].second += num;
164 }
165 }
166
167 result =
new SpaceInfo( resp[0].second, resp[1].second, resp[2].second,
168 resp[3].second );
169
170 st = XRootDStatus();
if( partial ) st.code =
suPartial;
171 return st;
172 }
Container for space information.
LocationList::iterator Iterator
Iterator over locations.
std::map< std::string, std::string > ParamsMap
const uint16_t stError
An error occurred that could potentially be retried.
const uint16_t errInvalidResponse
@ Space
Query logical space stats.