Loading...
Searching...
No Matches
XrdDigDirectory Class Reference

`#include <XrdDigFS.hh>`

Inheritance diagram for XrdDigDirectory:
Collaboration diagram for XrdDigDirectory:

## Public Member Functions

| XrdDigDirectory (char *user=0, int monid=0)
| ~XrdDigDirectory ()
int | autoStat (struct stat *buf)
int | close ()
const char * | FName ()
const char * | nextEntry ()
int | open (const char *dirName, const XrdSecClientName *client=0, 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.
virtual int | open (const char *path, const XrdSecEntity *client=0, const char *opaque=0)=0

## Additional Inherited Members

Public Attributes inherited from XrdSfsDirectory
XrdOucErrInfo & | error

## Detailed Description

Definition at line 45 of file XrdDigFS.hh.

## Constructor & Destructor Documentation

## XrdDigDirectory()

XrdDigDirectory::XrdDigDirectory | ( | char * | user = 0,
|  | int | monid = 0 )

inline

Definition at line 61 of file XrdDigFS.hh.

: XrdSfsDirectory(user, monid),
dh((DIR *)0), fname(0), sBuff(0),
d_pnt(&dirent_full.d_entry),
dirFD(-1), ateof(false),
isProc(false), isBase(false) {}
XrdSfsDirectory::XrdSfsDirectory
XrdSfsDirectory(const char *user=0, int MonID=0)
Definition XrdSfsInterface.hh:320

References XrdSfsDirectory::XrdSfsDirectory().

Here is the call graph for this function:

## ~XrdDigDirectory()

XrdDigDirectory::~XrdDigDirectory | ( |  | ) |

inline

Definition at line 68 of file XrdDigFS.hh.

{if (dh) close();}
XrdDigDirectory::close
int close()
Definition XrdDigFS.cc:314

References close().

Here is the call graph for this function:

## Member Function Documentation

## autoStat()

int XrdDigDirectory::autoStat | ( | struct stat * | buf | ) |

inline 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 59 of file XrdDigFS.hh.

{sBuff = buf; return SFS_OK;}
SFS_OK
#define SFS_OK
Definition XrdSfsInterface.hh:108

References SFS_OK, and stat.

## close()

int XrdDigDirectory::close | ( |  | ) |

virtual

Close the directory.

Returns
  One of SFS_OK or SFS_ERROR

Implements XrdSfsDirectory.

Definition at line 314 of file XrdDigFS.cc.

{
static const char *epname = "closedir";
// Release the handle
//
sBuff = 0;
if (dh && closedir(dh))
{XrdDigFS::Emsg(epname, error, errno, "close directory", fname);
return SFS_ERROR;
}
// Do some clean-up
//
if (fname) {free(fname); fname = 0;}
dh = (DIR *)0;
isProc = isBase = false;
return SFS_OK;
}
closedir
#define closedir(a)
Definition XrdPosix.hh:50
SFS_ERROR
#define SFS_ERROR
Definition XrdSfsInterface.hh:109
XrdDigFS::Emsg
static int Emsg(const char *, XrdOucErrInfo &, int, const char *x, const char *y="")
Definition XrdDigFS.cc:605
XrdSfsDirectory::error
XrdOucErrInfo & error
Definition XrdSfsInterface.hh:252

References closedir, XrdDigFS::Emsg(), XrdSfsDirectory::error, SFS_ERROR, and SFS_OK.

Referenced by ~XrdDigDirectory().

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

## FName()

const char * XrdDigDirectory::FName | ( |  | ) |

inline virtual

Get the directory path.

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

Implements XrdSfsDirectory.

Definition at line 57 of file XrdDigFS.hh.

{return (const char *)fname;}

## nextEntry()

const char * XrdDigDirectory::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 204 of file XrdDigFS.cc.

{
static const char *epname = "nextEntry";
static const int wMask = ~(S_IWUSR | S_IWGRP | S_IWOTH);
struct dirent *rp;
int retc;
// Check for base listing
//
if (isBase)
{if (dirFD > 0) return dirent_full.aEnt[--dirFD];
ateof = true;
return (const char *)0;
}
// Lock the direcrtory and do any required tracing
//
if (!dh)
{XrdDigFS::Emsg(epname,error,EBADF,"read directory",fname);
return (const char *)0;
}
// Check if we are at EOF (once there we stay there)
//
if (ateof) return (const char *)0;
// Read the next directory entry
//
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
do{errno = 0;
rp = readdir(dh);
if (!rp)
{if (!(retc = errno)) {ateof = 1; error.clear();}
else XrdDigFS::Emsg(epname,error,retc,"read directory",fname);
d_pnt->d_name[0] = '\0';
return (const char *)0;
}
#else
do{if ((retc = readdir_r(dh, d_pnt, &rp)))
{XrdDigFS::Emsg(epname,error,retc,"read directory",fname);
d_pnt->d_name[0] = '\0';
return (const char *)0;
}
// Check if we have reached end of file
//
if (!rp || !d_pnt->d_name[0])
{ateof = true;
error.clear();
return (const char *)0;
}
#endif
// If autostat wanted, do so here
//
if (sBuff)
{
#ifdef HAVE_FSTATAT
int sFlags = (isProc ? AT_SYMLINK_NOFOLLOW : 0);
if (fstatat(dirFD, rp->d_name, sBuff, sFlags)) continue;
sBuff->st_mode = (sBuff->st_mode & wMask) | S_IRUSR;
#else
char dPath[2048];
snprintf(dPath, sizeof(dPath), "%s%s", fname, rp->d_name);
if (stat(dPath, sBuff)) continue;
sBuff->st_mode = (sBuff->st_mode & wMask) | S_IRUSR;
#endif
}
// We want to extend the directory entry information with symlink information
// if this is a symlink. This is only done for /proc (Linux only)
//
#ifdef __linux__
if (isProc)
{struct stat Stat, *sP = (sBuff ? sBuff : &Stat);
char *dP;
int n, rc;
rc = (sBuff ? 0:fstatat(dirFD,rp->d_name,&Stat,AT_SYMLINK_NOFOLLOW));
if (!rc && !noTag && S_ISLNK(sP->st_mode))
{n = strlen(rp->d_name);
dP = rp->d_name + n + 4;
n = sizeof(dirent_full.nbf) - (n + 8);
if ((n = readlinkat(dirFD,rp->d_name,dP,n)) < 0) strcpy(dP,"?");
else *(dP+n) = 0;
memcpy(dP-4, " -> ", 4);
}
}
#endif
// Return the actual entry
//
return (const char *)(rp->d_name);
} while(1);
return 0; // Keep compiler happy
}
Stat
struct stat Stat
Definition XrdCks.cc:49
readdir_r
#define readdir_r(a, b, c)
Definition XrdPosix.hh:89
stat
#define stat(a, b)
Definition XrdPosix.hh:101
readdir
#define readdir(a)
Definition XrdPosix.hh:86

References XrdDigFS::Emsg(), XrdSfsDirectory::error, readdir, readdir_r, Stat, and stat.

Here is the call graph for this function:

## open()

int XrdDigDirectory::open | ( | const char * | dirName,
|  | const XrdSecClientName * | client = 0,
|  | const char * | opaque = 0 )

Definition at line 135 of file XrdDigFS.cc.

{
static const char *epname = "opendir";
int retc;
// Verify that this object is not already associated with an open directory
//
if (dh || isBase) return XrdDigFS::Emsg(epname, error, EADDRINUSE,
"open directory", dir_path);
// Check if we are trying to open the root to list it
//
if (!strcmp(dir_path, SFS_LCLPRFX) || !strcmp(dir_path, SFS_LCLPRFY))
{isBase = true;
if ((dirFD = Config.GenAccess(client, dirent_full.aEnt, aESZ)) < 0)
return XrdDigFS::Emsg(epname,error,EACCES,"open directory",dir_path);
ateof = dirFD == 0;
return SFS_OK;
}
// Authorize this open and get actual file name to open
//
if ( (retc = XrdDigFS::Validate(dir_path))
|| !(fname = Config.GenPath(retc, client, "opendir",
dir_path+SFS_LCLPLEN, XrdDigConfig::isDir)))
return XrdDigFS::Emsg(epname,error,retc,"open directory",dir_path);
// Set up values for this directory object
//
ateof = false;
// Open the directory and get it's id
//
if (!(dh = opendir(fname)))
{if (fname) {free(fname); fname = 0;}
return XrdDigFS::Emsg(epname,error,errno,"open directory",dir_path);
}
// Check if this is a reference to /proc (Linux only)
//
#ifdef __linux__
if (IS_PROC(dir_path))
{noTag = *(dir_path+SFS_LCLPLEN+4) == 0
|| !strcmp(dir_path+SFS_LCLPLEN+4, "/");
isProc = true;
dirFD = dirfd(dh);
}
#endif
// All done
//
return SFS_OK;
}
opendir
#define opendir(a)
Definition XrdPosix.hh:78
SFS_LCLPRFY
#define SFS_LCLPRFY
Definition XrdSfsInterface.hh:120
SFS_LCLPRFX
#define SFS_LCLPRFX
Definition XrdSfsInterface.hh:117
SFS_LCLPLEN
#define SFS_LCLPLEN
Definition XrdSfsInterface.hh:118
dirfd
#define dirfd(x)
Definition XrdSysFAttrSun.icc:116
XrdDigConfig::GenAccess
int GenAccess(const XrdSecEntity *client, const char *aList[], int aMax)
Definition XrdDigConfig.cc:189
XrdDigConfig::isDir
@ isDir
Definition XrdDigConfig.hh:45
XrdDigConfig::GenPath
char * GenPath(int &rc, const XrdSecEntity *client, const char *opname, const char *lfn, pType lfnType=isAny)
Definition XrdDigConfig.cc:226
XrdDigFS::Validate
static int Validate(const char *)
Definition XrdDigFS.cc:812
XrdDig::Config
XrdDigConfig Config
Definition XrdDigConfig.cc:72

References XrdDig::Config, dirfd, XrdDigFS::Emsg(), XrdSfsDirectory::error, XrdDigConfig::isDir, opendir, SFS_LCLPLEN, SFS_LCLPRFX, SFS_LCLPRFY, SFS_OK, XrdDigFS::Validate(), and XrdSecClientName.

Here is the call graph for this function:

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

- XrdDigFS.hh
- XrdDigFS.cc