Loading...
Searching...
No Matches
XrdOssAt Class Reference

`#include <XrdOssAt.hh>`

Collaboration diagram for XrdOssAt:

## Public Member Functions

| XrdOssAt (XrdOss &ossfs)
| ~XrdOssAt ()
| Destructor.
int | Opendir (XrdOssDF &atDir, const char *path, XrdOucEnv &env, XrdOssDF *&ossDF)
int | OpenRO (XrdOssDF &atDir, const char *path, XrdOucEnv &env, XrdOssDF *&ossDF)
int | Remdir (XrdOssDF &atDir, const char *path)
int | Stat (XrdOssDF &atDir, const char *path, struct stat &buf, int opts=0)
int | Unlink (XrdOssDF &atDir, const char *path)

## Static Public Attributes

static const int | At_dInfo = 0x00000001

## Detailed Description

This class defines the object that handles extended operations that are relative to an open directory. Create a single instance of this class by passing it the pointer to the asociated file system (XrdOss) and use the methods herein to effect various operations relative to an XrdOss directory.

Note
  1) The following relative methods are not currently implemented: access() (aka faccessat), chmod() (aka fchmodat), chown() (aka fchownat), mkdir() (aka mkdirat), readlink() (aka readlinkat), rename (a.k.a renameat), symlink() (aka symlinkat), and utimes() (a.k.a utimesat). 2) The path argument must be relative and is not subject to name2name() processing. This is in contrast to standard Unix "at" calls. 3) Only the online copy of the target is subject to these calls. Use the the standard calls for remote storage backed file systems.

Definition at line 61 of file XrdOssAt.hh.

## Constructor & Destructor Documentation

## XrdOssAt()

XrdOssAt::XrdOssAt | ( | XrdOss & | ossfs | ) |

inline

Constructor

Parameters

  ossfs | - Reference to the OSS system interface.

Definition at line 139 of file XrdOssAt.hh.

: ossFS(ossfs) {}

## ~XrdOssAt()

XrdOssAt::~XrdOssAt | ( |  | ) |

inline

Destructor.

Definition at line 145 of file XrdOssAt.hh.

{}

## Member Function Documentation

## Opendir()

int XrdOssAt::Opendir | ( | XrdOssDF & | atDir,
|  | const char * | path,
|  | XrdOucEnv & | env,
|  | XrdOssDF *& | ossDF )

Open a directory relative to an open directory.

Parameters

  atDir | - Reference to the directory object to use.
  path | - Pointer to the relative path of the directory to be opened.
  env | - Reference to environmental information.
  ossDF | - Reference to where the directory object pointer is to be returned upon success.

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Definition at line 96 of file XrdOssAt.cc.

{
openHelper hOpen;
DIR *dirP;
int dirFD;
// Standard boilerplate
//
BOILER_PLATE(dirFD, atDir);
// Open the target
//
OPEN_AT(hOpen.FD, dirFD, path, O_RDONLY);
// Create a new dir entry from this FD
//
dirP = fdopendir(hOpen.FD);
if (!dirP) return (errno ? -errno : -ENOMSG);
// Finally return a new directory object
//
ossDF = new XrdOssDir(atDir.getTID(), dirP);
hOpen.FD = -1;
return 0;
}
BOILER_PLATE
#define BOILER_PLATE(dfObj, fd)
Definition XrdOssAt.cc:66
OPEN_AT
#define OPEN_AT(dst, dfd, p, f)
Definition XrdOssAt.cc:76
XrdOssDF::getTID
virtual const char * getTID()
Definition XrdOss.hh:434

References BOILER_PLATE, XrdOssDF::getTID(), and OPEN_AT.

Here is the call graph for this function:

## OpenRO()

int XrdOssAt::OpenRO | ( | XrdOssDF & | atDir,
|  | const char * | path,
|  | XrdOucEnv & | env,
|  | XrdOssDF *& | ossDF )

Open a file in r/o mode relative to an open directory.

Parameters

  atDir | - Reference to the directory object to use.
  path | - Pointer to the relative path of the file to be opened.
  env | - Reference to environmental information.
  ossDF | - Reference to where the file object pointer is to be returned upon success.

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Definition at line 127 of file XrdOssAt.cc.

{
openHelper hOpen;
int dirFD;
// Standard boilerplate
//
BOILER_PLATE(dirFD, atDir);
// Open the target
//
OPEN_AT(hOpen.FD, dirFD, path, O_RDONLY);
// Return a new file object
//
ossDF = new XrdOssFile(atDir.getTID(), hOpen.FD);
hOpen.FD = -1;
return 0;
}

References BOILER_PLATE, XrdOssDF::getTID(), and OPEN_AT.

Here is the call graph for this function:

## Remdir()

int XrdOssAt::Remdir | ( | XrdOssDF & | atDir,
|  | const char * | path )

Remove a directory relative to an open directory. Only the online entry is removed (use standard remdir() for tape backed systems).

Parameters

  atDir | - Reference to the directory object to use.
  path | - Pointer to the path of the directory to be removed.

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Definition at line 152 of file XrdOssAt.cc.

{
int dirFD;
// Standard boilerplate
//
BOILER_PLATE(dirFD, atDir);
// Effect the removal
//
if (unlinkat(dirFD, path, AT_REMOVEDIR)) return -errno;
// All done
//
return 0;
}

References BOILER_PLATE.

## Stat()

int XrdOssAt::Stat | ( | XrdOssDF & | atDir,
|  | const char * | path,
|  | struct stat & | buf,
|  | int | opts = 0 )

Definition at line 173 of file XrdOssAt.cc.

{
int dirFD;
// Standard boilerplate
//
BOILER_PLATE(dirFD, atDir);
// Do the stat call
//
if (fstatat(dirFD, path, &buf, 0)) return -errno;
// Check if we need to provide dev info
//
if (opts & At_dInfo) XrdOssCache::DevInfo(buf);
// All done
//
return 0;
}
opts
struct myOpts opts
XrdOssAt::At_dInfo
static const int At_dInfo
Definition XrdOssAt.hh:117
XrdOssCache::DevInfo
static void DevInfo(struct stat &buf, bool limits=false)
Definition XrdOssCache.cc:583

References At_dInfo, BOILER_PLATE, XrdOssCache::DevInfo(), opts, and stat.

Referenced by Unlink().

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

## Unlink()

int XrdOssAt::Unlink | ( | XrdOssDF & | atDir,
|  | const char * | path )

Remove a file relative to an open directory. Only the online copy is is removed (use standard unlink() for tape backed systems).

Parameters

  atDir | - Reference to the directory object to use.
  path | - Pointer to the path of the file to be removed.

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Definition at line 199 of file XrdOssAt.cc.

{
struct stat Stat;
int dirFD;
// Standard boilerplate
//
BOILER_PLATE(dirFD, atDir);
// This could be a symlink or an actual file but not a directory.
//
if (fstatat(dirFD, path, &Stat, AT_SYMLINK_NOFOLLOW))
return (errno == ENOENT ? 0 : -errno);
if ((Stat.st_mode & S_IFMT) == S_IFDIR) return -EISDIR;
// If this is not a symlink then we can delete it directly
//
if ((Stat.st_mode & S_IFMT) != S_IFLNK)
{if (unlinkat(dirFD, path, 0)) return -errno;
if (Stat.st_size)
XrdOssCache::Adjust(Stat.st_dev, -Stat.st_size);
return 0;
}
// Get the target of this link
//
char lnkbuff[MAXPATHLEN+64];
int lnklen, retc;
if ((lnklen = readlinkat(dirFD, path, lnkbuff, sizeof(lnkbuff)-1)) < 0)
return -errno;
// If the underlying file exists, remove it
//
lnkbuff[lnklen] = '\0';
if (stat(lnkbuff, &Stat)) Stat.st_size = 0;
else if (unlink(lnkbuff) && errno != ENOENT)
{retc = -errno;
OssEroute.Emsg("Unlink",retc,"unlink symlink target",lnkbuff);
return -retc;
}
// Adjust the size based on what kind of data cache we are using.
//
if (Stat.st_size)
{char *lP = lnkbuff+lnklen-1;
if (*lP == XrdOssPath::xChar)
{XrdOssPath::Trim2Base(lP);
XrdOssCache::Adjust(lnkbuff, -Stat.st_size);
}
else XrdOssCache::Adjust(Stat.st_dev, -Stat.st_size);
}
// Effect the removal of the actual symlink
//
if (unlinkat(dirFD, path, 0)) return -errno;
// All done
//
return 0;
}
OssEroute
XrdSysError OssEroute
unlink
#define unlink(a)
Definition XrdPosix.hh:113
stat
#define stat(a, b)
Definition XrdPosix.hh:101
XrdOssAt::Stat
int Stat(XrdOssDF &atDir, const char *path, struct stat &buf, int opts=0)
Definition XrdOssAt.cc:173
XrdOssCache::Adjust
static void Adjust(dev_t devid, off_t size)
Definition XrdOssCache.cc:397
XrdOssPath::Trim2Base
static void Trim2Base(char *eP)
Definition XrdOssPath.cc:304
XrdOssPath::xChar
static const char xChar
Definition XrdOssPath.hh:47
XrdSysError::Emsg
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition XrdSysError.cc:95

References XrdOssCache::Adjust(), BOILER_PLATE, OssEroute, Stat(), stat, XrdOssPath::Trim2Base(), unlink, and XrdOssPath::xChar.

Here is the call graph for this function:

## Member Data Documentation

## At_dInfo

const int XrdOssAt::At_dInfo = 0x00000001

static

Return state information on the target relative to an open directory.

Parameters

  atDir | - Reference to the directory object to use.
  path | - Pointer to the path of the target to be interrogated.
  buf | - Reference to the structure where info it to be returned.
  opts | - Options: At_dInfo - provide bdevID in st_rdev and partID in st_dev

Returns
  0 upon success or -errno or -osserr (see XrdOssError.hh).

Definition at line 117 of file XrdOssAt.hh.

Referenced by Stat().

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

- XrdOssAt.hh
- XrdOssAt.cc