XRootD
Loading...
Searching...
No Matches
XrdPosixXrootd Class Reference

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

#include <XrdPosixXrootd.hh>

Collaboration diagram for XrdPosixXrootd:

Public Types

enum class  Fcop { QFInfo }

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().
static int Close (int fildes)
 Close() conforms to POSIX.1-2001 close().
static int Closedir (DIR *dirp)
 Closedir() conforms to POSIX.1-2001 closedir().
static int endPoint (int FD, char *Buff, int Blen)
static int Fcntl (int fildes, Fcop op, const std::string &args, std::string &resp)
static int Fstat (int fildes, struct stat *buf)
 Fstat() conforms to POSIX.1-2001 fstat().
static int Fsync (int fildes)
 Fsync() conforms to POSIX.1-2001 fsync().
static void Fsync (int fildes, XrdPosixCallBackIO *cbp)
static int Ftruncate (int fildes, off_t offset)
 Ftruncate() conforms to POSIX.1-2001 ftruncate().
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().
static int Mkdir (const char *path, mode_t mode)
 Mkdir() conforms to POSIX.1-2001 mkdir().
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().
static ssize_t Pread (int fildes, void *buf, size_t nbyte, off_t offset)
 Pread() conforms to POSIX.1-2001 pread().
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().
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().
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().
static int Rename (const char *oldpath, const char *newpath)
 Rename() conforms to POSIX.1-2001 rename().
static void Rewinddir (DIR *dirp)
 Rewinddir() conforms to POSIX.1-2001 rewinddir().
static int Rmdir (const char *path)
 Rmdir() conforms to POSIX.1-2001 rmdir().
static void Seekdir (DIR *dirp, long loc)
 Seekdir() conforms to POSIX.1-2001 seekdir().
static int Stat (const char *path, struct stat *buf)
 Stat() conforms to POSIX.1-2001 stat().
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().
static long Telldir (DIR *dirp)
 Telldir() conforms to POSIX.1-2001 telldir().
static int Truncate (const char *path, off_t offset)
 Telldir() conforms to POSIX.1-2001 telldir().
static int Unlink (const char *path)
 Unlink() conforms to POSIX.1-2001 unlink().
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().
static ssize_t Writev (int fildes, const struct iovec *iov, int iovcnt)
 Writev() conforms to POSIX.1-2001 writev().

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.

Member Enumeration Documentation

◆ Fcop

enum class XrdPosixXrootd::Fcop
strong

Fcntl() conforms to POSIX.1-2001 fcntl() only in terms of API. The actual function that are supported are as follows: TBD

Parameters
opOne of the operation codes in the enum class. FInfo - Get file information as requested by args.
args- Arguments specific to the specified the op parameter.
resp- Response or error message specific to the op parameter.
Returns
>= 0 - Success. The actual value is dependent on the op parameter.
< 0 - Failure. The resp may contain a message and errno set to an error code. If resp = '', convert errno to message text.
Enumerator
QFInfo 

Definition at line 115 of file XrdPosixXrootd.hh.

115{ QFInfo };

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{
244 XrdPosixAdmin admin(path,XrdPosixGlobals::ecMsg);
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 ret=-1, const char *alt=0)
XrdOucECMsg ecMsg

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

Here is the call 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//
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)
#define EPNAME(x)
std::string obfuscateAuth(const std::string &input)
#define DEBUGON
virtual bool Detach(XrdOucCacheIOCD &iocd)=0
XrdOucCacheIO * XCio
static void * DelayedDestroy(void *)
static int Result(const XrdCl::XRootDStatus &Status, XrdOucECMsg &ecMsg, bool retneg1=false)
static XrdPosixFile * ReleaseFile(int fildes)
std::string ToString() const
Create a string representation.

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

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

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)
static XrdPosixDir * ReleaseDir(int fildes)

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

Referenced by XrdPssDir::Close(), and XrdFfsPosix_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:962
bool GetProperty(const std::string &name, std::string &value) const
Definition XrdClFile.cc:994
int GetPort() const
Get the target port.
Definition XrdClURL.hh:188
XrdCl::File clFile
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:

◆ Fcntl()

int XrdPosixXrootd::Fcntl ( int fildes,
XrdPosixXrootd::Fcop op,
const std::string & args,
std::string & resp )
static

Definition at line 369 of file XrdPosixXrootd.cc.

372{
373 XrdPosixFile *fp;
374
375// Find the file object
376//
377 if (!(fp = XrdPosixObject::File(fildes))) return -1;
378
379// At the moment we support nothing
380//
381 resp = "Function not supported.";
382 errno = ENOTSUP;
383 return -1;
384}

References XrdPosixObject::File().

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 391 of file XrdPosixXrootd.hh.

391{return baseFD;}

Referenced by xrootdfs_init().

Here is the caller graph for this function:

◆ Fstat()

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

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

Definition at line 390 of file XrdPosixXrootd.cc.

391{
392 XrdPosixFile *fp;
393 int rc;
394
395// Find the file object
396//
397 if (!(fp = XrdPosixObject::File(fildes))) return -1;
398
399// First initialize the stat buffer
400//
402
403// Check if we can get the stat information from the cache.
404//
405 rc = fp->XCio->Fstat(*buf);
406 if (rc <= 0)
407 {fp->UnLock();
408 if (!rc) return 0;
409 errno = -rc; //???
410 return -1;
411 }
412
413// At this point we can call the file's Fstat() and if the file is not open
414// it will be opened.
415//
416 rc = fp->Fstat(*buf);
417 fp->UnLock();
418 if (rc < 0) {errno = -rc; rc = -1;}
419 return rc;
420}
virtual int Fstat(struct stat &sbuff)
static void initStat(struct stat *buf)
int Fstat(struct stat &buf) override

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

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

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

427{
428 XrdPosixFile *fp;
429 int rc;
430
431// Find the file object
432//
433 if (!(fp = XrdPosixObject::File(fildes))) return -1;
434
435// Do the sync
436//
437 if ((rc = fp->XCio->Sync()) < 0) return Fault(fp, -rc);
438 fp->UnLock();
439 return 0;
440}
virtual int Sync()=0

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

Referenced by XrdPssFile::Fsync(), XrdPssFile::Fsync(), and XrdFfsPosix_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 444 of file XrdPosixXrootd.cc.

445{
446 XrdPosixFile *fp;
447
448// Find the file object and do the sync
449//
450 if ((fp = XrdPosixObject::File(fildes)))
451 {cbp->theFile = fp;
452 fp->Ref(); fp->UnLock();
453 fp->XCio->Sync(*cbp);
454 } else cbp->Complete(-1);
455}
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 461 of file XrdPosixXrootd.cc.

462{
463 XrdPosixFile *fp;
464 int rc;
465
466// Find the file object
467//
468 if (!(fp = XrdPosixObject::File(fildes))) return -1;
469
470// Do the trunc
471//
472 if ((rc = fp->XCio->Trunc(offset)) < 0) return Fault(fp, -rc);
473 fp->UnLock();
474 return 0;
475}
virtual int Trunc(long long offs)=0

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

Referenced by XrdPssFile::Ftruncate(), and XrdFfsPosix_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 485 of file XrdPosixXrootd.cc.

487{
488 XrdPosixAdmin admin(path,XrdPosixGlobals::ecMsg);
490 int vsize = static_cast<int>(size);
491
492// Check if user just wants the maximum length needed
493//
494 if (size == 0) return 1024;
495
496// Check if we support the query
497//
498 if (name)
499 { if (!strcmp(name,"xroot.cksum")) reqCode=XrdCl::QueryCode::Checksum;
500 else if (!strcmp(name,"xroot.space")) reqCode=XrdCl::QueryCode::Space;
501 else if (!strcmp(name,"xroot.xattr")) reqCode=XrdCl::QueryCode::XAttr;
502 else {errno = ENOATTR; return -1;} //???
503 }else {errno = EINVAL; return -1;}
504
505// Stat the file first to allow vectoring of the request to the right server
506//
507 if (!admin.Stat()) return -1;
508
509// Return the result
510//
511 return admin.Query(reqCode, value, vsize);
512}
#define ENOATTR
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 1483 of file XrdPosixXrootd.cc.

1484{
1485 XrdPosixDir *dP;
1486 int fildes;
1487
1488 if (!dirp) return false;
1489 fildes = XrdPosixDir::dirNo(dirp);
1490
1491 if (!myFD(fildes) || !(dP = XrdPosixObject::Dir(fildes))) return false;
1492
1493 dP->UnLock();
1494 return true;
1495}
static XrdPosixDir * Dir(int fildes, bool glk=false)
static bool myFD(int fd)

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

Here is the call 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 518 of file XrdPosixXrootd.cc.

519{
520 XrdPosixFile *fp;
521 long long curroffset;
522
523// Find the file object
524//
525 if (!(fp = XrdPosixObject::File(fildes))) return -1;
526
527// Set the new offset. Note that SEEK_END requires that the file be opened.
528// An open may occur by calling the FSize() method via the cache pointer.
529//
530 if (whence == SEEK_SET) curroffset = fp->setOffset(offset);
531 else if (whence == SEEK_CUR) curroffset = fp->addOffset(offset);
532 else if (whence == SEEK_END)
533 {curroffset = fp->XCio->FSize();
534 if (curroffset < 0) return Fault(fp,static_cast<int>(-curroffset));
535 curroffset = fp->setOffset(curroffset+offset);
536 }
537 else return Fault(fp, EINVAL);
538
539// All done
540//
541 fp->UnLock();
542 return curroffset;
543}
virtual long long FSize()=0
long long addOffset(long long offs, int updtSz=0)
long long setOffset(long long offs)

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

Referenced by XrdFfsPosix_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 549 of file XrdPosixXrootd.cc.

550{
551 XrdPosixAdmin admin(path,XrdPosixGlobals::ecMsg);
553
554// Preferentially make the whole path unless told otherwise
555//
556 flags = (mode & S_ISUID ? XrdCl::MkDirFlags::None
558
559// Make sure the admin is OK
560//
561 if (!admin.isOK()) return -1;
562
563// Issue the mkdir
564//
565 return XrdPosixMap::Result(admin.Xrd.MkDir(admin.Url.GetPathWithParams(),
566 flags,
569 );
570}
static XrdCl::Access::Mode Mode2Access(mode_t mode)
@ 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(), and XrdFfsPosix_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 1501 of file XrdPosixXrootd.cc.

1502{
1503 return XrdPosixObject::Valid(fd);
1504}
static bool Valid(int fd)

References XrdPosixObject::Valid().

Referenced by isXrootdDir().

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

578{
579 return Open(path, oflags, mode, cbP, 0);
580}
static int Open(const char *path, int oflag, mode_t mode=0, XrdPosixCallBack *cbP=0)

References Open().

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

Here is the call graph for this function:
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 726 of file XrdPosixXrootd.cc.

727{
728 XrdPosixDir *dP;
729 DIR *dirP;
730 int rc;
731
732// Get a new directory object
733//
734 if (!(dP = new XrdPosixDir(path)))
736 return (DIR*)0;
737 }
738
739// Assign a file descriptor to this file
740//
741 if (!(dP->AssignFD()))
742 {delete dP;
744 return (DIR*)0;
745 }
746
747// Open the directory
748//
749 if ((dirP = dP->Open())) return dirP;
750
751// We failed
752//
753 rc = errno;
754 delete dP;
755 errno = rc; // Restore saved errno
756 return (DIR *)0;
757}
bool AssignFD(bool isStream=false)

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

Referenced by XrdPssDir::Opendir(), and XrdFfsPosix_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 763 of file XrdPosixXrootd.cc.

764{
765 XrdPosixFile *fp;
766 long long offs, bytes;
767 int iosz;
768
769// Find the file object
770//
771 if (!(fp = XrdPosixObject::File(fildes)))
772 return XrdPosixGlobals::ecMsg.SetErrno(EBADF);
773
774// Make sure the size is not too large
775//
776 if (nbyte > (size_t)0x7fffffff)
777 return Fault(fp, EOVERFLOW, "read size too large");
778 else iosz = static_cast<int>(nbyte);
779
780// Issue the read
781//
782 offs = static_cast<long long>(offset);
783 bytes = fp->XCio->Read((char *)buf, offs, (int)iosz);
784 if (bytes < 0) return Fault(fp,-bytes,"*");
785
786// All went well
787//
788 fp->UnLock();
789 return (ssize_t)bytes;
790}
virtual int Read(char *buff, long long offs, int rlen)=0

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

Referenced by XrdPssFile::Read(), XrdPssFile::Read(), and XrdFfsPosix_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 794 of file XrdPosixXrootd.cc.

796{
797 XrdPosixFile *fp;
798 long long offs;
799 int iosz;
800
801// Find the file object
802//
803 if (!(fp = XrdPosixObject::File(fildes))) {cbp->Complete(-1); return;}
804
805// Make sure the size is not too large
806//
807 if (nbyte > (size_t)0x7fffffff)
808 {fp->UnLock();
809 fp->ecMsg.SetErrno(EOVERFLOW,0,"read size too large");
810 cbp->Complete(-1);
811 return;
812 }
813
814// Prepare for the read
815//
816 cbp->theFile = fp;
817 fp->Ref(); fp->UnLock();
818 iosz = static_cast<int>(nbyte);
819 offs = static_cast<long long>(offset);
820
821// Issue the read
822//
823 fp->XCio->Read(*cbp, (char *)buf, offs, (int)iosz);
824}
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 830 of file XrdPosixXrootd.cc.

831{
832 XrdPosixFile *fp;
833 long long offs;
834 int iosz, bytes;
835
836// Find the file object
837//
838 if (!(fp = XrdPosixObject::File(fildes))) return -1;
839
840// Make sure the size is not too large
841//
842 if (nbyte > (size_t)0x7fffffff)
843 return Fault(fp,EOVERFLOW,"write size too large");
844 else iosz = static_cast<int>(nbyte);
845
846// Issue the write
847//
848 offs = static_cast<long long>(offset);
849 bytes = fp->XCio->Write((char *)buf, offs, (int)iosz);
850 if (bytes < 0) return Fault(fp,-bytes,"*");
851
852// All went well
853//
854 fp->UpdtSize(offs + iosz);
855 fp->UnLock();
856 return (ssize_t)iosz;
857}
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(), XrdPssFile::Write(), and XrdFfsPosix_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 861 of file XrdPosixXrootd.cc.

863{
864 XrdPosixFile *fp;
865 long long offs;
866 int iosz;
867
868// Find the file object
869//
870 if (!(fp = XrdPosixObject::File(fildes))) {cbp->Complete(-1); return;}
871
872// Make sure the size is not too large
873//
874 if (nbyte > (size_t)0x7fffffff)
875 {fp->UnLock();
876 fp->ecMsg.SetErrno(EOVERFLOW,0,"read size too large");
877 cbp->Complete(-1);
878 return;
879 }
880
881// Prepare for the writing
882//
883 cbp->theFile = fp;
884 fp->Ref(); fp->UnLock();
885 iosz = static_cast<int>(nbyte);
886 offs = static_cast<long long>(offset);
887
888// Issue the read
889//
890 fp->XCio->Write(*cbp, (char *)buf, offs, (int)iosz);
891}

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

1512{
1513 XrdPosixAdmin admin(path,XrdPosixGlobals::ecMsg);
1514
1515// Stat the file first to allow vectoring of the request to the right server
1516//
1517 if (!admin.Stat(0, &Mtime)) return -1;
1518
1519// Now we can get the checksum as we have landed on the right server
1520//
1521 return admin.Query(XrdCl::QueryCode::Checksum, value, vsize);
1522}

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

1550{
1551 XrdPosixDir *dP;
1552 int fildes = XrdPosixDir::dirNo(dirP);
1553
1554// Find the object
1555//
1556 if (!(dP = XrdPosixObject::Dir(fildes)))
1557 return XrdPosixGlobals::ecMsg.SetErrno(EBADF);
1558
1559// Return result
1560//
1561 return dP->getECMsg()->Get(emsg, reset);
1562}
int emsg(int rc, char *msg)
int Get(std::string &ecm, bool rst=true)
XrdOucECMsg * getECMsg()

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

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

1529{
1530 XrdOucECMsg* ecmP;
1531 XrdPosixFile* fp = 0;
1532
1533// If global wanted then use that one otherwise find the object specific one
1534//
1535 if (fd < 0) ecmP = &XrdPosixGlobals::ecMsg;
1536 else {if (!(fp = XrdPosixObject::File(fd))) return -1;
1537 ecmP = fp->getECMsg();
1538 }
1539
1540// Return the message information
1541//
1542 const int rc = ecmP->Get(emsg, reset);
1543 if (fp) fp->UnLock();
1544 return rc;
1545}

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

Referenced by XrdPssDir::Close(), XrdPssFile::Close(), XrdPssFile::Fctl(), XrdPssFile::Fstat(), XrdPssFile::Fsync(), XrdPssFile::Ftruncate(), XrdPssSys::Info(), XrdPssFile::Open(), XrdPssDir::Opendir(), XrdPssFile::pgRead(), XrdPssFile::pgWrite(), XrdPssFile::Read(), XrdPssDir::Readdir(), XrdPssFile::ReadV(), and XrdPssFile::Write().

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

1569{
1570 XrdPosixAdmin admin(path,XrdPosixGlobals::ecMsg);
1571
1572// Stat the file first to allow vectoring of the request to the right server
1573//
1574 if (!admin.Stat()) return -1;
1575
1576// Now we can get the checksum as we have landed on the right server
1577//
1578 return admin.Query(XrdCl::QueryCode::OpaqueFile, value, size);
1579}
@ 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 897 of file XrdPosixXrootd.cc.

898{
899 XrdPosixFile *fp;
900 long long bytes;
901 int iosz;
902
903// Find the file object
904//
905 if (!(fp = XrdPosixObject::File(fildes))) return -1;
906
907// Make sure the size is not too large
908//
909 if (nbyte > (size_t)0x7fffffff) return Fault(fp,EOVERFLOW);
910 else iosz = static_cast<int>(nbyte);
911
912// Issue the read
913//
914 bytes = fp->XCio->Read((char *)buf,fp->Offset(),(int)iosz);
915 if (bytes < 0) return Fault(fp,-bytes);
916
917// All went well
918//
919 fp->addOffset(bytes);
920 fp->UnLock();
921 return (ssize_t)bytes;
922}
long long Offset()

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

Referenced by main(), Readv(), and XrdFfsPosix_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 990 of file XrdPosixXrootd.cc.

991{
992 dirent64 *dp64;
993 dirent *dp32; // Could be the same as dp64
994
995 if (!(dp64 = Readdir64(dirp))) return 0;
996
997 dp32 = (struct dirent *)dp64;
998 if ((char*)dp32->d_name != (char*)dp64->d_name)
999 {dp32->d_ino = dp64->d_ino;
1000#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__GNU__) && !(defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1001 dp32->d_off = dp64->d_off;
1002#endif
1003#ifndef __solaris__
1004 dp32->d_type = dp64->d_type;
1005#endif
1006 dp32->d_reclen = dp64->d_reclen;
1007 strcpy(dp32->d_name, dp64->d_name);
1008 }
1009 return dp32;
1010}
static struct dirent64 * Readdir64(DIR *dirp)

References Readdir64().

Referenced by XrdFfsPosix_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 1012 of file XrdPosixXrootd.cc.

1013{
1014 XrdPosixDir *dP;
1015 dirent64 *dentP;
1016 int rc, fildes = XrdPosixDir::dirNo(dirp);
1017
1018// Find the object
1019//
1020 if (!(dP = XrdPosixObject::Dir(fildes)))
1022 return (dirent64*)0;
1023 }
1024
1025// Get the next directory entry
1026//
1027 if (!(dentP = dP->nextEntry())) rc = dP->Status();
1028 else rc = 0;
1029
1030// Return the appropriate result
1031//
1032 dP->UnLock();
1033 if (rc) errno = rc;
1034 return dentP;
1035}
dirent64 * nextEntry(dirent64 *dp=0)

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

Referenced by Readdir().

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

1065{
1066 XrdPosixDir *dP;
1067 int rc, fildes = XrdPosixDir::dirNo(dirp);
1068
1069// Find the object
1070//
1071 if (!(dP = XrdPosixObject::Dir(fildes))) return EBADF;
1072
1073// Get the next entry
1074//
1075 if (!(*result = dP->nextEntry(entry))) {rc = dP->Status(); *result = 0;}
1076 else {rc = 0; *result = entry;}
1077
1078// Return the appropriate result
1079//
1080 dP->UnLock();
1081 return rc;
1082}

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

Referenced by Readdir_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 1041 of file XrdPosixXrootd.cc.

1043{
1044 dirent64 *dp64 = 0, d64ent;
1045 int rc;
1046
1047 if ((rc = Readdir64_r(dirp, &d64ent, &dp64)) || !dp64)
1048 {*result = 0; return rc;}
1049
1050 entry->d_ino = dp64->d_ino;
1051#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__GNU__) && !(defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1052 entry->d_off = dp64->d_off;
1053#endif
1054#ifndef __solaris__
1055 entry->d_type = dp64->d_type;
1056#endif
1057 entry->d_reclen = dp64->d_reclen;
1058 strcpy(entry->d_name, dp64->d_name);
1059 *result = entry;
1060 return rc;
1061}
static int Readdir64_r(DIR *dirp, struct dirent64 *entry, struct dirent64 **result)

References Readdir64_r().

Referenced by XrdPssDir::Readdir().

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

929{
930 ssize_t bytes, totbytes = 0;
931 int i;
932
933// Return the results of the read for each iov segment
934//
935 for (i = 0; i < iovcnt; i++)
936 {bytes = Read(fildes,(void *)iov[i].iov_base,(size_t)iov[i].iov_len);
937 if (bytes > 0) totbytes += bytes;
938 else if (bytes < 0) return -1;
939 else break;
940 }
941
942// All done
943//
944 return totbytes;
945}
static ssize_t Read(int fildes, void *buf, size_t nbyte)
Read() conforms to POSIX.1-2001 read().

References Read().

Here is the call 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 1088 of file XrdPosixXrootd.cc.

1089{
1090 XrdPosixAdmin admin(oldpath,XrdPosixGlobals::ecMsg);
1091 XrdCl::URL newUrl((std::string)newpath);
1092
1093// Make sure the admin is OK and the new url is valid
1094//
1095 if (!admin.isOK() || !newUrl.IsValid())
1096 return XrdPosixGlobals::ecMsg.SetErrno(EINVAL);
1097
1098// Issue rename to he cache (it really should just deep-six both files)
1099//
1101 {LfnPath oldF("rename", oldpath);
1102 LfnPath newF("rename", newpath);
1103 if (!oldF.path || !newF.path) return -1;
1104 XrdPosixGlobals::theCache->Rename(oldF.path, newF.path);
1105 }
1106
1107// Issue the rename
1108//
1110 return EcRename(oldpath, newpath, admin);
1111
1112 return XrdPosixMap::Result(admin.Xrd.Mv(admin.Url.GetPathWithParams(),
1113 newUrl.GetPathWithParams()),
1115}
virtual int Rename(const char *oldp, const char *newp)
XrdOucCache * theCache

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

Referenced by XrdPssSys::Rename(), and XrdFfsPosix_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 1121 of file XrdPosixXrootd.cc.

1122{
1123 XrdPosixDir *dP;
1124 int fildes = XrdPosixDir::dirNo(dirp);
1125
1126// Find the object and rewind it
1127//
1128 if ((dP = XrdPosixObject::Dir(fildes)))
1129 {dP->rewind();
1130 dP->UnLock();
1131 }
1132}
void rewind()

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

Here is the call graph for this function:

◆ Rmdir()

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

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

Definition at line 1138 of file XrdPosixXrootd.cc.

1139{
1140 XrdPosixAdmin admin(path,XrdPosixGlobals::ecMsg);
1141
1142// Make sure the admin is OK
1143//
1144 if (!admin.isOK()) return -1;
1145
1146// Remove directory from the cache first
1147//
1149 {LfnPath rmd("rmdir", path);
1150 if (!rmd.path) return -1;
1152 }
1153
1154// Issue the rmdir
1155//
1156 return XrdPosixMap::Result(admin.Xrd.RmDir(admin.Url.GetPathWithParams()),
1158}
virtual int Rmdir(const char *dirp)

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

Referenced by XrdPssSys::Remdir(), and XrdFfsPosix_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 1164 of file XrdPosixXrootd.cc.

1165{
1166 XrdPosixDir *dP;
1167 int fildes = XrdPosixDir::dirNo(dirp);
1168
1169// Find the object
1170//
1171 if (!(dP = XrdPosixObject::Dir(fildes))) return;
1172
1173// Sets the current directory position
1174//
1175 if (dP->Unread() && !(dP->Open()))
1176 {if (loc >= dP->getEntries()) loc = dP->getEntries();
1177 else if (loc < 0) loc = 0;
1178 dP->setOffset(loc);
1179 }
1180 dP->UnLock();
1181}
bool Unread()
void setOffset(long offset)
long getEntries()

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

Here is the call 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 1187 of file XrdPosixXrootd.cc.

1188{
1189 XrdPosixAdmin admin(path,XrdPosixGlobals::ecMsg);
1190 bool cacheChk = false;
1191
1192// Make sure the admin is OK
1193//
1194 if (!admin.isOK()) return -1;
1195
1196// Initialize the stat buffer
1197//
1199
1200// Check if we can get the stat informatation from the cache
1201//
1203 {LfnPath statX("stat", path, false);
1204 if (!statX.path) return -1;
1205 int rc = XrdPosixGlobals::theCache->Stat(statX.path, *buf);
1206 if (!rc) return 0;
1207 if (rc < 0) {errno = -rc; return -1;} // does the cache set this???
1208 cacheChk = true;
1209 }
1210
1211// Issue the stat and verify that all went well
1212//
1214 return EcStat(path, buf, admin);
1215
1216 if (!admin.Stat(*buf)) return -1;
1217
1218// If we are here and the cache was checked then the file was not in the cache.
1219// We informally tell the caller this is the case by setting atime to zero.
1220// Normally, atime will never be zero in any other case.
1221//
1222 if (cacheChk) buf->st_atime = 0;
1223 return 0;
1224}
virtual int Stat(const char *url, struct stat &sbuff)

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

Referenced by XrdPssFile::Fstat(), main(), XrdPssSys::Stat(), and XrdFfsPosix_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 1230 of file XrdPosixXrootd.cc.

1231{
1232 struct statvfs myVfs;
1233 int rc;
1234
1235// Issue a statvfs() call and transcribe the results
1236//
1237 if ((rc = Statvfs(path, &myVfs))) return rc;
1238
1239// The vfs structure and fs structures should be size compatible (not really)
1240//
1241 memset(buf, 0, sizeof(struct statfs));
1242 buf->f_bsize = myVfs.f_bsize;
1243 buf->f_blocks = myVfs.f_blocks;
1244 buf->f_bfree = myVfs.f_bfree;
1245 buf->f_files = myVfs.f_files;
1246 buf->f_ffree = myVfs.f_ffree;
1247#if defined(__APPLE__) || defined(__FreeBSD__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1248 buf->f_iosize = myVfs.f_frsize;
1249#else
1250 buf->f_frsize = myVfs.f_frsize;
1251#endif
1252#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1253 buf->f_bavail = myVfs.f_bavail;
1254#endif
1255#if defined(__linux__) || defined(__GNU__)
1256 buf->f_namelen = myVfs.f_namemax;
1257#elif defined(__FreeBSD__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1258 buf->f_namemax = myVfs.f_namemax;
1259#endif
1260 return 0;
1261}
#define statvfs(a, b)
Definition XrdPosix.hh:105
#define statfs(a, b)
Definition XrdPosix.hh:103
static int Statvfs(const char *path, struct statvfs *buf)
Statvfs() conforms to POSIX.1-2001 statvfs().

References statfs, Statvfs(), and statvfs.

Here is the call graph for this function:

◆ StatRet()

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

Definition at line 1267 of file XrdPosixXrootd.cc.

1268{
1269// Find the object
1270//
1271 auto fildes = XrdPosixDir::dirNo(dirp);
1272 auto dP = XrdPosixObject::Dir(fildes);
1273 if (!dP) return EBADF;
1274
1275// Get the stat info
1276 auto rc = dP->StatRet(buf);
1277
1278 dP->UnLock();
1279 return rc;
1280}

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

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

1287{
1288 static const int szVFS = sizeof(buf->f_bfree);
1289 static const long long max32 = 0x7fffffffLL;
1290
1291 XrdPosixAdmin admin(path,XrdPosixGlobals::ecMsg);
1292 XrdCl::StatInfoVFS *vfsStat;
1293
1294 long long rwFree, ssFree, rwBlks;
1295 int rwNum, ssNum, rwUtil, ssUtil;
1296
1297// Make sure we connected
1298//
1299 if (!admin.isOK()) return -1;
1300
1301// Issue the statfvs call
1302//
1303 if (XrdPosixMap::Result(admin.Xrd.StatVFS(admin.Url.GetPathWithParams(),
1304 vfsStat),
1305 XrdPosixGlobals::ecMsg) < 0) return -1;
1306
1307// Extract out the information
1308//
1309 rwNum = static_cast<int>(vfsStat->GetNodesRW());
1310 rwFree = (long long)vfsStat->GetFreeRW();
1311 rwUtil = static_cast<int>(vfsStat->GetUtilizationRW());
1312 ssNum = static_cast<int>(vfsStat->GetNodesStaging());
1313 ssFree = (long long)vfsStat->GetFreeStaging();
1314 ssUtil = static_cast<int>(vfsStat->GetUtilizationStaging());
1315 delete vfsStat;
1316
1317// Calculate number of blocks
1318//
1319 if (rwUtil == 0) rwBlks = rwFree;
1320 else if (rwUtil >= 100) rwBlks = 0;
1321 else rwBlks = rwFree * (100 / (100 - rwUtil));
1322 if (ssUtil == 0) rwBlks += ssFree;
1323 else if (ssUtil < 100) rwBlks += ssFree * (100 / (100 - ssUtil));
1324
1325// Scale units to what will fit here (we can have a 32-bit or 64-bit struct)
1326//
1327 if (szVFS < 8)
1328 {if (rwBlks > max32) rwBlks = max32;
1329 if (rwFree > max32) rwFree = max32;
1330 if (ssFree > max32) ssFree = max32;
1331 }
1332
1333// Return what little we can
1334//
1335 memset(buf, 0, sizeof(struct statvfs));
1336 buf->f_bsize = 1024*1024;
1337 buf->f_frsize = 1024*1024;
1338 buf->f_blocks = static_cast<fsblkcnt_t>(rwBlks);
1339 buf->f_bfree = static_cast<fsblkcnt_t>(rwFree + ssFree);
1340 buf->f_bavail = static_cast<fsblkcnt_t>(rwFree);
1341 buf->f_ffree = rwNum + ssNum;
1342 buf->f_favail = rwNum;
1343 buf->f_namemax = 255; // The best we are going to do here
1344 buf->f_flag = (rwNum == 0 ? ST_RDONLY|ST_NOSUID : ST_NOSUID);
1345 return 0;
1346}
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(), XrdCl::FileSystem::StatVFS(), statvfs, XrdPosixAdmin::Url, and XrdPosixAdmin::Xrd.

Referenced by Statfs().

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

1353{
1354 XrdPosixDir *dP;
1355 long pos;
1356 int fildes = XrdPosixDir::dirNo(dirp);
1357
1358// Find the object
1359//
1360 if (!(dP = XrdPosixObject::Dir(fildes)))
1361 return XrdPosixGlobals::ecMsg.SetErrno(EBADF,0);
1362
1363// Tell the current directory location
1364//
1365 pos = dP->getOffset();
1366 dP->UnLock();
1367 return pos;
1368}
long getOffset()

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

Here is the call 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 1374 of file XrdPosixXrootd.cc.

1375{
1376 XrdPosixAdmin admin(path,XrdPosixGlobals::ecMsg);
1377 uint64_t tSize = static_cast<uint64_t>(Size);
1378
1379// Make sure the admin is OK
1380//
1381 if (!admin.isOK()) return -1;
1382
1383// Truncate in the cache first
1384//
1386 {LfnPath trunc("truncate", path);
1387 if (!trunc.path) return -1;
1388 XrdPosixGlobals::theCache->Truncate(trunc.path, tSize);
1389 }
1390
1391// Issue the truncate to the origin
1392//
1393 std::string urlp = admin.Url.GetPathWithParams();
1394 return XrdPosixMap::Result(admin.Xrd.Truncate(urlp,tSize),
1396}
virtual int Truncate(const char *path, off_t size)

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

Referenced by XrdPssSys::Truncate(), and XrdFfsPosix_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 1402 of file XrdPosixXrootd.cc.

1403{
1404 XrdPosixAdmin admin(path,XrdPosixGlobals::ecMsg);
1405
1406// Make sure the admin is OK
1407//
1408 if (!admin.isOK()) return -1;
1409
1410// Unlink the cache first
1411//
1413 {LfnPath remf("unlink", path);
1414 if (!remf.path) return -1;
1416 }
1417
1418// Issue the UnLink
1419//
1421 return EcUnlink(path, admin);
1422
1423 return XrdPosixMap::Result(admin.Xrd.Rm(admin.Url.GetPathWithParams()),
1425}
virtual int Unlink(const char *path)

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

Referenced by XrdPssSys::Unlink(), and XrdFfsPosix_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 951 of file XrdPosixXrootd.cc.

952{
953 XrdPosixFile *fp;
954 ssize_t bytes;
955
956// Find the file object
957//
958 if (!(fp = XrdPosixObject::File(fildes))) return -1;
959
960// Issue the read
961//
962 if ((bytes = fp->XCio->ReadV(readV, n)) < 0) return Fault(fp,-bytes);
963
964// Return bytes read
965//
966 fp->UnLock();
967 return bytes;
968}
virtual int ReadV(const XrdOucIOVec *readV, int rnum)

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

974{
975 XrdPosixFile *fp;
976
977// Find the file object and issue read
978//
979 if ((fp = XrdPosixObject::File(fildes)))
980 {cbp->theFile = fp;
981 fp->Ref(); fp->UnLock();
982 fp->XCio->ReadV(*cbp, readV, n);
983 } else cbp->Complete(-1);
984}

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

1432{
1433 XrdPosixFile *fp;
1434 int iosz, bytes;
1435
1436// Find the file object
1437//
1438 if (!(fp = XrdPosixObject::File(fildes))) return -1;
1439
1440// Make sure the size is not too large
1441//
1442 if (nbyte > (size_t)0x7fffffff) return Fault(fp,EOVERFLOW);
1443 else iosz = static_cast<int>(nbyte);
1444
1445// Issue the write
1446//
1447 bytes = fp->XCio->Write((char *)buf,fp->Offset(),(int)iosz);
1448 if (bytes < 0) return Fault(fp,-bytes);
1449
1450// All went well
1451//
1452 fp->addOffset(iosz, 1);
1453 fp->UnLock();
1454 return (ssize_t)iosz;
1455}

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

Referenced by Writev(), and XrdFfsPosix_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 1461 of file XrdPosixXrootd.cc.

1462{
1463 ssize_t totbytes = 0;
1464 int i;
1465
1466// Return the results of the write for each iov segment
1467//
1468 for (i = 0; i < iovcnt; i++)
1469 {if (!Write(fildes,(void *)iov[i].iov_base,(size_t)iov[i].iov_len))
1470 return -1;
1471 totbytes += iov[i].iov_len;
1472 }
1473
1474// All done
1475//
1476 return totbytes;
1477}
static ssize_t Write(int fildes, const void *buf, size_t nbyte)
Write() conforms to POSIX.1-2001 write().

References Write().

Here is the call graph for this function:

◆ XrdPosixConfig

friend class XrdPosixConfig
friend

Definition at line 66 of file XrdPosixXrootd.hh.

References XrdPosixConfig.

Referenced by XrdPosixConfig.

◆ XrdPosixExtra

friend class XrdPosixExtra
friend

Definition at line 67 of file XrdPosixXrootd.hh.

References XrdPosixExtra.

Referenced by XrdPosixExtra.

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 186 of file XrdPosixXrootd.hh.

Referenced by XrdPosix_Fopen().


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