XRootD
XrdPosixXrootd Class Reference

POSIX interface to XRootD with some extensions, as noted. More...

#include <XrdPosixXrootd.hh>

+ Collaboration diagram for XrdPosixXrootd:

Public Member Functions

 XrdPosixXrootd (int maxfd=255, int maxdir=0, int maxthr=0)
 
 ~XrdPosixXrootd ()
 
int fdOrigin ()
 

Static Public Member Functions

static int Access (const char *path, int amode)
 Access() conforms to POSIX.1-2001 access() More...
 
static int Close (int fildes)
 Close() conforms to POSIX.1-2001 close() More...
 
static int Closedir (DIR *dirp)
 Closedir() conforms to POSIX.1-2001 closedir() More...
 
static int endPoint (int FD, char *Buff, int Blen)
 
static int Fstat (int fildes, struct stat *buf)
 Fstat() conforms to POSIX.1-2001 fstat() More...
 
static int Fsync (int fildes)
 Fsync() conforms to POSIX.1-2001 fsync() More...
 
static void Fsync (int fildes, XrdPosixCallBackIO *cbp)
 
static int Ftruncate (int fildes, off_t offset)
 Ftruncate() conforms to POSIX.1-2001 ftruncate() More...
 
static long long Getxattr (const char *path, const char *name, void *value, unsigned long long size)
 
static bool isXrootdDir (DIR *dirp)
 
static off_t Lseek (int fildes, off_t offset, int whence)
 Lseek() conforms to POSIX.1-2001 lseek() More...
 
static int Mkdir (const char *path, mode_t mode)
 Mkdir() conforms to POSIX.1-2001 mkdir() More...
 
static bool myFD (int fd)
 
static int Open (const char *path, int oflag, mode_t mode=0, XrdPosixCallBack *cbP=0)
 
static DIR * Opendir (const char *path)
 Opendir() conforms to POSIX.1-2001 opendir() More...
 
static ssize_t Pread (int fildes, void *buf, size_t nbyte, off_t offset)
 Pread() conforms to POSIX.1-2001 pread() More...
 
static void Pread (int fildes, void *buf, size_t nbyte, off_t offset, XrdPosixCallBackIO *cbp)
 
static ssize_t Pwrite (int fildes, const void *buf, size_t nbyte, off_t offset)
 Pwrite() conforms to POSIX.1-2001 pwrite() More...
 
static void Pwrite (int fildes, const void *buf, size_t nbyte, off_t offset, XrdPosixCallBackIO *cbp)
 
static int QueryChksum (const char *path, time_t &mtime, char *buff, int blen)
 
static int QueryError (std::string &emsg, DIR *dirP, bool reset=true)
 
static int QueryError (std::string &emsg, int fd=-1, bool reset=true)
 
static long long QueryOpaque (const char *path, char *buff, int blen)
 
static ssize_t Read (int fildes, void *buf, size_t nbyte)
 Read() conforms to POSIX.1-2001 read() More...
 
static struct dirent * Readdir (DIR *dirp)
 
static struct dirent64 * Readdir64 (DIR *dirp)
 
static int Readdir64_r (DIR *dirp, struct dirent64 *entry, struct dirent64 **result)
 
static int Readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result)
 
static ssize_t Readv (int fildes, const struct iovec *iov, int iovcnt)
 Readv() conforms to POSIX.1-2001 readv() More...
 
static int Rename (const char *oldpath, const char *newpath)
 Rename() conforms to POSIX.1-2001 rename() More...
 
static void Rewinddir (DIR *dirp)
 Rewinddir() conforms to POSIX.1-2001 rewinddir() More...
 
static int Rmdir (const char *path)
 Rmdir() conforms to POSIX.1-2001 rmdir() More...
 
static void Seekdir (DIR *dirp, long loc)
 Seekdir() conforms to POSIX.1-2001 seekdir() More...
 
static int Stat (const char *path, struct stat *buf)
 Stat() conforms to POSIX.1-2001 stat() More...
 
static int Statfs (const char *path, struct statfs *buf)
 
static int Statvfs (const char *path, struct statvfs *buf)
 Statvfs() conforms to POSIX.1-2001 statvfs() More...
 
static long Telldir (DIR *dirp)
 Telldir() conforms to POSIX.1-2001 telldir() More...
 
static int Truncate (const char *path, off_t offset)
 Telldir() conforms to POSIX.1-2001 telldir() More...
 
static int Unlink (const char *path)
 Unlink() conforms to POSIX.1-2001 unlink() More...
 
static ssize_t VRead (int fildes, const XrdOucIOVec *readV, int n)
 
static void VRead (int fildes, const XrdOucIOVec *readV, int n, XrdPosixCallBackIO *cbp)
 
static ssize_t Write (int fildes, const void *buf, size_t nbyte)
 Write() conforms to POSIX.1-2001 write() More...
 
static ssize_t Writev (int fildes, const struct iovec *iov, int iovcnt)
 Writev() conforms to POSIX.1-2001 writev() More...
 

Static Public Attributes

static const int isStream = 0x40000000
 

Friends

class XrdPosixConfig
 
class XrdPosixExtra
 

Detailed Description

POSIX interface to XRootD with some extensions, as noted.

Definition at line 63 of file XrdPosixXrootd.hh.

Constructor & Destructor Documentation

◆ XrdPosixXrootd()

XrdPosixXrootd::XrdPosixXrootd ( int  maxfd = 255,
int  maxdir = 0,
int  maxthr = 0 
)

Definition at line 179 of file XrdPosixXrootd.cc.

180 {
181  static XrdSysMutex myMutex;
182  char *cfn;
183 
184 // Test if XRDCL_EC is set. That env var. is set at XrdCl::PlugInManager::LoadFactory
185 // in XrdClPlugInManager.cc, which is called (by XrdOssGetSS while loading
186 // libXrdPss.so) before this function.
187 // Note: some standalone programs will call this constructor directly.
188  XrdPosixGlobals::usingEC = getenv("XRDCL_EC")? true : false;
189 
190 // Only static fields are initialized here. We need to do this only once!
191 //
192  myMutex.Lock();
193  if (initDone) {myMutex.UnLock(); return;}
194  initDone = 1;
195  myMutex.UnLock();
196 
197 // Initialize environment as a client or a server (it differs somewhat).
198 // Note that we create a permanent Env since some plugins rely on it. We
199 // leave the logger handling to OucPsx as we do not want to enable messages
200 // because this is likely a client application that doesn't understand noise.
201 //
202  if (!XrdPosixGlobals::theLogger && (cfn=getenv("XRDPOSIX_CONFIG")) && *cfn)
203  {bool hush;
204  if (*cfn == '+') {hush = false; cfn++;}
205  else hush = (getenv("XRDPOSIX_DEBUG") == 0);
206  if (*cfn)
207  {XrdOucEnv *psxEnv = new XrdOucEnv;
208  psxEnv->Put("psx.Client", "1");
209  XrdOucPsx psxConfig(&XrdVERSIONINFOVAR(XrdPosix), cfn, 0, psxEnv);
210  if (!psxConfig.ClientConfig("posix.", hush)
211  || !XrdPosixConfig::SetConfig(psxConfig))
212  {std::cerr <<"Posix: Unable to instantiate specified "
213  "configuration; program exiting!" <<std::endl;
214  exit(16);
215  }
216  }
217  }
218 
219 // Initialize file tracking
220 //
221  baseFD = XrdPosixObject::Init(fdnum);
222 }
void Put(const char *varname, const char *value)
Definition: XrdOucEnv.hh:85
static bool SetConfig(XrdOucPsx &parms)
static int Init(int numfd)
XrdSysLogger * theLogger

References XrdOucPsx::ClientConfig(), XrdPosixObject::Init(), XrdSysMutex::Lock(), XrdOucEnv::Put(), XrdPosixConfig::SetConfig(), XrdPosixGlobals::theLogger, XrdSysMutex::UnLock(), and XrdPosixGlobals::usingEC.

+ Here is the call graph for this function:

◆ ~XrdPosixXrootd()

XrdPosixXrootd::~XrdPosixXrootd ( )

Definition at line 228 of file XrdPosixXrootd.cc.

229 {
230 
231 // Shutdown processing
232 //
234  initDone = 0;
235 }
static void Shutdown()

References XrdPosixObject::Shutdown().

+ Here is the call graph for this function:

Member Function Documentation

◆ Access()

int XrdPosixXrootd::Access ( const char *  path,
int  amode 
)
static

Access() conforms to POSIX.1-2001 access()

Definition at line 241 of file XrdPosixXrootd.cc.

242 {
244  mode_t stMode;
245  bool aOK = true;
246 
247 // Issue the stat and verify that all went well
248 //
249  if (!admin.Stat(&stMode)) return -1;
250 
251 // Translate the mode bits
252 //
253  if (amode & R_OK && !(stMode & S_IRUSR)) aOK = 0;
254  if (amode & W_OK && !(stMode & S_IWUSR)) aOK = 0;
255  if (amode & X_OK && !(stMode & S_IXUSR)) aOK = 0;
256 
257 // All done
258 //
259  if (aOK) return 0;
260  return XrdPosixGlobals::ecMsg.SetErrno(EACCES);
261 }
int SetErrno(int ecc, int retval=-1, const char *alt=0)
Definition: XrdOucECMsg.cc:144
thread_local XrdOucECMsg ecMsg

References XrdPosixGlobals::ecMsg, XrdOucECMsg::SetErrno(), and XrdPosixAdmin::Stat().

Referenced by XrdPosix_Access().

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

◆ Close()

int XrdPosixXrootd::Close ( int  fildes)
static

Close() conforms to POSIX.1-2001 close()

Definition at line 267 of file XrdPosixXrootd.cc.

268 {
269  EPNAME("Close");
270  XrdCl::XRootDStatus Status;
271  XrdPosixFile *fP;
272  bool ret;
273 
274 // Map the file number to the file object. In the prcess we relese the file
275 // number so no one can reference this file again.
276 //
277  if (!(fP = XrdPosixObject::ReleaseFile(fildes)))
278  return XrdPosixGlobals::ecMsg.SetErrno(EBADF);
279 
280 // Detach the file from a possible cache. We need to up the reference count
281 // to synchrnoize with any possible callback as we may need to place this
282 // object in he delayed destroy queue if it is stil being used. Note that
283 // the caller will get a zero return code should we delay the close.
284 //
285  fP->Ref();
286  if (fP->XCio->Detach((XrdOucCacheIOCD&)*fP) && fP->Refs() < 2)
287  {if ((ret = fP->Close(Status))) {delete fP; fP = 0;}
288  else if (DEBUGON)
289  {std::string eTxt = Status.ToString();
290  DEBUG(eTxt <<" closing " <<fP->Origin());
291  }
292  } else {
293  ret = true;
294  }
295 
296 // If we still have a handle then we need to do a delayed delete on this
297 // object because either the close failed or there is still active I/O
298 //
299  if (fP) XrdPosixFile::DelayedDestroy(fP);
300 
301 // Return final result. Note: close errors are recorded in global thread status
302 //
303  return (ret ? 0 : XrdPosixMap::Result(Status,XrdPosixGlobals::ecMsg,true));
304 }
#define DEBUG(x)
Definition: XrdBwmTrace.hh:54
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
#define DEBUGON
virtual bool Detach(XrdOucCacheIOCD &iocd)=0
XrdOucCacheIO * XCio
Definition: XrdPosixFile.hh:65
static void * DelayedDestroy(void *)
static int Result(const XrdCl::XRootDStatus &Status, XrdOucECMsg &ecMsg, bool retneg1=false)
Definition: XrdPosixMap.cc:150
static XrdPosixFile * ReleaseFile(int fildes)
std::string ToString() const
Create a string representation.
Definition: XrdClStatus.cc:97

References XrdPosixFile::Close(), DEBUG, DEBUGON, XrdPosixFile::DelayedDestroy(), XrdOucCacheIO::Detach(), XrdPosixGlobals::ecMsg, EPNAME, XrdPosixFile::Origin(), XrdPosixObject::Ref(), XrdPosixObject::Refs(), XrdPosixObject::ReleaseFile(), XrdPosixMap::Result(), XrdOucECMsg::SetErrno(), XrdCl::Status::ToString(), and XrdPosixFile::XCio.

Referenced by XrdPssFile::Close(), main(), XrdFfsPosix_close(), XrdPosix_Close(), XrdPosix_Fclose(), and XrdPosix_Fopen().

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

◆ Closedir()

int XrdPosixXrootd::Closedir ( DIR *  dirp)
static

Closedir() conforms to POSIX.1-2001 closedir()

Definition at line 310 of file XrdPosixXrootd.cc.

311 {
312  XrdPosixDir *dP;
313  int fildes = XrdPosixDir::dirNo(dirp);
314 
315 // Get the directory object
316 //
317  if (!(dP = XrdPosixObject::ReleaseDir(fildes)))
318  return XrdPosixGlobals::ecMsg.SetErrno(EBADF);
319 
320 // Deallocate the directory
321 //
322  delete dP;
323  return 0;
324 }
static int dirNo(DIR *dirP)
Definition: XrdPosixDir.hh:60
static XrdPosixDir * ReleaseDir(int fildes)

References XrdPosixDir::dirNo(), XrdPosixGlobals::ecMsg, XrdPosixObject::ReleaseDir(), and XrdOucECMsg::SetErrno().

Referenced by XrdPssDir::Close(), XrdFfsPosix_closedir(), and XrdPosix_Closedir().

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

◆ endPoint()

int XrdPosixXrootd::endPoint ( int  FD,
char *  Buff,
int  Blen 
)
static

endPoint() is a POSIX extension and returns the location of an open file.

Parameters
FDFile descriptor of an open file in question.
BuffPointer to the buffer to receive '<host>:<port>' of the server.
BlenSize of the buffer, it must be big enough for the result.
Returns
>= 0 The numeric port number of the data server.
-1 Call failed, errno has the reason.

Definition at line 330 of file XrdPosixXrootd.cc.

331 {
332  XrdPosixFile *fp;
333  int uPort;
334 
335 // Find the file object
336 //
337  if (!(fp = XrdPosixObject::File(FD))) return 0;
338 
339 // Make sure url is valid
340 //
341  if (!(fp->clFile.IsOpen()))
342  {fp->UnLock(); return -ENOTCONN;}
343 
344 // Make sure we can fit result in the buffer
345 //
346  std::string dataServer;
347  fp->clFile.GetProperty( "DataServer", dataServer );
348  XrdCl::URL dataServerUrl = dataServer;
349 
350  if (dataServer.size() >= (uint32_t)Blen)
351  {fp->UnLock(); return -ENAMETOOLONG;}
352 
353 // Copy the data server location
354 //
355  strcpy(Buff, dataServer.c_str());
356 
357 // Get the port and return it
358 //
359  uPort = dataServerUrl.GetPort();
360  fp->UnLock();
361  return uPort;
362 }
bool IsOpen() const
Check if the file is open.
Definition: XrdClFile.cc:846
bool GetProperty(const std::string &name, std::string &value) const
Definition: XrdClFile.cc:878
URL representation.
Definition: XrdClURL.hh:31
int GetPort() const
Get the target port.
Definition: XrdClURL.hh:183
XrdCl::File clFile
Definition: XrdPosixFile.hh:67
static XrdPosixFile * File(int fildes, bool glk=false)

References XrdPosixFile::clFile, XrdPosixObject::File(), XrdCl::URL::GetPort(), XrdCl::File::GetProperty(), XrdCl::File::IsOpen(), and XrdPosixObject::UnLock().

+ Here is the call graph for this function:

◆ fdOrigin()

int XrdPosixXrootd::fdOrigin ( )
inline

The following methods are considered private but defined as public to allow XrdPosix 'C' functions and XrdPss classes access private members.

Definition at line 371 of file XrdPosixXrootd.hh.

371 {return baseFD;}

◆ Fstat()

int XrdPosixXrootd::Fstat ( int  fildes,
struct stat buf 
)
static

Fstat() conforms to POSIX.1-2001 fstat()

Definition at line 368 of file XrdPosixXrootd.cc.

369 {
370  XrdPosixFile *fp;
371  int rc;
372 
373 // Find the file object
374 //
375  if (!(fp = XrdPosixObject::File(fildes))) return -1;
376 
377 // First initialize the stat buffer
378 //
380 
381 // Check if we can get the stat information from the cache.
382 //
383  rc = fp->XCio->Fstat(*buf);
384  if (rc <= 0)
385  {fp->UnLock();
386  if (!rc) return 0;
387  errno = -rc; //???
388  return -1;
389  }
390 
391 // At this point we can call the file's Fstat() and if the file is not open
392 // it will be opened.
393 //
394  rc = fp->Fstat(*buf);
395  fp->UnLock();
396  if (rc < 0) {errno = -rc; rc = -1;}
397  return rc;
398 }
virtual int Fstat(struct stat &sbuff)
Definition: XrdOucCache.hh:148
static void initStat(struct stat *buf)
int Fstat(struct stat &buf) override

References XrdPosixObject::File(), XrdPosixFile::Fstat(), XrdOucCacheIO::Fstat(), XrdPosixConfig::initStat(), XrdPosixObject::UnLock(), and XrdPosixFile::XCio.

Referenced by XrdPssFile::Fstat(), and XrdPosix_Fstat().

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

◆ Fsync() [1/2]

int XrdPosixXrootd::Fsync ( int  fildes)
static

Fsync() conforms to POSIX.1-2001 fsync()

Definition at line 404 of file XrdPosixXrootd.cc.

405 {
406  XrdPosixFile *fp;
407  int rc;
408 
409 // Find the file object
410 //
411  if (!(fp = XrdPosixObject::File(fildes))) return -1;
412 
413 // Do the sync
414 //
415  if ((rc = fp->XCio->Sync()) < 0) return Fault(fp, -rc);
416  fp->UnLock();
417  return 0;
418 }
virtual int Sync()=0

References XrdPosixObject::File(), XrdOucCacheIO::Sync(), XrdPosixObject::UnLock(), and XrdPosixFile::XCio.

Referenced by XrdPssFile::Fsync(), XrdFfsPosix_fsync(), XrdPosix_Fdatasync(), XrdPosix_Fflush(), and XrdPosix_Fsync().

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

◆ Fsync() [2/2]

void XrdPosixXrootd::Fsync ( int  fildes,
XrdPosixCallBackIO cbp 
)
static

Definition at line 422 of file XrdPosixXrootd.cc.

423 {
424  XrdPosixFile *fp;
425 
426 // Find the file object and do the sync
427 //
428  if ((fp = XrdPosixObject::File(fildes)))
429  {cbp->theFile = fp;
430  fp->Ref(); fp->UnLock();
431  fp->XCio->Sync(*cbp);
432  } else cbp->Complete(-1);
433 }
virtual void Complete(ssize_t Result)=0

References XrdPosixCallBackIO::Complete(), XrdPosixObject::File(), XrdPosixObject::Ref(), XrdOucCacheIO::Sync(), XrdPosixObject::UnLock(), and XrdPosixFile::XCio.

+ Here is the call graph for this function:

◆ Ftruncate()

int XrdPosixXrootd::Ftruncate ( int  fildes,
off_t  offset 
)
static

Ftruncate() conforms to POSIX.1-2001 ftruncate()

Definition at line 439 of file XrdPosixXrootd.cc.

440 {
441  XrdPosixFile *fp;
442  int rc;
443 
444 // Find the file object
445 //
446  if (!(fp = XrdPosixObject::File(fildes))) return -1;
447 
448 // Do the trunc
449 //
450  if ((rc = fp->XCio->Trunc(offset)) < 0) return Fault(fp, -rc);
451  fp->UnLock();
452  return 0;
453 }
virtual int Trunc(long long offs)=0

References XrdPosixObject::File(), XrdOucCacheIO::Trunc(), XrdPosixObject::UnLock(), and XrdPosixFile::XCio.

Referenced by XrdPssFile::Ftruncate(), XrdFfsPosix_ftruncate(), and XrdPosix_Ftruncate().

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

◆ Getxattr()

long long XrdPosixXrootd::Getxattr ( const char *  path,
const char *  name,
void *  value,
unsigned long long  size 
)
static

Getxattr() is a POSIX extension and conforms to Linux 2.4 getxattr(). This method returns attributes associated with a file. The format does not correspond to information returned by Linux. Refer to the XRootD protocol reference for the detailed description of the information returned.

Parameters
pathpointer to the path whose attributes are to be returned
namename of the attribute to be returned. Valid attributes are xrootd.cksum - file's checksum xrootd.space - space associated with the path xrootd.xattr - server specific extended attributes for path
valuepointer to the buffer to receive the attribute values.
sizesize of the buffer (value). If size is zero, only the maximum length of the attribute value is returned.
Returns
On success, a positive number is returned indicating the size of is extended attribute value. On failure, -1 is returned and errno

is set to indicate the reason.

Definition at line 463 of file XrdPosixXrootd.cc.

465 {
467  XrdCl::QueryCode::Code reqCode;
468  int vsize = static_cast<int>(size);
469 
470 // Check if user just wants the maximum length needed
471 //
472  if (size == 0) return 1024;
473 
474 // Check if we support the query
475 //
476  if (name)
477  { if (!strcmp(name,"xroot.cksum")) reqCode=XrdCl::QueryCode::Checksum;
478  else if (!strcmp(name,"xroot.space")) reqCode=XrdCl::QueryCode::Space;
479  else if (!strcmp(name,"xroot.xattr")) reqCode=XrdCl::QueryCode::XAttr;
480  else {errno = ENOATTR; return -1;} //???
481  }else {errno = EINVAL; return -1;}
482 
483 // Stat the file first to allow vectoring of the request to the right server
484 //
485  if (!admin.Stat()) return -1;
486 
487 // Return the result
488 //
489  return admin.Query(reqCode, value, vsize);
490 }
#define ENOATTR
Definition: XProtocol.hh:1339
Code
XRootD query request codes.
@ XAttr
Query file extended attributes.
@ Checksum
Query file checksum.
@ Space
Query logical space stats.

References XrdCl::QueryCode::Checksum, XrdPosixGlobals::ecMsg, ENOATTR, XrdPosixAdmin::Query(), XrdCl::QueryCode::Space, XrdPosixAdmin::Stat(), and XrdCl::QueryCode::XAttr.

Referenced by getchksum(), and XrdFfsPosix_getxattr().

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

◆ isXrootdDir()

bool XrdPosixXrootd::isXrootdDir ( DIR *  dirp)
static

Definition at line 1424 of file XrdPosixXrootd.cc.

1425 {
1426  XrdPosixDir *dP;
1427  int fildes;
1428 
1429  if (!dirp) return false;
1430  fildes = XrdPosixDir::dirNo(dirp);
1431 
1432  if (!myFD(fildes) || !(dP = XrdPosixObject::Dir(fildes))) return false;
1433 
1434  dP->UnLock();
1435  return true;
1436 }
static XrdPosixDir * Dir(int fildes, bool glk=false)
static bool myFD(int fd)

References XrdPosixObject::Dir(), XrdPosixDir::dirNo(), myFD(), and XrdPosixObject::UnLock().

Referenced by XrdPosix_Closedir(), XrdPosix_Readdir(), XrdPosix_Readdir64(), XrdPosix_Readdir64_r(), XrdPosix_Readdir_r(), XrdPosix_Rewinddir(), XrdPosix_Seekdir(), and XrdPosix_Telldir().

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

◆ Lseek()

off_t XrdPosixXrootd::Lseek ( int  fildes,
off_t  offset,
int  whence 
)
static

Lseek() conforms to POSIX.1-2001 lseek()

Definition at line 496 of file XrdPosixXrootd.cc.

497 {
498  XrdPosixFile *fp;
499  long long curroffset;
500 
501 // Find the file object
502 //
503  if (!(fp = XrdPosixObject::File(fildes))) return -1;
504 
505 // Set the new offset. Note that SEEK_END requires that the file be opened.
506 // An open may occur by calling the FSize() method via the cache pointer.
507 //
508  if (whence == SEEK_SET) curroffset = fp->setOffset(offset);
509  else if (whence == SEEK_CUR) curroffset = fp->addOffset(offset);
510  else if (whence == SEEK_END)
511  {curroffset = fp->XCio->FSize();
512  if (curroffset < 0) return Fault(fp,static_cast<int>(-curroffset));
513  curroffset = fp->setOffset(curroffset+offset);
514  }
515  else return Fault(fp, EINVAL);
516 
517 // All done
518 //
519  fp->UnLock();
520  return curroffset;
521 }
virtual long long FSize()=0
long long addOffset(long long offs, int updtSz=0)
Definition: XrdPosixFile.hh:69
long long setOffset(long long offs)

References XrdPosixFile::addOffset(), XrdPosixObject::File(), XrdOucCacheIO::FSize(), XrdPosixFile::setOffset(), XrdPosixObject::UnLock(), and XrdPosixFile::XCio.

Referenced by XrdFfsPosix_lseek(), XrdPosix_Fseek(), XrdPosix_Fseeko(), XrdPosix_Ftell(), XrdPosix_Ftello(), and XrdPosix_Lseek().

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

◆ Mkdir()

int XrdPosixXrootd::Mkdir ( const char *  path,
mode_t  mode 
)
static

Mkdir() conforms to POSIX.1-2001 mkdir()

Definition at line 527 of file XrdPosixXrootd.cc.

528 {
531 
532 // Preferentially make the whole path unless told otherwise
533 //
534  flags = (mode & S_ISUID ? XrdCl::MkDirFlags::None
536 
537 // Make sure the admin is OK
538 //
539  if (!admin.isOK()) return -1;
540 
541 // Issue the mkdir
542 //
543  return XrdPosixMap::Result(admin.Xrd.MkDir(admin.Url.GetPathWithParams(),
544  flags,
547  );
548 }
static XrdCl::Access::Mode Mode2Access(mode_t mode)
Definition: XrdPosixMap.cc:130
@ None
Nothing special.
@ MakePath
create the entire directory tree if it doesn't exist

References XrdPosixGlobals::ecMsg, XrdCl::URL::GetPathWithParams(), XrdPosixAdmin::isOK(), XrdCl::MkDirFlags::MakePath, XrdCl::FileSystem::MkDir(), XrdPosixMap::Mode2Access(), XrdCl::MkDirFlags::None, XrdPosixMap::Result(), XrdPosixAdmin::Url, and XrdPosixAdmin::Xrd.

Referenced by XrdPssSys::Mkdir(), XrdFfsPosix_mkdir(), and XrdPosix_Mkdir().

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

◆ myFD()

bool XrdPosixXrootd::myFD ( int  fd)
static

Definition at line 1442 of file XrdPosixXrootd.cc.

1443 {
1444  return XrdPosixObject::Valid(fd);
1445 }
static bool Valid(int fd)

References XrdPosixObject::Valid().

Referenced by fcntl(), fstat(), isXrootdDir(), XrdPosix_Close(), XrdPosix_Fclose(), XrdPosix_Fcntl(), XrdPosix_Fdatasync(), XrdPosix_Fflush(), XrdPosix_Fread(), XrdPosix_Fseek(), XrdPosix_Fseeko(), XrdPosix_Fstat(), XrdPosix_Fsync(), XrdPosix_Ftell(), XrdPosix_Ftello(), XrdPosix_Ftruncate(), XrdPosix_Fwrite(), XrdPosix_Lseek(), XrdPosix_Pread(), XrdPosix_Pwrite(), XrdPosix_Read(), XrdPosix_Readv(), XrdPosix_Write(), and XrdPosix_Writev().

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

◆ Open()

int XrdPosixXrootd::Open ( const char *  path,
int  oflag,
mode_t  mode = 0,
XrdPosixCallBack cbP = 0 
)
static

Definition at line 554 of file XrdPosixXrootd.cc.

556 {
557  return Open(path, oflags, mode, cbP, 0);
558 }
static int Open(const char *path, int oflag, mode_t mode=0, XrdPosixCallBack *cbP=0)

Referenced by main(), XrdPssFile::Open(), XrdPosixConfig::OpenFC(), XrdFfsPosix_open(), XrdPosix_Fopen(), and XrdPosix_Open().

+ Here is the caller graph for this function:

◆ Opendir()

DIR * XrdPosixXrootd::Opendir ( const char *  path)
static

Opendir() conforms to POSIX.1-2001 opendir()

Definition at line 694 of file XrdPosixXrootd.cc.

695 {
696  XrdPosixDir *dP;
697  DIR *dirP;
698  int rc;
699 
700 // Get a new directory object
701 //
702  if (!(dP = new XrdPosixDir(path)))
704  return (DIR*)0;
705  }
706 
707 // Assign a file descriptor to this file
708 //
709  if (!(dP->AssignFD()))
710  {delete dP;
712  return (DIR*)0;
713  }
714 
715 // Open the directory
716 //
717  if ((dirP = dP->Open())) return dirP;
718 
719 // We failed
720 //
721  rc = errno;
722  delete dP;
723  errno = rc; // Restore saved errno
724  return (DIR *)0;
725 }
DIR * Open()
Definition: XrdPosixDir.cc:94
bool AssignFD(bool isStream=false)

References XrdPosixObject::AssignFD(), XrdPosixGlobals::ecMsg, XrdPosixDir::Open(), and XrdOucECMsg::SetErrno().

Referenced by XrdPssDir::Opendir(), XrdFfsPosix_opendir(), and XrdPosix_Opendir().

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

◆ Pread() [1/2]

ssize_t XrdPosixXrootd::Pread ( int  fildes,
void *  buf,
size_t  nbyte,
off_t  offset 
)
static

Pread() conforms to POSIX.1-2001 pread()

Definition at line 731 of file XrdPosixXrootd.cc.

732 {
733  XrdPosixFile *fp;
734  long long offs, bytes;
735  int iosz;
736 
737 // Find the file object
738 //
739  if (!(fp = XrdPosixObject::File(fildes)))
740  return XrdPosixGlobals::ecMsg.SetErrno(EBADF);
741 
742 // Make sure the size is not too large
743 //
744  if (nbyte > (size_t)0x7fffffff)
745  return Fault(fp, EOVERFLOW, "read size too large");
746  else iosz = static_cast<int>(nbyte);
747 
748 // Issue the read
749 //
750  offs = static_cast<long long>(offset);
751  bytes = fp->XCio->Read((char *)buf, offs, (int)iosz);
752  if (bytes < 0) return Fault(fp,-bytes,"*");
753 
754 // All went well
755 //
756  fp->UnLock();
757  return (ssize_t)bytes;
758 }
virtual int Read(char *buff, long long offs, int rlen)=0

References XrdPosixGlobals::ecMsg, XrdPosixObject::File(), XrdOucCacheIO::Read(), XrdOucECMsg::SetErrno(), XrdPosixObject::UnLock(), and XrdPosixFile::XCio.

Referenced by XrdPssFile::Read(), XrdFfsPosix_pread(), and XrdPosix_Pread().

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

◆ Pread() [2/2]

void XrdPosixXrootd::Pread ( int  fildes,
void *  buf,
size_t  nbyte,
off_t  offset,
XrdPosixCallBackIO cbp 
)
static

Definition at line 762 of file XrdPosixXrootd.cc.

764 {
765  XrdPosixFile *fp;
766  long long offs;
767  int iosz;
768 
769 // Find the file object
770 //
771  if (!(fp = XrdPosixObject::File(fildes))) {cbp->Complete(-1); return;}
772 
773 // Make sure the size is not too large
774 //
775  if (nbyte > (size_t)0x7fffffff)
776  {fp->UnLock();
777  fp->ecMsg.SetErrno(EOVERFLOW,0,"read size too large");
778  cbp->Complete(-1);
779  return;
780  }
781 
782 // Prepare for the read
783 //
784  cbp->theFile = fp;
785  fp->Ref(); fp->UnLock();
786  iosz = static_cast<int>(nbyte);
787  offs = static_cast<long long>(offset);
788 
789 // Issue the read
790 //
791  fp->XCio->Read(*cbp, (char *)buf, offs, (int)iosz);
792 }
XrdOucECMsg ecMsg

References XrdPosixCallBackIO::Complete(), XrdPosixObject::ecMsg, XrdPosixObject::File(), XrdOucCacheIO::Read(), XrdPosixObject::Ref(), XrdOucECMsg::SetErrno(), XrdPosixObject::UnLock(), and XrdPosixFile::XCio.

+ Here is the call graph for this function:

◆ Pwrite() [1/2]

ssize_t XrdPosixXrootd::Pwrite ( int  fildes,
const void *  buf,
size_t  nbyte,
off_t  offset 
)
static

Pwrite() conforms to POSIX.1-2001 pwrite()

Definition at line 798 of file XrdPosixXrootd.cc.

799 {
800  XrdPosixFile *fp;
801  long long offs;
802  int iosz, bytes;
803 
804 // Find the file object
805 //
806  if (!(fp = XrdPosixObject::File(fildes))) return -1;
807 
808 // Make sure the size is not too large
809 //
810  if (nbyte > (size_t)0x7fffffff)
811  return Fault(fp,EOVERFLOW,"write size too large");
812  else iosz = static_cast<int>(nbyte);
813 
814 // Issue the write
815 //
816  offs = static_cast<long long>(offset);
817  bytes = fp->XCio->Write((char *)buf, offs, (int)iosz);
818  if (bytes < 0) return Fault(fp,-bytes,"*");
819 
820 // All went well
821 //
822  fp->UpdtSize(offs + iosz);
823  fp->UnLock();
824  return (ssize_t)iosz;
825 }
virtual int Write(char *buff, long long offs, int wlen)=0
void UpdtSize(size_t newsz)

References XrdPosixObject::File(), XrdPosixObject::UnLock(), XrdPosixFile::UpdtSize(), XrdOucCacheIO::Write(), and XrdPosixFile::XCio.

Referenced by XrdPssFile::Write(), XrdFfsPosix_pwrite(), and XrdPosix_Pwrite().

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

◆ Pwrite() [2/2]

void XrdPosixXrootd::Pwrite ( int  fildes,
const void *  buf,
size_t  nbyte,
off_t  offset,
XrdPosixCallBackIO cbp 
)
static

Definition at line 829 of file XrdPosixXrootd.cc.

831 {
832  XrdPosixFile *fp;
833  long long offs;
834  int iosz;
835 
836 // Find the file object
837 //
838  if (!(fp = XrdPosixObject::File(fildes))) {cbp->Complete(-1); return;}
839 
840 // Make sure the size is not too large
841 //
842  if (nbyte > (size_t)0x7fffffff)
843  {fp->UnLock();
844  fp->ecMsg.SetErrno(EOVERFLOW,0,"read size too large");
845  cbp->Complete(-1);
846  return;
847  }
848 
849 // Prepare for the writing
850 //
851  cbp->theFile = fp;
852  fp->Ref(); fp->UnLock();
853  iosz = static_cast<int>(nbyte);
854  offs = static_cast<long long>(offset);
855 
856 // Issue the read
857 //
858  fp->XCio->Write(*cbp, (char *)buf, offs, (int)iosz);
859 }

References XrdPosixCallBackIO::Complete(), XrdPosixObject::ecMsg, XrdPosixObject::File(), XrdPosixObject::Ref(), XrdOucECMsg::SetErrno(), XrdPosixObject::UnLock(), XrdOucCacheIO::Write(), and XrdPosixFile::XCio.

+ Here is the call graph for this function:

◆ QueryChksum()

int XrdPosixXrootd::QueryChksum ( const char *  path,
time_t &  mtime,
char *  buff,
int  blen 
)
static

QueryChksum() is a POSIX extension and returns a file's modification time and its associated checksum value.

Parameters
pathpath associated with the file whose checksum is wanted.
mtimewhere the file's modification time (st_mtime) is placed.
buffpointer to the buffer to hold the checksum value.
blenthe length of the buffer.
Returns
Upon success returns the length of the checksum response placed in buff. Otherwise, -1 is returned and errno appropriately set.

Definition at line 1451 of file XrdPosixXrootd.cc.

1453 {
1455 
1456 // Stat the file first to allow vectoring of the request to the right server
1457 //
1458  if (!admin.Stat(0, &Mtime)) return -1;
1459 
1460 // Now we can get the checksum as we have landed on the right server
1461 //
1462  return admin.Query(XrdCl::QueryCode::Checksum, value, vsize);
1463 }

References XrdCl::QueryCode::Checksum, XrdPosixGlobals::ecMsg, XrdPosixAdmin::Query(), and XrdPosixAdmin::Stat().

Referenced by XrdPssCks::Get().

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

◆ QueryError() [1/2]

int XrdPosixXrootd::QueryError ( std::string &  emsg,
DIR *  dirP,
bool  reset = true 
)
static

Definition at line 1488 of file XrdPosixXrootd.cc.

1489 {
1490  XrdPosixDir *dP;
1491  int fildes = XrdPosixDir::dirNo(dirP);
1492 
1493 // Find the object
1494 //
1495  if (!(dP = XrdPosixObject::Dir(fildes)))
1496  return XrdPosixGlobals::ecMsg.SetErrno(EBADF);
1497 
1498 // Return result
1499 //
1500  return dP->getECMsg()->Get(emsg, reset);
1501 }
int emsg(int rc, char *msg)
int Get(std::string &ecm, bool rst=true)
Definition: XrdOucECMsg.cc:41
XrdOucECMsg * getECMsg()

References XrdPosixObject::Dir(), XrdPosixDir::dirNo(), XrdPosixGlobals::ecMsg, emsg(), XrdOucECMsg::Get(), XrdPosixObject::getECMsg(), and XrdOucECMsg::SetErrno().

+ Here is the call graph for this function:

◆ QueryError() [2/2]

int XrdPosixXrootd::QueryError ( std::string &  emsg,
int  fd = -1,
bool  reset = true 
)
static

QueryError() is a POSIX extension and returns extended information about the last error returned from a call to a POSIX function.

Parameters
emsgReference to a string to hold the retruned message text.
fdThe file descriptor associated with the error. A negative value returns the last error encountered on the calling thread for the last function not releated to a file descritor. dirP Get the error associated with the last directory operation.
resetWhen true (the default) clears the error information.
Returns
The error code and the associated message via parameter emsg. A zero return indicates that no error information is available. A -1 return indicates the call was bad itself because either the fd or dirP was invalid.

Definition at line 1469 of file XrdPosixXrootd.cc.

1470 {
1471  XrdOucECMsg* ecmP;
1472 
1473 // If global wanted then use that one otherwise find the object specific one
1474 //
1475  if (fd < 0) ecmP = &XrdPosixGlobals::ecMsg;
1476  else {XrdPosixFile *fp;
1477  if (!(fp = XrdPosixObject::File(fd))) return -1;
1478  ecmP = fp->getECMsg();
1479  }
1480 
1481 // Return the message information
1482 //
1483  return ecmP->Get(emsg, reset);
1484 }

References XrdPosixGlobals::ecMsg, emsg(), XrdPosixObject::File(), XrdOucECMsg::Get(), and XrdPosixObject::getECMsg().

Referenced by XrdPssSys::Info().

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

◆ QueryOpaque()

long long XrdPosixXrootd::QueryOpaque ( const char *  path,
char *  buff,
int  blen 
)
static

QueryOpaque() is a POSIX extension and returns a file's implementation specific information.

Parameters
pathpath associated with the file whose information is wanted.
buffpointer to the buffer to hold the information.
blenthe length of the buffer.
Returns
Upon success returns the length of the checksum response placed in buff. Otherwise, -1 is returned and errno appropriately set.

Definition at line 1507 of file XrdPosixXrootd.cc.

1508 {
1510 
1511 // Stat the file first to allow vectoring of the request to the right server
1512 //
1513  if (!admin.Stat()) return -1;
1514 
1515 // Now we can get the checksum as we have landed on the right server
1516 //
1517  return admin.Query(XrdCl::QueryCode::OpaqueFile, value, size);
1518 }
@ OpaqueFile
Implementation dependent.

References XrdPosixGlobals::ecMsg, XrdCl::QueryCode::OpaqueFile, XrdPosixAdmin::Query(), and XrdPosixAdmin::Stat().

+ Here is the call graph for this function:

◆ Read()

ssize_t XrdPosixXrootd::Read ( int  fildes,
void *  buf,
size_t  nbyte 
)
static

Read() conforms to POSIX.1-2001 read()

Definition at line 865 of file XrdPosixXrootd.cc.

866 {
867  XrdPosixFile *fp;
868  long long bytes;
869  int iosz;
870 
871 // Find the file object
872 //
873  if (!(fp = XrdPosixObject::File(fildes))) return -1;
874 
875 // Make sure the size is not too large
876 //
877  if (nbyte > (size_t)0x7fffffff) return Fault(fp,EOVERFLOW);
878  else iosz = static_cast<int>(nbyte);
879 
880 // Issue the read
881 //
882  bytes = fp->XCio->Read((char *)buf,fp->Offset(),(int)iosz);
883  if (bytes < 0) return Fault(fp,-bytes);
884 
885 // All went well
886 //
887  fp->addOffset(bytes);
888  fp->UnLock();
889  return (ssize_t)bytes;
890 }
long long Offset()

References XrdPosixFile::addOffset(), XrdPosixObject::File(), XrdPosixFile::Offset(), XrdOucCacheIO::Read(), XrdPosixObject::UnLock(), and XrdPosixFile::XCio.

Referenced by main(), Readv(), XrdFfsPosix_read(), XrdPosix_Fread(), and XrdPosix_Read().

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

◆ Readdir()

struct dirent * XrdPosixXrootd::Readdir ( DIR *  dirp)
static

readdir() conforms to POSIX.1-2001 readdir() and is normally equivalent to readdir64(). The latter is provided for those platforms that require a specific 64-bit interface to directory information, which is now rare.

Definition at line 958 of file XrdPosixXrootd.cc.

959 {
960  dirent64 *dp64;
961  dirent *dp32; // Could be the same as dp64
962 
963  if (!(dp64 = Readdir64(dirp))) return 0;
964 
965  dp32 = (struct dirent *)dp64;
966  if ((char*)dp32->d_name != (char*)dp64->d_name)
967  {dp32->d_ino = dp64->d_ino;
968 #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__GNU__) && !(defined(__FreeBSD_kernel__) && defined(__GLIBC__))
969  dp32->d_off = dp64->d_off;
970 #endif
971 #ifndef __solaris__
972  dp32->d_type = dp64->d_type;
973 #endif
974  dp32->d_reclen = dp64->d_reclen;
975  strcpy(dp32->d_name, dp64->d_name);
976  }
977  return dp32;
978 }
static struct dirent64 * Readdir64(DIR *dirp)

References Readdir64().

Referenced by XrdFfsPosix_readdir(), and XrdPosix_Readdir().

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

◆ Readdir64()

struct dirent64 * XrdPosixXrootd::Readdir64 ( DIR *  dirp)
static

Definition at line 980 of file XrdPosixXrootd.cc.

981 {
982  XrdPosixDir *dP;
983  dirent64 *dentP;
984  int rc, fildes = XrdPosixDir::dirNo(dirp);
985 
986 // Find the object
987 //
988  if (!(dP = XrdPosixObject::Dir(fildes)))
990  return (dirent64*)0;
991  }
992 
993 // Get the next directory entry
994 //
995  if (!(dentP = dP->nextEntry())) rc = dP->Status();
996  else rc = 0;
997 
998 // Return the appropriate result
999 //
1000  dP->UnLock();
1001  if (rc) errno = rc;
1002  return dentP;
1003 }
dirent64 * nextEntry(dirent64 *dp=0)
Definition: XrdPosixDir.cc:48
int Status()
Definition: XrdPosixDir.hh:76

References XrdPosixObject::Dir(), XrdPosixDir::dirNo(), XrdPosixGlobals::ecMsg, XrdPosixDir::nextEntry(), XrdOucECMsg::SetErrno(), XrdPosixDir::Status(), and XrdPosixObject::UnLock().

Referenced by Readdir(), and XrdPosix_Readdir64().

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

◆ Readdir64_r()

int XrdPosixXrootd::Readdir64_r ( DIR *  dirp,
struct dirent64 *  entry,
struct dirent64 **  result 
)
static

Definition at line 1031 of file XrdPosixXrootd.cc.

1033 {
1034  XrdPosixDir *dP;
1035  int rc, fildes = XrdPosixDir::dirNo(dirp);
1036 
1037 // Find the object
1038 //
1039  if (!(dP = XrdPosixObject::Dir(fildes))) return EBADF;
1040 
1041 // Get the next entry
1042 //
1043  if (!(*result = dP->nextEntry(entry))) {rc = dP->Status(); *result = 0;}
1044  else {rc = 0; *result = entry;}
1045 
1046 // Return the appropriate result
1047 //
1048  dP->UnLock();
1049  return rc;
1050 }

References XrdPosixObject::Dir(), XrdPosixDir::dirNo(), XrdPosixDir::nextEntry(), XrdPosixDir::Status(), and XrdPosixObject::UnLock().

Referenced by Readdir_r(), and XrdPosix_Readdir64_r().

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

◆ Readdir_r()

int XrdPosixXrootd::Readdir_r ( DIR *  dirp,
struct dirent *  entry,
struct dirent **  result 
)
static

readdir_r() conforms to POSIX.1-2001 readdir_r() and is normally equivalent to readdir64_r(). The latter is provided for those platforms that require a specific 64-bit interface to directory information, which is now rare.

Definition at line 1009 of file XrdPosixXrootd.cc.

1011 {
1012  dirent64 *dp64 = 0, d64ent;
1013  int rc;
1014 
1015  if ((rc = Readdir64_r(dirp, &d64ent, &dp64)) || !dp64)
1016  {*result = 0; return rc;}
1017 
1018  entry->d_ino = dp64->d_ino;
1019 #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__GNU__) && !(defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1020  entry->d_off = dp64->d_off;
1021 #endif
1022 #ifndef __solaris__
1023  entry->d_type = dp64->d_type;
1024 #endif
1025  entry->d_reclen = dp64->d_reclen;
1026  strcpy(entry->d_name, dp64->d_name);
1027  *result = entry;
1028  return rc;
1029 }
static int Readdir64_r(DIR *dirp, struct dirent64 *entry, struct dirent64 **result)

References Readdir64_r().

Referenced by XrdPssDir::Readdir(), and XrdPosix_Readdir_r().

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

◆ Readv()

ssize_t XrdPosixXrootd::Readv ( int  fildes,
const struct iovec *  iov,
int  iovcnt 
)
static

Readv() conforms to POSIX.1-2001 readv()

Definition at line 896 of file XrdPosixXrootd.cc.

897 {
898  ssize_t bytes, totbytes = 0;
899  int i;
900 
901 // Return the results of the read for each iov segment
902 //
903  for (i = 0; i < iovcnt; i++)
904  {bytes = Read(fildes,(void *)iov[i].iov_base,(size_t)iov[i].iov_len);
905  if (bytes > 0) totbytes += bytes;
906  else if (bytes < 0) return -1;
907  else break;
908  }
909 
910 // All done
911 //
912  return totbytes;
913 }
static ssize_t Read(int fildes, void *buf, size_t nbyte)
Read() conforms to POSIX.1-2001 read()

References Read().

Referenced by XrdPosix_Readv().

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

◆ Rename()

int XrdPosixXrootd::Rename ( const char *  oldpath,
const char *  newpath 
)
static

Rename() conforms to POSIX.1-2001 rename()

Definition at line 1056 of file XrdPosixXrootd.cc.

1057 {
1058  XrdPosixAdmin admin(oldpath,XrdPosixGlobals::ecMsg);
1059  XrdCl::URL newUrl((std::string)newpath);
1060 
1061 // Make sure the admin is OK and the new url is valid
1062 //
1063  if (!admin.isOK() || !newUrl.IsValid())
1064  return XrdPosixGlobals::ecMsg.SetErrno(EINVAL);
1065 
1066 // Issue rename to he cache (it really should just deep-six both files)
1067 //
1069  {LfnPath oldF("rename", oldpath);
1070  LfnPath newF("rename", newpath);
1071  if (!oldF.path || !newF.path) return -1;
1072  XrdPosixGlobals::theCache->Rename(oldF.path, newF.path);
1073  }
1074 
1075 // Issue the rename
1076 //
1078  return EcRename(oldpath, newpath, admin);
1079 
1080  return XrdPosixMap::Result(admin.Xrd.Mv(admin.Url.GetPathWithParams(),
1081  newUrl.GetPathWithParams()),
1082  XrdPosixGlobals::ecMsg, true);
1083 }
virtual int Rename(const char *oldp, const char *newp)
Definition: XrdOucCache.hh:610
XrdOucCache * theCache

References XrdPosixGlobals::ecMsg, XrdCl::URL::GetPathWithParams(), XrdPosixAdmin::isOK(), XrdCl::URL::IsValid(), XrdCl::FileSystem::Mv(), XrdOucCache::Rename(), XrdPosixMap::Result(), XrdOucECMsg::SetErrno(), XrdPosixGlobals::theCache, XrdPosixAdmin::Url, XrdPosixGlobals::usingEC, and XrdPosixAdmin::Xrd.

Referenced by XrdPssSys::Rename(), XrdFfsPosix_rename(), and XrdPosix_Rename().

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

◆ Rewinddir()

void XrdPosixXrootd::Rewinddir ( DIR *  dirp)
static

Rewinddir() conforms to POSIX.1-2001 rewinddir()

Definition at line 1089 of file XrdPosixXrootd.cc.

1090 {
1091  XrdPosixDir *dP;
1092  int fildes = XrdPosixDir::dirNo(dirp);
1093 
1094 // Find the object and rewind it
1095 //
1096  if ((dP = XrdPosixObject::Dir(fildes)))
1097  {dP->rewind();
1098  dP->UnLock();
1099  }
1100 }
void rewind()
Definition: XrdPosixDir.hh:72

References XrdPosixObject::Dir(), XrdPosixDir::dirNo(), XrdPosixDir::rewind(), and XrdPosixObject::UnLock().

Referenced by XrdPosix_Rewinddir().

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

◆ Rmdir()

int XrdPosixXrootd::Rmdir ( const char *  path)
static

Rmdir() conforms to POSIX.1-2001 rmdir()

Definition at line 1106 of file XrdPosixXrootd.cc.

1107 {
1109 
1110 // Make sure the admin is OK
1111 //
1112  if (!admin.isOK()) return -1;
1113 
1114 // Remove directory from the cache first
1115 //
1117  {LfnPath rmd("rmdir", path);
1118  if (!rmd.path) return -1;
1119  XrdPosixGlobals::theCache->Rmdir(rmd.path);
1120  }
1121 
1122 // Issue the rmdir
1123 //
1124  return XrdPosixMap::Result(admin.Xrd.RmDir(admin.Url.GetPathWithParams()),
1125  XrdPosixGlobals::ecMsg, true);
1126 }
virtual int Rmdir(const char *dirp)
Definition: XrdOucCache.hh:622

References XrdPosixGlobals::ecMsg, XrdCl::URL::GetPathWithParams(), XrdPosixAdmin::isOK(), XrdPosixMap::Result(), XrdOucCache::Rmdir(), XrdCl::FileSystem::RmDir(), XrdPosixGlobals::theCache, XrdPosixAdmin::Url, and XrdPosixAdmin::Xrd.

Referenced by XrdPssSys::Remdir(), XrdFfsPosix_rmdir(), and XrdPosix_Rmdir().

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

◆ Seekdir()

void XrdPosixXrootd::Seekdir ( DIR *  dirp,
long  loc 
)
static

Seekdir() conforms to POSIX.1-2001 seekdir()

Definition at line 1132 of file XrdPosixXrootd.cc.

1133 {
1134  XrdPosixDir *dP;
1135  int fildes = XrdPosixDir::dirNo(dirp);
1136 
1137 // Find the object
1138 //
1139  if (!(dP = XrdPosixObject::Dir(fildes))) return;
1140 
1141 // Sets the current directory position
1142 //
1143  if (dP->Unread() && !(dP->Open()))
1144  {if (loc >= dP->getEntries()) loc = dP->getEntries();
1145  else if (loc < 0) loc = 0;
1146  dP->setOffset(loc);
1147  }
1148  dP->UnLock();
1149 }
bool Unread()
Definition: XrdPosixDir.hh:78
void setOffset(long offset)
Definition: XrdPosixDir.hh:66
long getEntries()
Definition: XrdPosixDir.hh:62

References XrdPosixObject::Dir(), XrdPosixDir::dirNo(), XrdPosixDir::getEntries(), XrdPosixDir::Open(), XrdPosixDir::setOffset(), XrdPosixObject::UnLock(), and XrdPosixDir::Unread().

Referenced by XrdPosix_Seekdir().

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

◆ Stat()

int XrdPosixXrootd::Stat ( const char *  path,
struct stat buf 
)
static

Stat() conforms to POSIX.1-2001 stat()

Definition at line 1155 of file XrdPosixXrootd.cc.

1156 {
1158 
1159 // Make sure the admin is OK
1160 //
1161  if (!admin.isOK()) return -1;
1162 
1163 // Initialize the stat buffer
1164 //
1166 
1167 // Check if we can get the stat informatation from the cache
1168 //
1170  {LfnPath statX("stat", path, false);
1171  if (!statX.path) return -1;
1172  int rc = XrdPosixGlobals::theCache->Stat(statX.path, *buf);
1173  if (!rc) return 0;
1174  if (rc < 0) {errno = -rc; return -1;} // does the cache set this???
1175  }
1176 
1177 // Issue the stat and verify that all went well
1178 //
1180  return EcStat(path, buf, admin);
1181 
1182  if (!admin.Stat(*buf)) return -1;
1183  return 0;
1184 }
virtual int Stat(const char *url, struct stat &sbuff)
Definition: XrdOucCache.hh:638

References XrdPosixGlobals::ecMsg, XrdPosixConfig::initStat(), XrdPosixAdmin::isOK(), XrdOucCache::Stat(), XrdPosixAdmin::Stat(), XrdPosixGlobals::theCache, and XrdPosixGlobals::usingEC.

Referenced by XrdPssFile::Fstat(), main(), XrdPssSys::Stat(), XrdFfsPosix_stat(), XrdPosix_Lstat(), and XrdPosix_Stat().

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

◆ Statfs()

int XrdPosixXrootd::Statfs ( const char *  path,
struct statfs buf 
)
static

Statfs() generally conforms to the platform-specific definition of statfs(). There is no specific POSIX specification for this call.

Definition at line 1190 of file XrdPosixXrootd.cc.

1191 {
1192  struct statvfs myVfs;
1193  int rc;
1194 
1195 // Issue a statvfs() call and transcribe the results
1196 //
1197  if ((rc = Statvfs(path, &myVfs))) return rc;
1198 
1199 // The vfs structure and fs structures should be size compatible (not really)
1200 //
1201  memset(buf, 0, sizeof(struct statfs));
1202  buf->f_bsize = myVfs.f_bsize;
1203  buf->f_blocks = myVfs.f_blocks;
1204  buf->f_bfree = myVfs.f_bfree;
1205  buf->f_files = myVfs.f_files;
1206  buf->f_ffree = myVfs.f_ffree;
1207 #if defined(__APPLE__) || defined(__FreeBSD__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1208  buf->f_iosize = myVfs.f_frsize;
1209 #else
1210  buf->f_frsize = myVfs.f_frsize;
1211 #endif
1212 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1213  buf->f_bavail = myVfs.f_bavail;
1214 #endif
1215 #if defined(__linux__) || defined(__GNU__)
1216  buf->f_namelen = myVfs.f_namemax;
1217 #elif defined(__FreeBSD__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1218  buf->f_namemax = myVfs.f_namemax;
1219 #endif
1220  return 0;
1221 }
int statvfs(const char *path, struct statvfs *buf)
int statfs(const char *path, struct statfs *buf)
static int Statvfs(const char *path, struct statvfs *buf)
Statvfs() conforms to POSIX.1-2001 statvfs()

References statfs(), statvfs(), and Statvfs().

Referenced by XrdPosix_Statfs().

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

◆ Statvfs()

int XrdPosixXrootd::Statvfs ( const char *  path,
struct statvfs buf 
)
static

Statvfs() conforms to POSIX.1-2001 statvfs()

Definition at line 1227 of file XrdPosixXrootd.cc.

1228 {
1229  static const int szVFS = sizeof(buf->f_bfree);
1230  static const long long max32 = 0x7fffffffLL;
1231 
1233  XrdCl::StatInfoVFS *vfsStat;
1234 
1235  long long rwFree, ssFree, rwBlks;
1236  int rwNum, ssNum, rwUtil, ssUtil;
1237 
1238 // Make sure we connected
1239 //
1240  if (!admin.isOK()) return -1;
1241 
1242 // Issue the statfvs call
1243 //
1244  if (XrdPosixMap::Result(admin.Xrd.StatVFS(admin.Url.GetPathWithParams(),
1245  vfsStat),
1246  XrdPosixGlobals::ecMsg) < 0) return -1;
1247 
1248 // Extract out the information
1249 //
1250  rwNum = static_cast<int>(vfsStat->GetNodesRW());
1251  rwFree = (long long)vfsStat->GetFreeRW();
1252  rwUtil = static_cast<int>(vfsStat->GetUtilizationRW());
1253  ssNum = static_cast<int>(vfsStat->GetNodesStaging());
1254  ssFree = (long long)vfsStat->GetFreeStaging();
1255  ssUtil = static_cast<int>(vfsStat->GetUtilizationStaging());
1256  delete vfsStat;
1257 
1258 // Calculate number of blocks
1259 //
1260  if (rwUtil == 0) rwBlks = rwFree;
1261  else if (rwUtil >= 100) rwBlks = 0;
1262  else rwBlks = rwFree * (100 / (100 - rwUtil));
1263  if (ssUtil == 0) rwBlks += ssFree;
1264  else if (ssUtil < 100) rwBlks += ssFree * (100 / (100 - ssUtil));
1265 
1266 // Scale units to what will fit here (we can have a 32-bit or 64-bit struct)
1267 //
1268  if (szVFS < 8)
1269  {if (rwBlks > max32) rwBlks = max32;
1270  if (rwFree > max32) rwFree = max32;
1271  if (ssFree > max32) ssFree = max32;
1272  }
1273 
1274 // Return what little we can
1275 //
1276  memset(buf, 0, sizeof(struct statvfs));
1277  buf->f_bsize = 1024*1024;
1278  buf->f_frsize = 1024*1024;
1279  buf->f_blocks = static_cast<fsblkcnt_t>(rwBlks);
1280  buf->f_bfree = static_cast<fsblkcnt_t>(rwFree + ssFree);
1281  buf->f_bavail = static_cast<fsblkcnt_t>(rwFree);
1282  buf->f_ffree = rwNum + ssNum;
1283  buf->f_favail = rwNum;
1284  buf->f_namemax = 255; // The best we are going to do here
1285  buf->f_flag = (rwNum == 0 ? ST_RDONLY|ST_NOSUID : ST_NOSUID);
1286  return 0;
1287 }
uint64_t GetFreeRW() const
Get size of the largest contiguous area of free r/w space (in MB)
uint64_t GetNodesStaging() const
Get number of nodes that can provide staging space.
uint8_t GetUtilizationStaging() const
Get percentage of the partition utilization represented by FreeStaging.
uint64_t GetFreeStaging() const
Get size of the largest contiguous area of free staging space (in MB)
uint8_t GetUtilizationRW() const
Get percentage of the partition utilization represented by FreeRW.
uint64_t GetNodesRW() const
Get number of nodes that can provide read/write space.

References XrdPosixGlobals::ecMsg, XrdCl::StatInfoVFS::GetFreeRW(), XrdCl::StatInfoVFS::GetFreeStaging(), XrdCl::StatInfoVFS::GetNodesRW(), XrdCl::StatInfoVFS::GetNodesStaging(), XrdCl::URL::GetPathWithParams(), XrdCl::StatInfoVFS::GetUtilizationRW(), XrdCl::StatInfoVFS::GetUtilizationStaging(), XrdPosixAdmin::isOK(), XrdPosixMap::Result(), statvfs(), XrdCl::FileSystem::StatVFS(), XrdPosixAdmin::Url, and XrdPosixAdmin::Xrd.

Referenced by Statfs(), and XrdPosix_Statvfs().

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

◆ Telldir()

long XrdPosixXrootd::Telldir ( DIR *  dirp)
static

Telldir() conforms to POSIX.1-2001 telldir()

Definition at line 1293 of file XrdPosixXrootd.cc.

1294 {
1295  XrdPosixDir *dP;
1296  long pos;
1297  int fildes = XrdPosixDir::dirNo(dirp);
1298 
1299 // Find the object
1300 //
1301  if (!(dP = XrdPosixObject::Dir(fildes)))
1302  return XrdPosixGlobals::ecMsg.SetErrno(EBADF,0);
1303 
1304 // Tell the current directory location
1305 //
1306  pos = dP->getOffset();
1307  dP->UnLock();
1308  return pos;
1309 }
long getOffset()
Definition: XrdPosixDir.hh:64

References XrdPosixObject::Dir(), XrdPosixDir::dirNo(), XrdPosixGlobals::ecMsg, XrdPosixDir::getOffset(), XrdOucECMsg::SetErrno(), and XrdPosixObject::UnLock().

Referenced by XrdPosix_Telldir().

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

◆ Truncate()

int XrdPosixXrootd::Truncate ( const char *  path,
off_t  offset 
)
static

Telldir() conforms to POSIX.1-2001 telldir()

Definition at line 1315 of file XrdPosixXrootd.cc.

1316 {
1318  uint64_t tSize = static_cast<uint64_t>(Size);
1319 
1320 // Make sure the admin is OK
1321 //
1322  if (!admin.isOK()) return -1;
1323 
1324 // Truncate in the cache first
1325 //
1327  {LfnPath trunc("truncate", path);
1328  if (!trunc.path) return -1;
1329  XrdPosixGlobals::theCache->Truncate(trunc.path, tSize);
1330  }
1331 
1332 // Issue the truncate to the origin
1333 //
1334  std::string urlp = admin.Url.GetPathWithParams();
1335  return XrdPosixMap::Result(admin.Xrd.Truncate(urlp,tSize),
1336  XrdPosixGlobals::ecMsg,true);
1337 }
virtual int Truncate(const char *path, off_t size)
Definition: XrdOucCache.hh:651

References XrdPosixGlobals::ecMsg, XrdCl::URL::GetPathWithParams(), XrdPosixAdmin::isOK(), XrdPosixMap::Result(), XrdPosixGlobals::theCache, XrdOucCache::Truncate(), XrdCl::FileSystem::Truncate(), XrdPosixAdmin::Url, and XrdPosixAdmin::Xrd.

Referenced by XrdPssSys::Truncate(), XrdFfsPosix_truncate(), and XrdPosix_Truncate().

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

◆ Unlink()

int XrdPosixXrootd::Unlink ( const char *  path)
static

Unlink() conforms to POSIX.1-2001 unlink()

Definition at line 1343 of file XrdPosixXrootd.cc.

1344 {
1346 
1347 // Make sure the admin is OK
1348 //
1349  if (!admin.isOK()) return -1;
1350 
1351 // Unlink the cache first
1352 //
1354  {LfnPath remf("unlink", path);
1355  if (!remf.path) return -1;
1356  XrdPosixGlobals::theCache->Unlink(remf.path);
1357  }
1358 
1359 // Issue the UnLink
1360 //
1362  return EcUnlink(path, admin);
1363 
1364  return XrdPosixMap::Result(admin.Xrd.Rm(admin.Url.GetPathWithParams()),
1365  XrdPosixGlobals::ecMsg, true);
1366 }
virtual int Unlink(const char *path)
Definition: XrdOucCache.hh:663

References XrdPosixGlobals::ecMsg, XrdCl::URL::GetPathWithParams(), XrdPosixAdmin::isOK(), XrdPosixMap::Result(), XrdCl::FileSystem::Rm(), XrdPosixGlobals::theCache, XrdOucCache::Unlink(), XrdPosixAdmin::Url, XrdPosixGlobals::usingEC, and XrdPosixAdmin::Xrd.

Referenced by XrdPssSys::Unlink(), XrdFfsPosix_unlink(), and XrdPosix_Unlink().

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

◆ VRead() [1/2]

ssize_t XrdPosixXrootd::VRead ( int  fildes,
const XrdOucIOVec readV,
int  n 
)
static

Definition at line 919 of file XrdPosixXrootd.cc.

920 {
921  XrdPosixFile *fp;
922  ssize_t bytes;
923 
924 // Find the file object
925 //
926  if (!(fp = XrdPosixObject::File(fildes))) return -1;
927 
928 // Issue the read
929 //
930  if ((bytes = fp->XCio->ReadV(readV, n)) < 0) return Fault(fp,-bytes);
931 
932 // Return bytes read
933 //
934  fp->UnLock();
935  return bytes;
936 }
virtual int ReadV(const XrdOucIOVec *readV, int rnum)
Definition: XrdOucCache.cc:86

References XrdPosixObject::File(), XrdOucCacheIO::ReadV(), XrdPosixObject::UnLock(), and XrdPosixFile::XCio.

+ Here is the call graph for this function:

◆ VRead() [2/2]

void XrdPosixXrootd::VRead ( int  fildes,
const XrdOucIOVec readV,
int  n,
XrdPosixCallBackIO cbp 
)
static

VRead() is a POSIX extension and allows one to read multiple chunks of a file in one operation.

Parameters
fildesfile descriptor of a file opened for reading.
readVthe read vector of offset/length/buffer triplets. Data at each offset of the specifiued length is placed in buffer.
nthe number of elements in the readV vector.
cbppointer to the callback object for async execution.

Definition at line 940 of file XrdPosixXrootd.cc.

942 {
943  XrdPosixFile *fp;
944 
945 // Find the file object and issue read
946 //
947  if ((fp = XrdPosixObject::File(fildes)))
948  {cbp->theFile = fp;
949  fp->Ref(); fp->UnLock();
950  fp->XCio->ReadV(*cbp, readV, n);
951  } else cbp->Complete(-1);
952 }

References XrdPosixCallBackIO::Complete(), XrdPosixObject::File(), XrdOucCacheIO::ReadV(), XrdPosixObject::Ref(), XrdPosixObject::UnLock(), and XrdPosixFile::XCio.

Referenced by XrdPssFile::ReadV().

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

◆ Write()

ssize_t XrdPosixXrootd::Write ( int  fildes,
const void *  buf,
size_t  nbyte 
)
static

Write() conforms to POSIX.1-2001 write()

Definition at line 1372 of file XrdPosixXrootd.cc.

1373 {
1374  XrdPosixFile *fp;
1375  int iosz, bytes;
1376 
1377 // Find the file object
1378 //
1379  if (!(fp = XrdPosixObject::File(fildes))) return -1;
1380 
1381 // Make sure the size is not too large
1382 //
1383  if (nbyte > (size_t)0x7fffffff) return Fault(fp,EOVERFLOW);
1384  else iosz = static_cast<int>(nbyte);
1385 
1386 // Issue the write
1387 //
1388  bytes = fp->XCio->Write((char *)buf,fp->Offset(),(int)iosz);
1389  if (bytes < 0) return Fault(fp,-bytes);
1390 
1391 // All went well
1392 //
1393  fp->addOffset(iosz, 1);
1394  fp->UnLock();
1395  return (ssize_t)iosz;
1396 }

References XrdPosixFile::addOffset(), XrdPosixObject::File(), XrdPosixFile::Offset(), XrdPosixObject::UnLock(), XrdOucCacheIO::Write(), and XrdPosixFile::XCio.

Referenced by Writev(), XrdFfsPosix_write(), XrdPosix_Fwrite(), and XrdPosix_Write().

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

◆ Writev()

ssize_t XrdPosixXrootd::Writev ( int  fildes,
const struct iovec *  iov,
int  iovcnt 
)
static

Writev() conforms to POSIX.1-2001 writev()

Definition at line 1402 of file XrdPosixXrootd.cc.

1403 {
1404  ssize_t totbytes = 0;
1405  int i;
1406 
1407 // Return the results of the write for each iov segment
1408 //
1409  for (i = 0; i < iovcnt; i++)
1410  {if (!Write(fildes,(void *)iov[i].iov_base,(size_t)iov[i].iov_len))
1411  return -1;
1412  totbytes += iov[i].iov_len;
1413  }
1414 
1415 // All done
1416 //
1417  return totbytes;
1418 }
static ssize_t Write(int fildes, const void *buf, size_t nbyte)
Write() conforms to POSIX.1-2001 write()

References Write().

Referenced by XrdPosix_Writev().

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

Friends And Related Function Documentation

◆ XrdPosixConfig

friend class XrdPosixConfig
friend

Definition at line 66 of file XrdPosixXrootd.hh.

◆ XrdPosixExtra

friend class XrdPosixExtra
friend

Definition at line 67 of file XrdPosixXrootd.hh.

Member Data Documentation

◆ isStream

const int XrdPosixXrootd::isStream = 0x40000000
static

Open() conforms to POSIX.1-2001 open() when extensions are not used.

Extensions:

Parameters
cbPPointer to a callback object. When specified, the open is performed in the background and the Comp[lete() is called when the Open() completes. See XrdPosixCallBack.hh for complete details.
Returns
-1 is always returned when cbP is specified. If the Open() was actually scheduled then errno will contain EINPROGRESS. Otherwise, the Open() immediately failed and errno contains the reason.

Definition at line 166 of file XrdPosixXrootd.hh.

Referenced by XrdPosix_Fopen().


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