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 422 of file XrdOfs.cc.

437 {
438  EPNAME("autoStat");
439  int retc;
440 
441 // Check if this directory is actually open
442 //
443  if (!dp) {XrdOfsFS->Emsg(epname, error, EBADF, "autostat directory");
444  return SFS_ERROR;
445  }
446 
447 // Set the stat buffer in the storage system directory but don't complain.
448 //
449  if ((retc = dp->StatRet(buf))) return retc;
450  return SFS_OK;
451 }
#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:2633
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 376 of file XrdOfs.cc.

389 {
390  EPNAME("closedir");
391  int retc;
392 
393 // Check if this directory is actually open
394 //
395  if (!dp) {XrdOfsFS->Emsg(epname, error, EBADF, "close directory");
396  return SFS_ERROR;
397  }
398  XTRACE(closedir, fname, "");
399 
400 // Close this directory
401 //
402  if ((retc = dp->Close()))
403  {std::string eText;
404  const char* etP = 0;
405  if (XrdOfsFS->tryXERT && dp->getErrMsg(eText)) etP = eText.c_str();
406  retc = XrdOfsFS->Emsg(epname, error, retc, "close", fname, etP);
407  } else retc = SFS_OK;
408 
409 // All done
410 //
411  delete dp;
412  dp = 0;
413  free(fname);
414  fname = 0;
415  return retc;
416 }
#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 313 of file XrdOfs.cc.

333 {
334  EPNAME("readdir");
335  int retc;
336 
337 // Check if this directory is actually open
338 //
339  if (!dp) {XrdOfsFS->Emsg(epname, error, EBADF, "read directory");
340  return 0;
341  }
342 
343 // Check if we are at EOF (once there we stay there)
344 //
345  if (atEOF) return 0;
346 
347 // Read the next directory entry
348 //
349  if ((retc = dp->Readdir(dname, sizeof(dname))) < 0)
350  {std::string eText;
351  const char* etP = 0;
352  if (XrdOfsFS->tryXERT && dp->getErrMsg(eText)) etP = eText.c_str();
353  XrdOfsFS->Emsg(epname, error, retc, "read directory", fname, etP);
354  return 0;
355  }
356 
357 // Check if we have reached end of file
358 //
359  if (!*dname)
360  {atEOF = 1;
361  error.clear();
362  XTRACE(readdir, fname, "<eof>");
363  return 0;
364  }
365 
366 // Return the actual entry
367 //
369  return (const char *)(dname);
370 }
#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 245 of file XrdOfs.cc.

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