XRootD
XrdOssAt Class Reference

#include <XrdOssAt.hh>

+ Collaboration diagram for XrdOssAt:

Public Member Functions

 XrdOssAt (XrdOss &ossfs)
 
 ~XrdOssAt ()
 Destructor. More...
 
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.

139 : ossFS(ossfs) {}

◆ ~XrdOssAt()

XrdOssAt::~XrdOssAt ( )
inline

Destructor.

Definition at line 145 of file XrdOssAt.hh.

145 {}

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.

98 {
99  openHelper hOpen;
100  DIR *dirP;
101  int dirFD;
102 
103 // Standard boilerplate
104 //
105  BOILER_PLATE(dirFD, atDir);
106 
107 // Open the target
108 //
109  OPEN_AT(hOpen.FD, dirFD, path, O_RDONLY);
110 
111 // Create a new dir entry from this FD
112 //
113  dirP = fdopendir(hOpen.FD);
114  if (!dirP) return (errno ? -errno : -ENOMSG);
115 
116 // Finally return a new directory object
117 //
118  ossDF = new XrdOssDir(atDir.getTID(), dirP);
119  hOpen.FD = -1;
120  return 0;
121 }
#define BOILER_PLATE(dfObj, fd)
Definition: XrdOssAt.cc:66
#define OPEN_AT(dst, dfd, p, f)
Definition: XrdOssAt.cc:76
virtual const char * getTID()
Definition: XrdOss.hh:434

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

Referenced by XrdPfc::FsTraversal::cd_down().

+ Here is the call graph for this function:
+ Here is the caller 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.

129 {
130  openHelper hOpen;
131  int dirFD;
132 
133 // Standard boilerplate
134 //
135  BOILER_PLATE(dirFD, atDir);
136 
137 // Open the target
138 //
139  OPEN_AT(hOpen.FD, dirFD, path, O_RDONLY);
140 
141 // Return a new file object
142 //
143  ossDF = new XrdOssFile(atDir.getTID(), hOpen.FD);
144  hOpen.FD = -1;
145  return 0;
146 }

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

Referenced by XrdPfc::FsTraversal::open_at_ro().

+ Here is the call graph for this function:
+ Here is the caller 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.

153 {
154  int dirFD;
155 
156 // Standard boilerplate
157 //
158  BOILER_PLATE(dirFD, atDir);
159 
160 // Effect the removal
161 //
162  if (unlinkat(dirFD, path, AT_REMOVEDIR)) return -errno;
163 
164 // All done
165 //
166  return 0;
167 }

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.

175 {
176  int dirFD;
177 
178 // Standard boilerplate
179 //
180  BOILER_PLATE(dirFD, atDir);
181 
182 // Do the stat call
183 //
184  if (fstatat(dirFD, path, &buf, 0)) return -errno;
185 
186 // Check if we need to provide dev info
187 //
188  if (opts & At_dInfo) XrdOssCache::DevInfo(buf);
189 
190 // All done
191 //
192  return 0;
193 }
struct myOpts opts
static const int At_dInfo
Definition: XrdOssAt.hh:117
static void DevInfo(struct stat &buf, bool limits=false)
Definition: XrdOssCache.cc:583

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

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.

200 {
201  struct stat Stat;
202  int dirFD;
203 
204 // Standard boilerplate
205 //
206  BOILER_PLATE(dirFD, atDir);
207 
208 // This could be a symlink or an actual file but not a directory.
209 //
210  if (fstatat(dirFD, path, &Stat, AT_SYMLINK_NOFOLLOW))
211  return (errno == ENOENT ? 0 : -errno);
212  if ((Stat.st_mode & S_IFMT) == S_IFDIR) return -EISDIR;
213 
214 // If this is not a symlink then we can delete it directly
215 //
216  if ((Stat.st_mode & S_IFMT) != S_IFLNK)
217  {if (unlinkat(dirFD, path, 0)) return -errno;
218  if (Stat.st_size)
219  XrdOssCache::Adjust(Stat.st_dev, -Stat.st_size);
220  return 0;
221  }
222 
223 // Get the target of this link
224 //
225  char lnkbuff[MAXPATHLEN+64];
226  int lnklen, retc;
227  if ((lnklen = readlinkat(dirFD, path, lnkbuff, sizeof(lnkbuff)-1)) < 0)
228  return -errno;
229 
230 // If the underlying file exists, remove it
231 //
232  lnkbuff[lnklen] = '\0';
233  if (stat(lnkbuff, &Stat)) Stat.st_size = 0;
234  else if (unlink(lnkbuff) && errno != ENOENT)
235  {retc = -errno;
236  OssEroute.Emsg("Unlink",retc,"unlink symlink target",lnkbuff);
237  return -retc;
238  }
239 
240 // Adjust the size based on what kind of data cache we are using.
241 //
242  if (Stat.st_size)
243  {char *lP = lnkbuff+lnklen-1;
244  if (*lP == XrdOssPath::xChar)
246  XrdOssCache::Adjust(lnkbuff, -Stat.st_size);
247  }
248  else XrdOssCache::Adjust(Stat.st_dev, -Stat.st_size);
249  }
250 
251 // Effect the removal of the actual symlink
252 //
253  if (unlinkat(dirFD, path, 0)) return -errno;
254 
255 // All done
256 //
257  return 0;
258 }
XrdSysError OssEroute
int stat(const char *path, struct stat *buf)
int unlink(const char *path)
int Stat(XrdOssDF &atDir, const char *path, struct stat &buf, int opts=0)
Definition: XrdOssAt.cc:173
static void Adjust(dev_t devid, off_t size)
Definition: XrdOssCache.cc:397
static void Trim2Base(char *eP)
Definition: XrdOssPath.cc:304
static const char xChar
Definition: XrdOssPath.hh:47
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95

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

Referenced by XrdPfc::FsTraversal::unlink_at().

+ Here is the call graph for this function:
+ Here is the caller 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: