XRootD
XrdOfsDirectory Class Reference

#include <XrdOfs.hh>

+ Inheritance diagram for XrdOfsDirectory:
+ Collaboration diagram for XrdOfsDirectory:

Public Member Functions

 XrdOfsDirectory (XrdOucErrInfo &eInfo, const char *user)
 
virtual ~XrdOfsDirectory ()
 
int autoStat (struct stat *buf)
 
int close ()
 
void copyError (XrdOucErrInfo &einfo)
 
const char * FName ()
 
const char * nextEntry ()
 
int open (const char *dirName, const XrdSecEntity *client, const char *opaque=0)
 
- Public Member Functions inherited from XrdSfsDirectory
 XrdSfsDirectory (const char *user=0, int MonID=0)
 
 XrdSfsDirectory (XrdOucErrInfo &eInfo)
 
 XrdSfsDirectory (XrdSfsDirectory &wrapD)
 
virtual ~XrdSfsDirectory ()
 Destructor. More...
 

Protected Attributes

int atEOF
 
char dname [MAXNAMLEN]
 
XrdOssDFdp
 
char * fname
 
const char * tident
 

Additional Inherited Members

- Public Attributes inherited from XrdSfsDirectory
XrdOucErrInfoerror
 

Detailed Description

Definition at line 63 of file XrdOfs.hh.

Constructor & Destructor Documentation

◆ XrdOfsDirectory()

XrdOfsDirectory::XrdOfsDirectory ( XrdOucErrInfo eInfo,
const char *  user 
)
inline

Definition at line 81 of file XrdOfs.hh.

82  : XrdSfsDirectory(eInfo), tident(user ? user : ""),
83  fname(0), dp(0), atEOF(0) {}
const char * tident
Definition: XrdOfs.hh:88
char * fname
Definition: XrdOfs.hh:89
XrdOssDF * dp
Definition: XrdOfs.hh:90
XrdSfsDirectory(const char *user=0, int MonID=0)

◆ ~XrdOfsDirectory()

virtual XrdOfsDirectory::~XrdOfsDirectory ( )
inlinevirtual

Definition at line 85 of file XrdOfs.hh.

85 {if (dp) close();}

References close(), and dp.

+ Here is the call graph for this function:

Member Function Documentation

◆ autoStat()

int XrdOfsDirectory::autoStat ( struct stat buf)
virtual

Set the stat() buffer where stat information is to be placed corresponding to the directory entry returned by nextEntry().

Returns
If supported, SFS_OK should be returned. If not supported, then SFS_ERROR should be returned with error.code set to ENOTSUP.
Note
: When autoStat() is in effect, directory entries that have been deleted from the target directory are quietly skipped.

Reimplemented from XrdSfsDirectory.

Definition at line 417 of file XrdOfs.cc.

432 {
433  EPNAME("autoStat");
434  int retc;
435 
436 // Check if this directory is actually open
437 //
438  if (!dp) {XrdOfsFS->Emsg(epname, error, EBADF, "autostat directory");
439  return SFS_ERROR;
440  }
441 
442 // Set the stat buffer in the storage system directory but don't complain.
443 //
444  if ((retc = dp->StatRet(buf))) return retc;
445  return SFS_OK;
446 }
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
XrdOfs * XrdOfsFS
Definition: XrdOfsFS.cc:47
#define SFS_ERROR
#define SFS_OK
static int Emsg(const char *, XrdOucErrInfo &, int, const char *x, XrdOfsHandle *hP, bool posChk=false, bool chktype=true)
Definition: XrdOfs.cc:2609
virtual int StatRet(struct stat *buff)
Definition: XrdOss.hh:112
XrdOucErrInfo & error

References dp, XrdOfs::Emsg(), EPNAME, XrdSfsDirectory::error, SFS_ERROR, SFS_OK, XrdOssDF::StatRet(), and XrdOfsFS.

+ Here is the call graph for this function:

◆ close()

int XrdOfsDirectory::close ( )
virtual

Close the directory.

Returns
One of SFS_OK or SFS_ERROR

Implements XrdSfsDirectory.

Definition at line 371 of file XrdOfs.cc.

384 {
385  EPNAME("closedir");
386  int retc;
387 
388 // Check if this directory is actually open
389 //
390  if (!dp) {XrdOfsFS->Emsg(epname, error, EBADF, "close directory");
391  return SFS_ERROR;
392  }
393  XTRACE(closedir, fname, "");
394 
395 // Close this directory
396 //
397  if ((retc = dp->Close()))
398  {std::string eText;
399  const char* etP = 0;
400  if (XrdOfsFS->tryXERT && dp->getErrMsg(eText)) etP = eText.c_str();
401  retc = XrdOfsFS->Emsg(epname, error, retc, "close", fname, etP);
402  } else retc = SFS_OK;
403 
404 // All done
405 //
406  delete dp;
407  dp = 0;
408  free(fname);
409  fname = 0;
410  return retc;
411 }
#define XTRACE(act, target, x)
Definition: XrdBwmTrace.hh:49
int closedir(DIR *dirp)
virtual int Close(long long *retsz=0)=0
virtual bool getErrMsg(std::string &eText)
Definition: XrdOss.hh:478

References XrdOssDF::Close(), closedir(), dp, XrdOfs::Emsg(), EPNAME, XrdSfsDirectory::error, fname, XrdOssDF::getErrMsg(), SFS_ERROR, SFS_OK, XrdOfsFS, and XTRACE.

Referenced by ~XrdOfsDirectory().

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

◆ copyError()

void XrdOfsDirectory::copyError ( XrdOucErrInfo einfo)
inline

Definition at line 75 of file XrdOfs.hh.

75 {einfo = error;}

References XrdSfsDirectory::error.

◆ FName()

const char* XrdOfsDirectory::FName ( )
inlinevirtual

Get the directory path.

Returns
Null terminated string of the path used in open().

Implements XrdSfsDirectory.

Definition at line 77 of file XrdOfs.hh.

77 {return (const char *)fname;}

References fname.

◆ nextEntry()

const char * XrdOfsDirectory::nextEntry ( )
virtual

Get the next directory entry.

Returns
A null terminated string with the directory name. Normally, "." ".." are not returned. If a null pointer is returned then if this is due to an error, error.code should contain errno. Otherwise, error.code should contain zero to indicate that no more entries exist (i.e. end of list). See autoStat() for additional caveats.

Implements XrdSfsDirectory.

Definition at line 308 of file XrdOfs.cc.

328 {
329  EPNAME("readdir");
330  int retc;
331 
332 // Check if this directory is actually open
333 //
334  if (!dp) {XrdOfsFS->Emsg(epname, error, EBADF, "read directory");
335  return 0;
336  }
337 
338 // Check if we are at EOF (once there we stay there)
339 //
340  if (atEOF) return 0;
341 
342 // Read the next directory entry
343 //
344  if ((retc = dp->Readdir(dname, sizeof(dname))) < 0)
345  {std::string eText;
346  const char* etP = 0;
347  if (XrdOfsFS->tryXERT && dp->getErrMsg(eText)) etP = eText.c_str();
348  XrdOfsFS->Emsg(epname, error, retc, "read directory", fname, etP);
349  return 0;
350  }
351 
352 // Check if we have reached end of file
353 //
354  if (!*dname)
355  {atEOF = 1;
356  error.clear();
357  XTRACE(readdir, fname, "<eof>");
358  return 0;
359  }
360 
361 // Return the actual entry
362 //
364  return (const char *)(dname);
365 }
#define readdir(a)
Definition: XrdPosix.hh:90
char dname[MAXNAMLEN]
Definition: XrdOfs.hh:92
virtual int Readdir(char *buff, int blen)
Definition: XrdOss.hh:97
void clear()
Reset data and error information to null. Any appenadges are released.

References atEOF, XrdOucErrInfo::clear(), dname, dp, XrdOfs::Emsg(), EPNAME, XrdSfsDirectory::error, fname, XrdOssDF::getErrMsg(), readdir, XrdOssDF::Readdir(), XrdOfsFS, and XTRACE.

+ Here is the call graph for this function:

◆ open()

int XrdOfsDirectory::open ( const char *  path,
const XrdSecEntity client,
const char *  opaque = 0 
)
virtual

Open a directory.

Parameters
path- Pointer to the path of the directory to be opened.
client- Client's identify (see common description).
opaque- path's CGI information (see common description).
Returns
One of SFS_OK, SFS_ERROR, SFS_REDIRECT, ir SFS_STALL

Implements XrdSfsDirectory.

Definition at line 240 of file XrdOfs.cc.

257 {
258  EPNAME("opendir");
259  static const int od_mode = SFS_O_RDONLY|SFS_O_META;
260  XrdOucEnv Open_Env(info,0,client);
261  int retc;
262 
263 // Trace entry
264 //
265  XTRACE(opendir, dir_path, "");
266 
267 // Verify that this object is not already associated with an open directory
268 //
269  if (dp) return
270  XrdOfsFS->Emsg(epname, error, EADDRINUSE, "open directory", dir_path);
271 
272 // Apply security, as needed
273 //
274  AUTHORIZE(client,&Open_Env,AOP_Readdir,"open directory",dir_path,error);
275 
276 // Find out where we should open this directory
277 //
278  if (XrdOfsFS->DirRdr && XrdOfsFS->Finder && XrdOfsFS->Finder->isRemote()
279  && (retc = XrdOfsFS->Finder->Locate(error, dir_path, od_mode, &Open_Env)))
280  return XrdOfsFS->fsError(error, retc);
281 
282 // Open the directory and allocate a handle for it
283 //
284  if (!(dp = XrdOfsOss->newDir(tident))) retc = -ENOMEM;
285  else if (!(retc = dp->Opendir(dir_path, Open_Env)))
286  {fname = strdup(dir_path);
287  return SFS_OK;
288  }
289 
290 // Handle extended error information
291 //
292  std::string eText;
293  const char* etP = 0;
294  if (dp && XrdOfsFS->tryXERT)
295  {if (dp->getErrMsg(eText)) etP = eText.c_str();
296  delete dp; dp = 0;
297  }
298 
299 // Encountered an error
300 //
301  return XrdOfsFS->Emsg(epname, error, retc, "open directory", dir_path, etP);
302 }
@ AOP_Readdir
opendir()
#define AUTHORIZE(usr, env, optype, action, pathp, edata)
XrdOss * XrdOfsOss
Definition: XrdOfs.cc:163
DIR * opendir(const char *path)
#define SFS_O_META
#define SFS_O_RDONLY
virtual int isRemote()
virtual int Locate(XrdOucErrInfo &Resp, const char *path, int flags, XrdOucEnv *Info=0)=0
XrdCmsClient * Finder
Definition: XrdOfs.hh:434
static int fsError(XrdOucErrInfo &myError, int rc)
Definition: XrdOfs.cc:2777
virtual int Opendir(const char *path, XrdOucEnv &env)
Definition: XrdOss.hh:84
virtual XrdOssDF * newDir(const char *tident)=0

References AOP_Readdir, AUTHORIZE, dp, XrdOfs::Emsg(), EPNAME, XrdSfsDirectory::error, XrdOfs::Finder, fname, XrdOfs::fsError(), XrdOssDF::getErrMsg(), XrdCmsClient::isRemote(), XrdCmsClient::Locate(), XrdOss::newDir(), opendir(), XrdOssDF::Opendir(), SFS_O_META, SFS_O_RDONLY, SFS_OK, tident, XrdOfsFS, XrdOfsOss, and XTRACE.

+ Here is the call graph for this function:

Member Data Documentation

◆ atEOF

int XrdOfsDirectory::atEOF
protected

Definition at line 91 of file XrdOfs.hh.

Referenced by nextEntry().

◆ dname

char XrdOfsDirectory::dname[MAXNAMLEN]
protected

Definition at line 92 of file XrdOfs.hh.

Referenced by nextEntry().

◆ dp

XrdOssDF* XrdOfsDirectory::dp
protected

Definition at line 90 of file XrdOfs.hh.

Referenced by ~XrdOfsDirectory(), autoStat(), close(), nextEntry(), and open().

◆ fname

char* XrdOfsDirectory::fname
protected

Definition at line 89 of file XrdOfs.hh.

Referenced by close(), FName(), nextEntry(), and open().

◆ tident

const char* XrdOfsDirectory::tident
protected

Definition at line 88 of file XrdOfs.hh.

Referenced by open().


The documentation for this class was generated from the following files: