XRootD
Posix Namespace Reference

Functions

std::pair< int, XRootDStatus_PRead (Davix::DavPosix &davix_client, DAVIX_FD *fd, void *buffer, uint32_t size, uint64_t offset, bool no_pread=false)
 
XRootDStatus Close (Davix::DavPosix &davix_client, DAVIX_FD *fd)
 
std::pair< XrdCl::DirectoryList *, XrdCl::XRootDStatusDirList (Davix::DavPosix &davix_client, const std::string &path, bool details, bool, uint16_t timeout)
 
XRootDStatus MkDir (Davix::DavPosix &davix_client, const std::string &path, XrdCl::MkDirFlags::Flags flags, XrdCl::Access::Mode, uint16_t timeout)
 
std::pair< DAVIX_FD *, XRootDStatusOpen (Davix::DavPosix &davix_client, const std::string &url, int flags, uint16_t timeout)
 
std::pair< int, XRootDStatusPRead (Davix::DavPosix &davix_client, DAVIX_FD *fd, void *buffer, uint32_t size, uint64_t offset)
 
std::pair< int, XrdCl::XRootDStatusPReadVec (Davix::DavPosix &davix_client, DAVIX_FD *fd, const XrdCl::ChunkList &chunks, void *buffer)
 
std::pair< int, XrdCl::XRootDStatusPWrite (Davix::DavPosix &davix_client, DAVIX_FD *fd, uint64_t offset, uint32_t size, const void *buffer, uint16_t timeout)
 
std::pair< int, XRootDStatusRead (Davix::DavPosix &davix_client, DAVIX_FD *fd, void *buffer, uint32_t size)
 
XRootDStatus Rename (Davix::DavPosix &davix_client, const std::string &source, const std::string &dest, uint16_t timeout)
 
XRootDStatus RmDir (Davix::DavPosix &davix_client, const std::string &path, uint16_t timeout)
 
XRootDStatus Stat (Davix::DavPosix &davix_client, const std::string &url, uint16_t timeout, StatInfo *stat_info)
 
XRootDStatus Unlink (Davix::DavPosix &davix_client, const std::string &url, uint16_t timeout)
 

Function Documentation

◆ _PRead()

std::pair<int, XRootDStatus> Posix::_PRead ( Davix::DavPosix &  davix_client,
DAVIX_FD *  fd,
void *  buffer,
uint32_t  size,
uint64_t  offset,
bool  no_pread = false 
)

Definition at line 422 of file XrdClHttpPosix.cc.

424  {
425  Davix::DavixError* err = nullptr;
426  int num_bytes_read;
427  if (no_pread) { // continue reading from the current offset position
428  num_bytes_read = davix_client.read(fd, buffer, size, &err);
429  }
430  else {
431  num_bytes_read = davix_client.pread(fd, buffer, size, offset, &err);
432  }
433  if (num_bytes_read < 0) {
434  auto errStatus =
435  XRootDStatus(stError, errInternal, err->getStatus(), err->getErrMsg());
436  delete err;
437  return std::make_pair(num_bytes_read, errStatus);
438  }
439 
440  return std::make_pair(num_bytes_read, XRootDStatus());
441 }
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
const uint16_t errInternal
Internal error.
Definition: XrdClStatus.hh:56

References XrdCl::errInternal, and XrdCl::stError.

Referenced by PRead(), and Read().

+ Here is the caller graph for this function:

◆ Close()

XrdCl::XRootDStatus Posix::Close ( Davix::DavPosix &  davix_client,
DAVIX_FD *  fd 
)

Definition at line 220 of file XrdClHttpPosix.cc.

220  {
221  Davix::DavixError* err = nullptr;
222  if (davix_client.close(fd, &err)) {
223  auto errStatus =
224  XRootDStatus(stError, errInternal, err->getStatus(), err->getErrMsg());
225  delete err;
226  return errStatus;
227  }
228 
229  return XRootDStatus();
230 }

References XrdCl::errInternal, and XrdCl::stError.

Referenced by XrdCl::HttpFilePlugIn::Close().

+ Here is the caller graph for this function:

◆ DirList()

std::pair< XrdCl::DirectoryList *, XrdCl::XRootDStatus > Posix::DirList ( Davix::DavPosix &  davix_client,
const std::string &  path,
bool  details,
bool  ,
uint16_t  timeout 
)

Definition at line 299 of file XrdClHttpPosix.cc.

301  {
302  Davix::RequestParams params;
303  SetTimeout(params, timeout);
304  SetAuthz(params);
305 
306  auto dir_list = new DirectoryList();
307 
308  Davix::DavixError* err = nullptr;
309 
310  auto dir_fd = davix_client.opendirpp(&params, SanitizedURL(path), &err);
311  if (!dir_fd) {
312  auto errStatus = XRootDStatus(stError, errInternal, err->getStatus(),
313  err->getErrMsg());
314  delete err;
315  return std::make_pair(nullptr, errStatus);
316  }
317 
318  struct stat info;
319  while (auto entry = davix_client.readdirpp(dir_fd, &info, &err)) {
320  if (err) {
321  auto errStatus = XRootDStatus(stError, errInternal, err->getStatus(),
322  err->getErrMsg());
323  delete err;
324  return std::make_pair(nullptr, errStatus);
325  }
326 
327  StatInfo* stat_info = nullptr;
328  if (details) {
329  stat_info = new StatInfo();
330  auto res = FillStatInfo(info, stat_info);
331  if (res.IsError()) {
332  delete entry;
333  delete stat_info;
334  return std::make_pair(nullptr, res);
335  }
336  }
337 
338  auto list_entry = new DirectoryList::ListEntry(path, entry->d_name, stat_info);
339  dir_list->Add(list_entry);
340 
341  // do not delete "entry". davix_client.readdirpp() always return the same address
342  // and will set it to NULL when there is no more directory entry to return
343  //delete entry;
344  }
345 
346  if (davix_client.closedirpp(dir_fd, &err)) {
347  auto errStatus = XRootDStatus(stError, errInternal, err->getStatus(),
348  err->getErrMsg());
349  delete err;
350  return std::make_pair(nullptr, errStatus);
351  }
352 
353  return std::make_pair(dir_list, XRootDStatus());
354 }
int stat(const char *path, struct stat *buf)
Object stat info.

References XrdCl::errInternal, stat(), and XrdCl::stError.

Referenced by XrdCl::HttpFileSystemPlugIn::DirList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MkDir()

XrdCl::XRootDStatus Posix::MkDir ( Davix::DavPosix &  davix_client,
const std::string &  path,
XrdCl::MkDirFlags::Flags  flags,
XrdCl::Access::Mode  ,
uint16_t  timeout 
)

Definition at line 232 of file XrdClHttpPosix.cc.

234  {
235 
236  return XRootDStatus();
237 
238  Davix::RequestParams params;
239  SetTimeout(params, timeout);
240  SetAuthz(params);
241 
242  auto DoMkDir = [&davix_client, &params](const std::string& path) {
243  Davix::DavixError* err = nullptr;
244  if (davix_client.mkdir(&params, SanitizedURL(path), S_IRWXU, &err) &&
245  (err->getStatus() != Davix::StatusCode::FileExist)) {
246  auto errStatus = XRootDStatus(stError, errInternal, err->getStatus(),
247  err->getErrMsg());
248  delete err;
249  return errStatus;
250  } else {
251  return XRootDStatus();
252  }
253  };
254 
255  auto url = XrdCl::URL(path);
256 
257  if (flags & XrdCl::MkDirFlags::MakePath) {
258  // Also create intermediate directories
259 
260  auto dirs = SplitString(url.GetPath(), "/");
261 
262  std::string dirs_cumul;
263  for (const auto& d : dirs) {
264  dirs_cumul += "/" + d;
265  url.SetPath(dirs_cumul);
266  auto status = DoMkDir(url.GetLocation());
267  if (status.IsError()) {
268  return status;
269  }
270  }
271  } else {
272  // Only create final directory
273  auto status = DoMkDir(url.GetURL());
274  if (status.IsError()) {
275  return status;
276  }
277  }
278 
279  return XRootDStatus();
280 }
XRootDStatus DoMkDir(FileSystem *fs, Env *env, const FSExecutor::CommandParams &args)
Definition: XrdClFS.cc:496
URL representation.
Definition: XrdClURL.hh:31
@ MakePath
create the entire directory tree if it doesn't exist

References DoMkDir(), XrdCl::errInternal, XrdCl::MkDirFlags::MakePath, and XrdCl::stError.

Referenced by XrdCl::HttpFileSystemPlugIn::MkDir(), and XrdCl::HttpFilePlugIn::Open().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Open()

std::pair< DAVIX_FD *, XrdCl::XRootDStatus > Posix::Open ( Davix::DavPosix &  davix_client,
const std::string &  url,
int  flags,
uint16_t  timeout 
)

Definition at line 200 of file XrdClHttpPosix.cc.

202  {
203  Davix::RequestParams params;
204  SetTimeout(params, timeout);
205  SetAuthz(params);
206  Davix::DavixError* err = nullptr;
207  DAVIX_FD* fd = davix_client.open(&params, SanitizedURL(url), flags, &err);
208  XRootDStatus status;
209  if (!fd) {
210  auto res = ErrCodeConvert(err->getStatus());
211  status = XRootDStatus(stError, res.first, res.second, err->getErrMsg());
212  delete err;
213  }
214  else {
215  status = XRootDStatus();
216  }
217  return std::make_pair(fd, status);
218 }

References XrdCl::stError.

Referenced by XrdCl::HttpFilePlugIn::Open().

+ Here is the caller graph for this function:

◆ PRead()

std::pair< int, XrdCl::XRootDStatus > Posix::PRead ( Davix::DavPosix &  davix_client,
DAVIX_FD *  fd,
void *  buffer,
uint32_t  size,
uint64_t  offset 
)

Definition at line 448 of file XrdClHttpPosix.cc.

449  {
450  return _PRead(davix_client, fd, buffer, size, offset, false);
451 }
std::pair< int, XRootDStatus > _PRead(Davix::DavPosix &davix_client, DAVIX_FD *fd, void *buffer, uint32_t size, uint64_t offset, bool no_pread=false)

References _PRead().

Referenced by XrdCl::HttpFilePlugIn::Read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PReadVec()

std::pair< int, XrdCl::XRootDStatus > Posix::PReadVec ( Davix::DavPosix &  davix_client,
DAVIX_FD *  fd,
const XrdCl::ChunkList chunks,
void *  buffer 
)

Definition at line 453 of file XrdClHttpPosix.cc.

456  {
457  const auto num_chunks = chunks.size();
458  std::vector<Davix::DavIOVecInput> input_vector(num_chunks);
459  std::vector<Davix::DavIOVecOuput> output_vector(num_chunks);
460 
461  for (size_t i = 0; i < num_chunks; ++i) {
462  input_vector[i].diov_offset = chunks[i].offset;
463  input_vector[i].diov_size = chunks[i].length;
464  input_vector[i].diov_buffer = chunks[i].buffer;
465  }
466 
467  Davix::DavixError* err = nullptr;
468  int num_bytes_read = davix_client.preadVec(
469  fd, input_vector.data(), output_vector.data(), num_chunks, &err);
470  if (num_bytes_read < 0) {
471  auto errStatus =
472  XRootDStatus(stError, errInternal, err->getStatus(), err->getErrMsg());
473  delete err;
474  return std::make_pair(num_bytes_read, XRootDStatus(stError, errUnknown));
475  }
476 
477  return std::make_pair(num_bytes_read, XRootDStatus());
478 }
const uint16_t errUnknown
Unknown error.
Definition: XrdClStatus.hh:50

References XrdCl::errInternal, XrdCl::errUnknown, and XrdCl::stError.

Referenced by XrdCl::HttpFilePlugIn::VectorRead().

+ Here is the caller graph for this function:

◆ PWrite()

std::pair< int, XrdCl::XRootDStatus > Posix::PWrite ( Davix::DavPosix &  davix_client,
DAVIX_FD *  fd,
uint64_t  offset,
uint32_t  size,
const void *  buffer,
uint16_t  timeout 
)

Definition at line 480 of file XrdClHttpPosix.cc.

483  {
484  Davix::DavixError* err = nullptr;
485  off_t new_offset = davix_client.lseek(fd, offset, SEEK_SET, &err);
486  if (uint64_t(new_offset) != offset) {
487  auto errStatus =
488  XRootDStatus(stError, errInternal, err->getStatus(), err->getErrMsg());
489  delete err;
490  return std::make_pair(new_offset, errStatus);
491  }
492  int num_bytes_written = davix_client.write(fd, buffer, size, &err);
493  if (num_bytes_written < 0) {
494  auto errStatus =
495  XRootDStatus(stError, errInternal, err->getStatus(), err->getErrMsg());
496  delete err;
497  return std::make_pair(num_bytes_written, errStatus);
498  }
499 
500  return std::make_pair(num_bytes_written, XRootDStatus());
501 }

References XrdCl::errInternal, and XrdCl::stError.

Referenced by XrdCl::HttpFilePlugIn::Write().

+ Here is the caller graph for this function:

◆ Read()

std::pair< int, XrdCl::XRootDStatus > Posix::Read ( Davix::DavPosix &  davix_client,
DAVIX_FD *  fd,
void *  buffer,
uint32_t  size 
)

Definition at line 443 of file XrdClHttpPosix.cc.

444  {
445  return _PRead(davix_client, fd, buffer, size, 0, true);
446 }

References _PRead().

Referenced by XrdCl::HttpFilePlugIn::Read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Rename()

XrdCl::XRootDStatus Posix::Rename ( Davix::DavPosix &  davix_client,
const std::string &  source,
const std::string &  dest,
uint16_t  timeout 
)

Definition at line 356 of file XrdClHttpPosix.cc.

357  {
358 
359  // most s3 storage systems either:
360  // 1. do not support rename, especially for files that were uploaded using multi-part
361  // 2. support by copy-n-delete.
362  // we could implement copy-n-delete if necessary
363  if (getenv("AWS_ACCESS_KEY_ID"))
365 
366  Davix::RequestParams params;
367  SetTimeout(params, timeout);
368  SetAuthz(params);
369 
370  Davix::DavixError* err = nullptr;
371  if (davix_client.rename(&params, SanitizedURL(source), SanitizedURL(dest), &err)) {
372  auto errStatus =
373  XRootDStatus(stError, errInternal, err->getStatus(), err->getErrMsg());
374  delete err;
375  return errStatus;
376  }
377 
378  return XRootDStatus();
379 }
@ kXR_Unsupported
Definition: XProtocol.hh:1003
const uint16_t errErrorResponse
Definition: XrdClStatus.hh:105

References XrdCl::errErrorResponse, XrdCl::errInternal, kXR_Unsupported, and XrdCl::stError.

Referenced by XrdCl::HttpFileSystemPlugIn::Mv().

+ Here is the caller graph for this function:

◆ RmDir()

XrdCl::XRootDStatus Posix::RmDir ( Davix::DavPosix &  davix_client,
const std::string &  path,
uint16_t  timeout 
)

Definition at line 282 of file XrdClHttpPosix.cc.

283  {
284  Davix::RequestParams params;
285  SetTimeout(params, timeout);
286  SetAuthz(params);
287 
288  Davix::DavixError* err = nullptr;
289  if (davix_client.rmdir(&params, path, &err)) {
290  auto errStatus =
291  XRootDStatus(stError, errInternal, err->getStatus(), err->getErrMsg());
292  delete err;
293  return errStatus;
294  }
295 
296  return XRootDStatus();
297 }

References XrdCl::errInternal, and XrdCl::stError.

Referenced by XrdCl::HttpFileSystemPlugIn::RmDir().

+ Here is the caller graph for this function:

◆ Stat()

XrdCl::XRootDStatus Posix::Stat ( Davix::DavPosix &  davix_client,
const std::string &  url,
uint16_t  timeout,
StatInfo stat_info 
)

Definition at line 381 of file XrdClHttpPosix.cc.

382  {
383  Davix::RequestParams params;
384  SetTimeout(params, timeout);
385  SetAuthz(params);
386 
387  struct stat stats;
388  Davix::DavixError* err = nullptr;
389  if (davix_client.stat(&params, SanitizedURL(url), &stats, &err)) {
390  auto res = ErrCodeConvert(err->getStatus());
391  auto errStatus =
392  XRootDStatus(stError, res.first, res.second, err->getErrMsg());
393  delete err;
394  return errStatus;
395  }
396 
397  auto res = FillStatInfo(stats, stat_info);
398  if (res.IsError()) {
399  return res;
400  }
401 
402  return XRootDStatus();
403 }

References stat(), and XrdCl::stError.

Referenced by XrdCl::HttpFilePlugIn::Open(), XrdCl::HttpFilePlugIn::Stat(), and XrdCl::HttpFileSystemPlugIn::Stat().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Unlink()

XrdCl::XRootDStatus Posix::Unlink ( Davix::DavPosix &  davix_client,
const std::string &  url,
uint16_t  timeout 
)

Definition at line 405 of file XrdClHttpPosix.cc.

406  {
407  Davix::RequestParams params;
408  SetTimeout(params, timeout);
409  SetAuthz(params);
410 
411  Davix::DavixError* err = nullptr;
412  if (davix_client.unlink(&params, SanitizedURL(url), &err)) {
413  auto errStatus =
414  XRootDStatus(stError, errInternal, err->getStatus(), err->getErrMsg());
415  delete err;
416  return errStatus;
417  }
418 
419  return XRootDStatus();
420 }

References XrdCl::errInternal, and XrdCl::stError.

Referenced by XrdOfsPoscq::Del(), XrdCl::HttpFilePlugIn::Open(), XrdFrmAdmin::Remove(), and XrdCl::HttpFileSystemPlugIn::Rm().

+ Here is the caller graph for this function: