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 StatRet (DIR *dirp, struct stat *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 180 of file XrdPosixXrootd.cc.

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

230 {
231 
232 // Shutdown processing
233 //
235  initDone = 0;
236 }
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 242 of file XrdPosixXrootd.cc.

243 {
245  mode_t stMode;
246  bool aOK = true;
247 
248 // Issue the stat and verify that all went well
249 //
250  if (!admin.Stat(&stMode)) return -1;
251 
252 // Translate the mode bits
253 //
254  if (amode & R_OK && !(stMode & S_IRUSR)) aOK = 0;
255  if (amode & W_OK && !(stMode & S_IWUSR)) aOK = 0;
256  if (amode & X_OK && !(stMode & S_IXUSR)) aOK = 0;
257 
258 // All done
259 //
260  if (aOK) return 0;
261  return XrdPosixGlobals::ecMsg.SetErrno(EACCES);
262 }
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 268 of file XrdPosixXrootd.cc.

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

312 {
313  XrdPosixDir *dP;
314  int fildes = XrdPosixDir::dirNo(dirp);
315 
316 // Get the directory object
317 //
318  if (!(dP = XrdPosixObject::ReleaseDir(fildes)))
319  return XrdPosixGlobals::ecMsg.SetErrno(EBADF);
320 
321 // Deallocate the directory
322 //
323  delete dP;
324  return 0;
325 }
static int dirNo(DIR *dirP)
Definition: XrdPosixDir.hh:61
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 331 of file XrdPosixXrootd.cc.

332 {
333  XrdPosixFile *fp;
334  int uPort;
335 
336 // Find the file object
337 //
338  if (!(fp = XrdPosixObject::File(FD))) return 0;
339 
340 // Make sure url is valid
341 //
342  if (!(fp->clFile.IsOpen()))
343  {fp->UnLock(); return -ENOTCONN;}
344 
345 // Make sure we can fit result in the buffer
346 //
347  std::string dataServer;
348  fp->clFile.GetProperty( "DataServer", dataServer );
349  XrdCl::URL dataServerUrl = dataServer;
350 
351  if (dataServer.size() >= (uint32_t)Blen)
352  {fp->UnLock(); return -ENAMETOOLONG;}
353 
354 // Copy the data server location
355 //
356  strcpy(Buff, dataServer.c_str());
357 
358 // Get the port and return it
359 //
360  uPort = dataServerUrl.GetPort();
361  fp->UnLock();
362  return uPort;
363 }
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:188
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 369 of file XrdPosixXrootd.cc.

370 {
371  XrdPosixFile *fp;
372  int rc;
373 
374 // Find the file object
375 //
376  if (!(fp = XrdPosixObject::File(fildes))) return -1;
377 
378 // First initialize the stat buffer
379 //
381 
382 // Check if we can get the stat information from the cache.
383 //
384  rc = fp->XCio->Fstat(*buf);
385  if (rc <= 0)
386  {fp->UnLock();
387  if (!rc) return 0;
388  errno = -rc; //???
389  return -1;
390  }
391 
392 // At this point we can call the file's Fstat() and if the file is not open
393 // it will be opened.
394 //
395  rc = fp->Fstat(*buf);
396  fp->UnLock();
397  if (rc < 0) {errno = -rc; rc = -1;}
398  return rc;
399 }
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 405 of file XrdPosixXrootd.cc.

406 {
407  XrdPosixFile *fp;
408  int rc;
409 
410 // Find the file object
411 //
412  if (!(fp = XrdPosixObject::File(fildes))) return -1;
413 
414 // Do the sync
415 //
416  if ((rc = fp->XCio->Sync()) < 0) return Fault(fp, -rc);
417  fp->UnLock();
418  return 0;
419 }
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 423 of file XrdPosixXrootd.cc.

424 {
425  XrdPosixFile *fp;
426 
427 // Find the file object and do the sync
428 //
429  if ((fp = XrdPosixObject::File(fildes)))
430  {cbp->theFile = fp;
431  fp->Ref(); fp->UnLock();
432  fp->XCio->Sync(*cbp);
433  } else cbp->Complete(-1);
434 }
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 440 of file XrdPosixXrootd.cc.

441 {
442  XrdPosixFile *fp;
443  int rc;
444 
445 // Find the file object
446 //
447  if (!(fp = XrdPosixObject::File(fildes))) return -1;
448 
449 // Do the trunc
450 //
451  if ((rc = fp->XCio->Trunc(offset)) < 0) return Fault(fp, -rc);
452  fp->UnLock();
453  return 0;
454 }
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 464 of file XrdPosixXrootd.cc.

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

1460 {
1461  XrdPosixDir *dP;
1462  int fildes;
1463 
1464  if (!dirp) return false;
1465  fildes = XrdPosixDir::dirNo(dirp);
1466 
1467  if (!myFD(fildes) || !(dP = XrdPosixObject::Dir(fildes))) return false;
1468 
1469  dP->UnLock();
1470  return true;
1471 }
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 497 of file XrdPosixXrootd.cc.

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

529 {
532 
533 // Preferentially make the whole path unless told otherwise
534 //
535  flags = (mode & S_ISUID ? XrdCl::MkDirFlags::None
537 
538 // Make sure the admin is OK
539 //
540  if (!admin.isOK()) return -1;
541 
542 // Issue the mkdir
543 //
544  return XrdPosixMap::Result(admin.Xrd.MkDir(admin.Url.GetPathWithParams(),
545  flags,
548  );
549 }
static XrdCl::Access::Mode Mode2Access(mode_t mode)
Definition: XrdPosixMap.cc:165
@ 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 1477 of file XrdPosixXrootd.cc.

1478 {
1479  return XrdPosixObject::Valid(fd);
1480 }
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 555 of file XrdPosixXrootd.cc.

557 {
558  return Open(path, oflags, mode, cbP, 0);
559 }
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 705 of file XrdPosixXrootd.cc.

706 {
707  XrdPosixDir *dP;
708  DIR *dirP;
709  int rc;
710 
711 // Get a new directory object
712 //
713  if (!(dP = new XrdPosixDir(path)))
715  return (DIR*)0;
716  }
717 
718 // Assign a file descriptor to this file
719 //
720  if (!(dP->AssignFD()))
721  {delete dP;
723  return (DIR*)0;
724  }
725 
726 // Open the directory
727 //
728  if ((dirP = dP->Open())) return dirP;
729 
730 // We failed
731 //
732  rc = errno;
733  delete dP;
734  errno = rc; // Restore saved errno
735  return (DIR *)0;
736 }
DIR * Open()
Definition: XrdPosixDir.cc:111
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 742 of file XrdPosixXrootd.cc.

743 {
744  XrdPosixFile *fp;
745  long long offs, bytes;
746  int iosz;
747 
748 // Find the file object
749 //
750  if (!(fp = XrdPosixObject::File(fildes)))
751  return XrdPosixGlobals::ecMsg.SetErrno(EBADF);
752 
753 // Make sure the size is not too large
754 //
755  if (nbyte > (size_t)0x7fffffff)
756  return Fault(fp, EOVERFLOW, "read size too large");
757  else iosz = static_cast<int>(nbyte);
758 
759 // Issue the read
760 //
761  offs = static_cast<long long>(offset);
762  bytes = fp->XCio->Read((char *)buf, offs, (int)iosz);
763  if (bytes < 0) return Fault(fp,-bytes,"*");
764 
765 // All went well
766 //
767  fp->UnLock();
768  return (ssize_t)bytes;
769 }
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 773 of file XrdPosixXrootd.cc.

775 {
776  XrdPosixFile *fp;
777  long long offs;
778  int iosz;
779 
780 // Find the file object
781 //
782  if (!(fp = XrdPosixObject::File(fildes))) {cbp->Complete(-1); return;}
783 
784 // Make sure the size is not too large
785 //
786  if (nbyte > (size_t)0x7fffffff)
787  {fp->UnLock();
788  fp->ecMsg.SetErrno(EOVERFLOW,0,"read size too large");
789  cbp->Complete(-1);
790  return;
791  }
792 
793 // Prepare for the read
794 //
795  cbp->theFile = fp;
796  fp->Ref(); fp->UnLock();
797  iosz = static_cast<int>(nbyte);
798  offs = static_cast<long long>(offset);
799 
800 // Issue the read
801 //
802  fp->XCio->Read(*cbp, (char *)buf, offs, (int)iosz);
803 }
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 809 of file XrdPosixXrootd.cc.

810 {
811  XrdPosixFile *fp;
812  long long offs;
813  int iosz, bytes;
814 
815 // Find the file object
816 //
817  if (!(fp = XrdPosixObject::File(fildes))) return -1;
818 
819 // Make sure the size is not too large
820 //
821  if (nbyte > (size_t)0x7fffffff)
822  return Fault(fp,EOVERFLOW,"write size too large");
823  else iosz = static_cast<int>(nbyte);
824 
825 // Issue the write
826 //
827  offs = static_cast<long long>(offset);
828  bytes = fp->XCio->Write((char *)buf, offs, (int)iosz);
829  if (bytes < 0) return Fault(fp,-bytes,"*");
830 
831 // All went well
832 //
833  fp->UpdtSize(offs + iosz);
834  fp->UnLock();
835  return (ssize_t)iosz;
836 }
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 840 of file XrdPosixXrootd.cc.

842 {
843  XrdPosixFile *fp;
844  long long offs;
845  int iosz;
846 
847 // Find the file object
848 //
849  if (!(fp = XrdPosixObject::File(fildes))) {cbp->Complete(-1); return;}
850 
851 // Make sure the size is not too large
852 //
853  if (nbyte > (size_t)0x7fffffff)
854  {fp->UnLock();
855  fp->ecMsg.SetErrno(EOVERFLOW,0,"read size too large");
856  cbp->Complete(-1);
857  return;
858  }
859 
860 // Prepare for the writing
861 //
862  cbp->theFile = fp;
863  fp->Ref(); fp->UnLock();
864  iosz = static_cast<int>(nbyte);
865  offs = static_cast<long long>(offset);
866 
867 // Issue the read
868 //
869  fp->XCio->Write(*cbp, (char *)buf, offs, (int)iosz);
870 }

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 1486 of file XrdPosixXrootd.cc.

1488 {
1490 
1491 // Stat the file first to allow vectoring of the request to the right server
1492 //
1493  if (!admin.Stat(0, &Mtime)) return -1;
1494 
1495 // Now we can get the checksum as we have landed on the right server
1496 //
1497  return admin.Query(XrdCl::QueryCode::Checksum, value, vsize);
1498 }

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 1523 of file XrdPosixXrootd.cc.

1524 {
1525  XrdPosixDir *dP;
1526  int fildes = XrdPosixDir::dirNo(dirP);
1527 
1528 // Find the object
1529 //
1530  if (!(dP = XrdPosixObject::Dir(fildes)))
1531  return XrdPosixGlobals::ecMsg.SetErrno(EBADF);
1532 
1533 // Return result
1534 //
1535  return dP->getECMsg()->Get(emsg, reset);
1536 }
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 1504 of file XrdPosixXrootd.cc.

1505 {
1506  XrdOucECMsg* ecmP;
1507 
1508 // If global wanted then use that one otherwise find the object specific one
1509 //
1510  if (fd < 0) ecmP = &XrdPosixGlobals::ecMsg;
1511  else {XrdPosixFile *fp;
1512  if (!(fp = XrdPosixObject::File(fd))) return -1;
1513  ecmP = fp->getECMsg();
1514  }
1515 
1516 // Return the message information
1517 //
1518  return ecmP->Get(emsg, reset);
1519 }

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 1542 of file XrdPosixXrootd.cc.

1543 {
1545 
1546 // Stat the file first to allow vectoring of the request to the right server
1547 //
1548  if (!admin.Stat()) return -1;
1549 
1550 // Now we can get the checksum as we have landed on the right server
1551 //
1552  return admin.Query(XrdCl::QueryCode::OpaqueFile, value, size);
1553 }
@ 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 876 of file XrdPosixXrootd.cc.

877 {
878  XrdPosixFile *fp;
879  long long bytes;
880  int iosz;
881 
882 // Find the file object
883 //
884  if (!(fp = XrdPosixObject::File(fildes))) return -1;
885 
886 // Make sure the size is not too large
887 //
888  if (nbyte > (size_t)0x7fffffff) return Fault(fp,EOVERFLOW);
889  else iosz = static_cast<int>(nbyte);
890 
891 // Issue the read
892 //
893  bytes = fp->XCio->Read((char *)buf,fp->Offset(),(int)iosz);
894  if (bytes < 0) return Fault(fp,-bytes);
895 
896 // All went well
897 //
898  fp->addOffset(bytes);
899  fp->UnLock();
900  return (ssize_t)bytes;
901 }
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 969 of file XrdPosixXrootd.cc.

970 {
971  dirent64 *dp64;
972  dirent *dp32; // Could be the same as dp64
973 
974  if (!(dp64 = Readdir64(dirp))) return 0;
975 
976  dp32 = (struct dirent *)dp64;
977  if ((char*)dp32->d_name != (char*)dp64->d_name)
978  {dp32->d_ino = dp64->d_ino;
979 #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__GNU__) && !(defined(__FreeBSD_kernel__) && defined(__GLIBC__))
980  dp32->d_off = dp64->d_off;
981 #endif
982 #ifndef __solaris__
983  dp32->d_type = dp64->d_type;
984 #endif
985  dp32->d_reclen = dp64->d_reclen;
986  strcpy(dp32->d_name, dp64->d_name);
987  }
988  return dp32;
989 }
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 991 of file XrdPosixXrootd.cc.

992 {
993  XrdPosixDir *dP;
994  dirent64 *dentP;
995  int rc, fildes = XrdPosixDir::dirNo(dirp);
996 
997 // Find the object
998 //
999  if (!(dP = XrdPosixObject::Dir(fildes)))
1001  return (dirent64*)0;
1002  }
1003 
1004 // Get the next directory entry
1005 //
1006  if (!(dentP = dP->nextEntry())) rc = dP->Status();
1007  else rc = 0;
1008 
1009 // Return the appropriate result
1010 //
1011  dP->UnLock();
1012  if (rc) errno = rc;
1013  return dentP;
1014 }
dirent64 * nextEntry(dirent64 *dp=0)
Definition: XrdPosixDir.cc:48
int Status()
Definition: XrdPosixDir.hh:82

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 1042 of file XrdPosixXrootd.cc.

1044 {
1045  XrdPosixDir *dP;
1046  int rc, fildes = XrdPosixDir::dirNo(dirp);
1047 
1048 // Find the object
1049 //
1050  if (!(dP = XrdPosixObject::Dir(fildes))) return EBADF;
1051 
1052 // Get the next entry
1053 //
1054  if (!(*result = dP->nextEntry(entry))) {rc = dP->Status(); *result = 0;}
1055  else {rc = 0; *result = entry;}
1056 
1057 // Return the appropriate result
1058 //
1059  dP->UnLock();
1060  return rc;
1061 }

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 1020 of file XrdPosixXrootd.cc.

1022 {
1023  dirent64 *dp64 = 0, d64ent;
1024  int rc;
1025 
1026  if ((rc = Readdir64_r(dirp, &d64ent, &dp64)) || !dp64)
1027  {*result = 0; return rc;}
1028 
1029  entry->d_ino = dp64->d_ino;
1030 #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__GNU__) && !(defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1031  entry->d_off = dp64->d_off;
1032 #endif
1033 #ifndef __solaris__
1034  entry->d_type = dp64->d_type;
1035 #endif
1036  entry->d_reclen = dp64->d_reclen;
1037  strcpy(entry->d_name, dp64->d_name);
1038  *result = entry;
1039  return rc;
1040 }
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 907 of file XrdPosixXrootd.cc.

908 {
909  ssize_t bytes, totbytes = 0;
910  int i;
911 
912 // Return the results of the read for each iov segment
913 //
914  for (i = 0; i < iovcnt; i++)
915  {bytes = Read(fildes,(void *)iov[i].iov_base,(size_t)iov[i].iov_len);
916  if (bytes > 0) totbytes += bytes;
917  else if (bytes < 0) return -1;
918  else break;
919  }
920 
921 // All done
922 //
923  return totbytes;
924 }
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 1083 of file XrdPosixXrootd.cc.

1084 {
1085  XrdPosixAdmin admin(oldpath,XrdPosixGlobals::ecMsg);
1086  XrdCl::URL newUrl((std::string)newpath);
1087 
1088 // Make sure the admin is OK and the new url is valid
1089 //
1090  if (!admin.isOK() || !newUrl.IsValid())
1091  return XrdPosixGlobals::ecMsg.SetErrno(EINVAL);
1092 
1093 // Issue rename to he cache (it really should just deep-six both files)
1094 //
1096  {LfnPath oldF("rename", oldpath);
1097  LfnPath newF("rename", newpath);
1098  if (!oldF.path || !newF.path) return -1;
1099  XrdPosixGlobals::theCache->Rename(oldF.path, newF.path);
1100  }
1101 
1102 // Issue the rename
1103 //
1105  return EcRename(oldpath, newpath, admin);
1106 
1107  return XrdPosixMap::Result(admin.Xrd.Mv(admin.Url.GetPathWithParams(),
1108  newUrl.GetPathWithParams()),
1109  XrdPosixGlobals::ecMsg, true);
1110 }
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 1116 of file XrdPosixXrootd.cc.

1117 {
1118  XrdPosixDir *dP;
1119  int fildes = XrdPosixDir::dirNo(dirp);
1120 
1121 // Find the object and rewind it
1122 //
1123  if ((dP = XrdPosixObject::Dir(fildes)))
1124  {dP->rewind();
1125  dP->UnLock();
1126  }
1127 }
void rewind()
Definition: XrdPosixDir.hh:78

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 1133 of file XrdPosixXrootd.cc.

1134 {
1136 
1137 // Make sure the admin is OK
1138 //
1139  if (!admin.isOK()) return -1;
1140 
1141 // Remove directory from the cache first
1142 //
1144  {LfnPath rmd("rmdir", path);
1145  if (!rmd.path) return -1;
1146  XrdPosixGlobals::theCache->Rmdir(rmd.path);
1147  }
1148 
1149 // Issue the rmdir
1150 //
1151  return XrdPosixMap::Result(admin.Xrd.RmDir(admin.Url.GetPathWithParams()),
1152  XrdPosixGlobals::ecMsg, true);
1153 }
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 1159 of file XrdPosixXrootd.cc.

1160 {
1161  XrdPosixDir *dP;
1162  int fildes = XrdPosixDir::dirNo(dirp);
1163 
1164 // Find the object
1165 //
1166  if (!(dP = XrdPosixObject::Dir(fildes))) return;
1167 
1168 // Sets the current directory position
1169 //
1170  if (dP->Unread() && !(dP->Open()))
1171  {if (loc >= dP->getEntries()) loc = dP->getEntries();
1172  else if (loc < 0) loc = 0;
1173  dP->setOffset(loc);
1174  }
1175  dP->UnLock();
1176 }
bool Unread()
Definition: XrdPosixDir.hh:84
void setOffset(long offset)
Definition: XrdPosixDir.hh:67
long getEntries()
Definition: XrdPosixDir.hh:63

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 1182 of file XrdPosixXrootd.cc.

1183 {
1185  bool cacheChk = false;
1186 
1187 // Make sure the admin is OK
1188 //
1189  if (!admin.isOK()) return -1;
1190 
1191 // Initialize the stat buffer
1192 //
1194 
1195 // Check if we can get the stat informatation from the cache
1196 //
1198  {LfnPath statX("stat", path, false);
1199  if (!statX.path) return -1;
1200  int rc = XrdPosixGlobals::theCache->Stat(statX.path, *buf);
1201  if (!rc) return 0;
1202  if (rc < 0) {errno = -rc; return -1;} // does the cache set this???
1203  cacheChk = true;
1204  }
1205 
1206 // Issue the stat and verify that all went well
1207 //
1209  return EcStat(path, buf, admin);
1210 
1211  if (!admin.Stat(*buf)) return -1;
1212 
1213 // If we are here and the cache was checked then the file was not in the cache.
1214 // We informally tell the caller this is the case by setting atime to zero.
1215 // Normally, atime will never be zero in any other case.
1216 //
1217  if (cacheChk) buf->st_atime = 0;
1218  return 0;
1219 }
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 1225 of file XrdPosixXrootd.cc.

1226 {
1227  struct statvfs myVfs;
1228  int rc;
1229 
1230 // Issue a statvfs() call and transcribe the results
1231 //
1232  if ((rc = Statvfs(path, &myVfs))) return rc;
1233 
1234 // The vfs structure and fs structures should be size compatible (not really)
1235 //
1236  memset(buf, 0, sizeof(struct statfs));
1237  buf->f_bsize = myVfs.f_bsize;
1238  buf->f_blocks = myVfs.f_blocks;
1239  buf->f_bfree = myVfs.f_bfree;
1240  buf->f_files = myVfs.f_files;
1241  buf->f_ffree = myVfs.f_ffree;
1242 #if defined(__APPLE__) || defined(__FreeBSD__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1243  buf->f_iosize = myVfs.f_frsize;
1244 #else
1245  buf->f_frsize = myVfs.f_frsize;
1246 #endif
1247 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1248  buf->f_bavail = myVfs.f_bavail;
1249 #endif
1250 #if defined(__linux__) || defined(__GNU__)
1251  buf->f_namelen = myVfs.f_namemax;
1252 #elif defined(__FreeBSD__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1253  buf->f_namemax = myVfs.f_namemax;
1254 #endif
1255  return 0;
1256 }
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:

◆ StatRet()

int XrdPosixXrootd::StatRet ( DIR *  dirp,
struct stat buf 
)
static

Definition at line 1063 of file XrdPosixXrootd.cc.

1064 {
1065 
1066 // Find the object
1067 //
1068  auto fildes = XrdPosixDir::dirNo(dirp);
1069  auto dP = XrdPosixObject::Dir(fildes);
1070  if (!dP) return EBADF;
1071 
1072 // Get the stat info
1073  auto rc = dP->StatRet(buf);
1074 
1075  dP->UnLock();
1076  return rc;
1077 }

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

Referenced by XrdPssDir::StatRet().

+ 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 1262 of file XrdPosixXrootd.cc.

1263 {
1264  static const int szVFS = sizeof(buf->f_bfree);
1265  static const long long max32 = 0x7fffffffLL;
1266 
1268  XrdCl::StatInfoVFS *vfsStat;
1269 
1270  long long rwFree, ssFree, rwBlks;
1271  int rwNum, ssNum, rwUtil, ssUtil;
1272 
1273 // Make sure we connected
1274 //
1275  if (!admin.isOK()) return -1;
1276 
1277 // Issue the statfvs call
1278 //
1279  if (XrdPosixMap::Result(admin.Xrd.StatVFS(admin.Url.GetPathWithParams(),
1280  vfsStat),
1281  XrdPosixGlobals::ecMsg) < 0) return -1;
1282 
1283 // Extract out the information
1284 //
1285  rwNum = static_cast<int>(vfsStat->GetNodesRW());
1286  rwFree = (long long)vfsStat->GetFreeRW();
1287  rwUtil = static_cast<int>(vfsStat->GetUtilizationRW());
1288  ssNum = static_cast<int>(vfsStat->GetNodesStaging());
1289  ssFree = (long long)vfsStat->GetFreeStaging();
1290  ssUtil = static_cast<int>(vfsStat->GetUtilizationStaging());
1291  delete vfsStat;
1292 
1293 // Calculate number of blocks
1294 //
1295  if (rwUtil == 0) rwBlks = rwFree;
1296  else if (rwUtil >= 100) rwBlks = 0;
1297  else rwBlks = rwFree * (100 / (100 - rwUtil));
1298  if (ssUtil == 0) rwBlks += ssFree;
1299  else if (ssUtil < 100) rwBlks += ssFree * (100 / (100 - ssUtil));
1300 
1301 // Scale units to what will fit here (we can have a 32-bit or 64-bit struct)
1302 //
1303  if (szVFS < 8)
1304  {if (rwBlks > max32) rwBlks = max32;
1305  if (rwFree > max32) rwFree = max32;
1306  if (ssFree > max32) ssFree = max32;
1307  }
1308 
1309 // Return what little we can
1310 //
1311  memset(buf, 0, sizeof(struct statvfs));
1312  buf->f_bsize = 1024*1024;
1313  buf->f_frsize = 1024*1024;
1314  buf->f_blocks = static_cast<fsblkcnt_t>(rwBlks);
1315  buf->f_bfree = static_cast<fsblkcnt_t>(rwFree + ssFree);
1316  buf->f_bavail = static_cast<fsblkcnt_t>(rwFree);
1317  buf->f_ffree = rwNum + ssNum;
1318  buf->f_favail = rwNum;
1319  buf->f_namemax = 255; // The best we are going to do here
1320  buf->f_flag = (rwNum == 0 ? ST_RDONLY|ST_NOSUID : ST_NOSUID);
1321  return 0;
1322 }
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 1328 of file XrdPosixXrootd.cc.

1329 {
1330  XrdPosixDir *dP;
1331  long pos;
1332  int fildes = XrdPosixDir::dirNo(dirp);
1333 
1334 // Find the object
1335 //
1336  if (!(dP = XrdPosixObject::Dir(fildes)))
1337  return XrdPosixGlobals::ecMsg.SetErrno(EBADF,0);
1338 
1339 // Tell the current directory location
1340 //
1341  pos = dP->getOffset();
1342  dP->UnLock();
1343  return pos;
1344 }
long getOffset()
Definition: XrdPosixDir.hh:65

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 1350 of file XrdPosixXrootd.cc.

1351 {
1353  uint64_t tSize = static_cast<uint64_t>(Size);
1354 
1355 // Make sure the admin is OK
1356 //
1357  if (!admin.isOK()) return -1;
1358 
1359 // Truncate in the cache first
1360 //
1362  {LfnPath trunc("truncate", path);
1363  if (!trunc.path) return -1;
1364  XrdPosixGlobals::theCache->Truncate(trunc.path, tSize);
1365  }
1366 
1367 // Issue the truncate to the origin
1368 //
1369  std::string urlp = admin.Url.GetPathWithParams();
1370  return XrdPosixMap::Result(admin.Xrd.Truncate(urlp,tSize),
1371  XrdPosixGlobals::ecMsg,true);
1372 }
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 1378 of file XrdPosixXrootd.cc.

1379 {
1381 
1382 // Make sure the admin is OK
1383 //
1384  if (!admin.isOK()) return -1;
1385 
1386 // Unlink the cache first
1387 //
1389  {LfnPath remf("unlink", path);
1390  if (!remf.path) return -1;
1391  XrdPosixGlobals::theCache->Unlink(remf.path);
1392  }
1393 
1394 // Issue the UnLink
1395 //
1397  return EcUnlink(path, admin);
1398 
1399  return XrdPosixMap::Result(admin.Xrd.Rm(admin.Url.GetPathWithParams()),
1400  XrdPosixGlobals::ecMsg, true);
1401 }
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 930 of file XrdPosixXrootd.cc.

931 {
932  XrdPosixFile *fp;
933  ssize_t bytes;
934 
935 // Find the file object
936 //
937  if (!(fp = XrdPosixObject::File(fildes))) return -1;
938 
939 // Issue the read
940 //
941  if ((bytes = fp->XCio->ReadV(readV, n)) < 0) return Fault(fp,-bytes);
942 
943 // Return bytes read
944 //
945  fp->UnLock();
946  return bytes;
947 }
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 951 of file XrdPosixXrootd.cc.

953 {
954  XrdPosixFile *fp;
955 
956 // Find the file object and issue read
957 //
958  if ((fp = XrdPosixObject::File(fildes)))
959  {cbp->theFile = fp;
960  fp->Ref(); fp->UnLock();
961  fp->XCio->ReadV(*cbp, readV, n);
962  } else cbp->Complete(-1);
963 }

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 1407 of file XrdPosixXrootd.cc.

1408 {
1409  XrdPosixFile *fp;
1410  int iosz, bytes;
1411 
1412 // Find the file object
1413 //
1414  if (!(fp = XrdPosixObject::File(fildes))) return -1;
1415 
1416 // Make sure the size is not too large
1417 //
1418  if (nbyte > (size_t)0x7fffffff) return Fault(fp,EOVERFLOW);
1419  else iosz = static_cast<int>(nbyte);
1420 
1421 // Issue the write
1422 //
1423  bytes = fp->XCio->Write((char *)buf,fp->Offset(),(int)iosz);
1424  if (bytes < 0) return Fault(fp,-bytes);
1425 
1426 // All went well
1427 //
1428  fp->addOffset(iosz, 1);
1429  fp->UnLock();
1430  return (ssize_t)iosz;
1431 }

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 1437 of file XrdPosixXrootd.cc.

1438 {
1439  ssize_t totbytes = 0;
1440  int i;
1441 
1442 // Return the results of the write for each iov segment
1443 //
1444  for (i = 0; i < iovcnt; i++)
1445  {if (!Write(fildes,(void *)iov[i].iov_base,(size_t)iov[i].iov_len))
1446  return -1;
1447  totbytes += iov[i].iov_len;
1448  }
1449 
1450 // All done
1451 //
1452  return totbytes;
1453 }
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: