Recursively get space information for given path.
101 {
102
103
104
105 LocationInfo *locationInfo = 0;
107 XRootDStatus st = fs->DeepLocate( path, flags, locationInfo );
108 if( !st.IsOK() )
109 return st;
110
111 std::unique_ptr<LocationInfo> locationInfoPtr( locationInfo );
112
113 bool partial = st.code ==
suPartial ? true :
false;
114
115 std::vector<std::pair<std::string, uint64_t> > resp;
116 resp.push_back( std::make_pair( std::string("oss.space"), (uint64_t)0 ) );
117 resp.push_back( std::make_pair( std::string("oss.free"), (uint64_t)0 ) );
118 resp.push_back( std::make_pair( std::string("oss.used"), (uint64_t)0 ) );
119 resp.push_back( std::make_pair( std::string("oss.maxf"), (uint64_t)0 ) );
120
121
122
123
125 Buffer pathArg; pathArg.FromString( path );
126 for( it = locationInfo->Begin(); it != locationInfo->End(); ++it )
127 {
128
129
130
131 Buffer *spaceInfo = 0;
132 FileSystem fs1( it->GetAddress() );
134 if( !st.IsOK() )
135 return st;
136
137 std::unique_ptr<Buffer> spaceInfoPtr( spaceInfo );
138
139
140
141
142 std::string fakeUrl = "root://fake/fake?" + spaceInfo->ToString();
143 URL url( fakeUrl );
144
145 if( !url.IsValid() )
147
149
150
151
152
154 for( size_t i = 0; i < resp.size(); ++i )
155 {
156 URL::ParamsMap::iterator paramIt = params.find( resp[i].first );
157 if( paramIt == params.end() ) return st;
158 char *res;
159 uint64_t num = ::strtoll( paramIt->second.c_str(), &res, 0 );
160 if( *res != 0 ) return st;
161 if( resp[i].first == "oss.maxf" )
162 { if( num > resp[i].second ) resp[i].second = num; }
163 else
164 resp[i].second += num;
165 }
166 }
167
168 result = new SpaceInfo( resp[0].second, resp[1].second, resp[2].second,
169 resp[3].second );
170
171 st = XRootDStatus();
if( partial ) st.code =
suPartial;
172 return st;
173 }
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
Flags
Open flags, may be or'd when appropriate.
@ Space
Query logical space stats.