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 62 of file XrdOfs.hh.

Constructor & Destructor Documentation

◆ XrdOfsDirectory()

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

Definition at line 80 of file XrdOfs.hh.

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

◆ ~XrdOfsDirectory()

virtual XrdOfsDirectory::~XrdOfsDirectory ( )
inlinevirtual

Definition at line 84 of file XrdOfs.hh.

84 {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 402 of file XrdOfs.cc.

417 {
418  EPNAME("autoStat");
419  int retc;
420 
421 // Check if this directory is actually open
422 //
423  if (!dp) {XrdOfsFS->Emsg(epname, error, EBADF, "autostat directory");
424  return SFS_ERROR;
425  }
426 
427 // Set the stat buffer in the storage system directory but don't complain.
428 //
429  if ((retc = dp->StatRet(buf))) return retc;
430  return SFS_OK;
431 }
#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)
Definition: XrdOfs.cc:2513
virtual int StatRet(struct stat *buff)
Definition: XrdOss.hh:107
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 359 of file XrdOfs.cc.

372 {
373  EPNAME("closedir");
374  int retc;
375 
376 // Check if this directory is actually open
377 //
378  if (!dp) {XrdOfsFS->Emsg(epname, error, EBADF, "close directory");
379  return SFS_ERROR;
380  }
381  XTRACE(closedir, fname, "");
382 
383 // Close this directory
384 //
385  if ((retc = dp->Close()))
386  retc = XrdOfsFS->Emsg(epname, error, retc, "close", fname);
387  else retc = SFS_OK;
388 
389 // All done
390 //
391  delete dp;
392  dp = 0;
393  free(fname);
394  fname = 0;
395  return retc;
396 }
#define XTRACE(act, target, x)
Definition: XrdBwmTrace.hh:49
int closedir(DIR *dirp)
virtual int Close(long long *retsz=0)=0

References XrdOssDF::Close(), closedir(), dp, XrdOfs::Emsg(), EPNAME, XrdSfsDirectory::error, fname, 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 74 of file XrdOfs.hh.

74 {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 76 of file XrdOfs.hh.

76 {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 299 of file XrdOfs.cc.

319 {
320  EPNAME("readdir");
321  int retc;
322 
323 // Check if this directory is actually open
324 //
325  if (!dp) {XrdOfsFS->Emsg(epname, error, EBADF, "read directory");
326  return 0;
327  }
328 
329 // Check if we are at EOF (once there we stay there)
330 //
331  if (atEOF) return 0;
332 
333 // Read the next directory entry
334 //
335  if ((retc = dp->Readdir(dname, sizeof(dname))) < 0)
336  {XrdOfsFS->Emsg(epname, error, retc, "read directory", fname);
337  return 0;
338  }
339 
340 // Check if we have reached end of file
341 //
342  if (!*dname)
343  {atEOF = 1;
344  error.clear();
345  XTRACE(readdir, fname, "<eof>");
346  return 0;
347  }
348 
349 // Return the actual entry
350 //
352  return (const char *)(dname);
353 }
struct dirent * readdir(DIR *dirp)
char dname[MAXNAMLEN]
Definition: XrdOfs.hh:91
virtual int Readdir(char *buff, int blen)
Definition: XrdOss.hh:92
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::Readdir(), 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 239 of file XrdOfs.cc.

256 {
257  EPNAME("opendir");
258  static const int od_mode = SFS_O_RDONLY|SFS_O_META;
259  XrdOucEnv Open_Env(info,0,client);
260  int retc;
261 
262 // Trace entry
263 //
264  XTRACE(opendir, dir_path, "");
265 
266 // Verify that this object is not already associated with an open directory
267 //
268  if (dp) return
269  XrdOfsFS->Emsg(epname, error, EADDRINUSE, "open directory", dir_path);
270 
271 // Apply security, as needed
272 //
273  AUTHORIZE(client,&Open_Env,AOP_Readdir,"open directory",dir_path,error);
274 
275 // Find out where we should open this directory
276 //
277  if (XrdOfsFS->DirRdr && XrdOfsFS->Finder && XrdOfsFS->Finder->isRemote()
278  && (retc = XrdOfsFS->Finder->Locate(error, dir_path, od_mode, &Open_Env)))
279  return XrdOfsFS->fsError(error, retc);
280 
281 // Open the directory and allocate a handle for it
282 //
283  if (!(dp = XrdOfsOss->newDir(tident))) retc = -ENOMEM;
284  else if (!(retc = dp->Opendir(dir_path, Open_Env)))
285  {fname = strdup(dir_path);
286  return SFS_OK;
287  }
288  else {delete dp; dp = 0;}
289 
290 // Encountered an error
291 //
292  return XrdOfsFS->Emsg(epname, error, retc, "open directory", dir_path);
293 }
@ 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:429
static int fsError(XrdOucErrInfo &myError, int rc)
Definition: XrdOfs.cc:2628
virtual int Opendir(const char *path, XrdOucEnv &env)
Definition: XrdOss.hh:79
virtual XrdOssDF * newDir(const char *tident)=0

References AOP_Readdir, AUTHORIZE, dp, XrdOfs::Emsg(), EPNAME, XrdSfsDirectory::error, XrdOfs::Finder, fname, XrdOfs::fsError(), 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 90 of file XrdOfs.hh.

Referenced by nextEntry().

◆ dname

char XrdOfsDirectory::dname[MAXNAMLEN]
protected

Definition at line 91 of file XrdOfs.hh.

Referenced by nextEntry().

◆ dp

XrdOssDF* XrdOfsDirectory::dp
protected

Definition at line 89 of file XrdOfs.hh.

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

◆ fname

char* XrdOfsDirectory::fname
protected

Definition at line 88 of file XrdOfs.hh.

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

◆ tident

const char* XrdOfsDirectory::tident
protected

Definition at line 87 of file XrdOfs.hh.

Referenced by open().


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