XRootD
XrdPosix.cc File Reference
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <limits.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/uio.h>
#include "XrdSys/XrdSysHeaders.hh"
#include "XrdPosix/XrdPosixLinkage.hh"
#include "XrdPosix/XrdPosixXrootd.hh"
#include "XrdPosix/XrdPosixXrootdPath.hh"
#include "XrdSys/XrdSysStatx.hh"
+ Include dependency graph for XrdPosix.cc:

Go to the source code of this file.

Macros

#define ISMODE(x)   !strcmp(mode, x)
 

Functions

static void fseteof (FILE *fp)
 
static void fseterr (FILE *fp)
 
int XrdPosix_Access (const char *path, int amode)
 
int XrdPosix_Acl (const char *path, int cmd, int nentries, void *aclbufp)
 
int XrdPosix_Chdir (const char *path)
 
int XrdPosix_Close (int fildes)
 
int XrdPosix_Closedir (DIR *dirp)
 
int XrdPosix_Creat (const char *path, mode_t mode)
 
int XrdPosix_Fclose (FILE *stream)
 
int XrdPosix_Fcntl (int fd, int cmd,...)
 
int XrdPosix_Fdatasync (int fildes)
 
int XrdPosix_Fflush (FILE *stream)
 
FILE * XrdPosix_Fopen (const char *path, const char *mode)
 
size_t XrdPosix_Fread (void *ptr, size_t size, size_t nitems, FILE *stream)
 
int XrdPosix_Fseek (FILE *stream, long offset, int whence)
 
int XrdPosix_Fseeko (FILE *stream, long long offset, int whence)
 
int XrdPosix_Fstat (int fildes, struct stat *buf)
 
int XrdPosix_Fstatat (int dirfd, const char *path, struct stat *buf, int flags)
 
int XrdPosix_FstatV (int ver, int fildes, struct stat *buf)
 
int XrdPosix_Fsync (int fildes)
 
long XrdPosix_Ftell (FILE *stream)
 
long long XrdPosix_Ftello (FILE *stream)
 
int XrdPosix_Ftruncate (int fildes, long long offset)
 
size_t XrdPosix_Fwrite (const void *ptr, size_t size, size_t nitems, FILE *stream)
 
int XrdPosix_isMyPath (const char *path)
 
off_t XrdPosix_Lseek (int fildes, off_t offset, int whence)
 
int XrdPosix_Lstat (const char *path, struct stat *buf)
 
int XrdPosix_Mkdir (const char *path, mode_t mode)
 
int XrdPosix_Open (const char *path, int oflag,...)
 
int XrdPosix_Openat (int dirfd, const char *path, int flag,...)
 
DIR * XrdPosix_Opendir (const char *path)
 
long XrdPosix_Pathconf (const char *path, int name)
 
ssize_t XrdPosix_Pread (int fildes, void *buf, size_t nbyte, off_t offset)
 
ssize_t XrdPosix_Pwrite (int fildes, const void *buf, size_t nbyte, off_t offset)
 
ssize_t XrdPosix_Read (int fildes, void *buf, size_t nbyte)
 
struct dirent * XrdPosix_Readdir (DIR *dirp)
 
struct dirent64 * XrdPosix_Readdir64 (DIR *dirp)
 
int XrdPosix_Readdir64_r (DIR *dirp, struct dirent64 *entry, struct dirent64 **result)
 
int XrdPosix_Readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result)
 
ssize_t XrdPosix_Readv (int fildes, const struct iovec *iov, int iovcnt)
 
int XrdPosix_Rename (const char *oldpath, const char *newpath)
 
void XrdPosix_Rewinddir (DIR *dirp)
 
int XrdPosix_Rmdir (const char *path)
 
void XrdPosix_Seekdir (DIR *dirp, long loc)
 
int XrdPosix_Stat (const char *path, struct stat *buf)
 
int XrdPosix_Statfs (const char *path, struct statfs *buf)
 
int XrdPosix_Statvfs (const char *path, struct statvfs *buf)
 
int XrdPosix_Statx (int dirfd, const char *path, int flags, unsigned int mask, XrdSysStatx *stx)
 
long XrdPosix_Telldir (DIR *dirp)
 
int XrdPosix_Truncate (const char *path, off_t offset)
 
int XrdPosix_Unlink (const char *path)
 
char * XrdPosix_URL (const char *path, char *buff, int blen)
 
ssize_t XrdPosix_Write (int fildes, const void *buf, size_t nbyte)
 
ssize_t XrdPosix_Writev (int fildes, const struct iovec *iov, int iovcnt)
 
static ssize_t XrdResolveLink (const char *path, char *resolved, size_t rsize)
 

Variables

XrdPosixXrootd Xroot
 
XrdPosixXrootPath XrootPath
 
XrdPosixLinkage Xunix
 

Macro Definition Documentation

◆ ISMODE

#define ISMODE (   x)    !strcmp(mode, x)

Definition at line 362 of file XrdPosix.cc.

Function Documentation

◆ fseteof()

static void fseteof ( FILE *  fp)
inlinestatic

Definition at line 90 of file XrdPosix.cc.

91 {
92  /* Most systems provide FILE as a struct and the necessary bitmask in
93  <stdio.h>, because they need it for implementing getc() and putc() as
94  fast macros. */
95 #if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
96  /* GNU libc, BeOS, Haiku, Linux libc5 */
97  fp->_flags |= _IO_EOF_SEEN;
98 #elif defined __sferror || defined __APPLE__ || defined __DragonFly__ || defined __ANDROID__
99  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
100  fp->_flags |= __SEOF;
101 #elif defined _IOEOF
102  /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
103  fp->_flag |= _IOEOF;
104 #elif defined __UCLIBC__ /* uClibc */
105  fp->__modeflags |= __FLAG_EOF;
106 #else
107  (void) fseek(fp, 0L, SEEK_END);
108 #endif
109 }
int fseek(FILE *stream, long offset, int whence)

References fseek().

Referenced by XrdPosix_Fread().

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

◆ fseterr()

static void fseterr ( FILE *  fp)
inlinestatic

Definition at line 67 of file XrdPosix.cc.

68 {
69  /* Most systems provide FILE as a struct and the necessary bitmask in
70  <stdio.h>, because they need it for implementing getc() and putc() as
71  fast macros. This function is based on gnulib's fseterr.c */
72 #if defined _IO_ERR_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
73  /* GNU libc, BeOS, Haiku, Linux libc5 */
74  fp->_flags |= _IO_ERR_SEEN;
75 #elif defined __sferror || defined __APPLE__ || defined __DragonFly__ || defined __FreeBSD__ || defined __ANDROID__
76  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
77  fp->_flags |= __SERR;
78 #elif defined _IOERR
79  /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
80  fp->_flag |= _IOERR;
81 #elif defined __UCLIBC__ /* uClibc */
82  fp->__modeflags |= __FLAG_ERROR;
83 #elif defined MUSL /* musl libc */
84  __fseterr(fp);
85 #else
86  #error "Unsupported platform! Please report it as a bug."
87 #endif
88 }

Referenced by XrdPosix_Fread(), and XrdPosix_Fwrite().

+ Here is the caller graph for this function:

◆ XrdPosix_Access()

int XrdPosix_Access ( const char *  path,
int  amode 
)

Definition at line 165 of file XrdPosix.cc.

166 {
167  char *myPath, buff[2048];
168  char unref[2049];
169 
170  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
171  if (res > 0) {
172  // Return the results of a mkdir of a Unix file system
173  //
174  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
175  return Xunix.Access( path, amode);
176 
177  // Return the results of our version of access()
178  //
179  return Xroot.Access(myPath, amode);
180  } else {
181  return res;
182  }
183 }
XrdPosixXrootd Xroot
Definition: XrdPosix.cc:53
static ssize_t XrdResolveLink(const char *path, char *resolved, size_t rsize)
Definition: XrdPosix.cc:114
XrdPosixXrootPath XrootPath
Definition: XrdPosix.cc:55
XrdPosixLinkage Xunix
Retv_Access(* Access)(Args_Access)
char * URL(const char *path, char *buff, int blen)
static int Access(const char *path, int amode)
Access() conforms to POSIX.1-2001 access()

References XrdPosixXrootd::Access(), XrdPosixLinkage::Access, XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, XrootPath, and Xunix.

Referenced by access().

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

◆ XrdPosix_Acl()

int XrdPosix_Acl ( const char *  path,
int  cmd,
int  nentries,
void *  aclbufp 
)

Definition at line 194 of file XrdPosix.cc.

195 {
196  char unref[2049];
197 
198  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
199  if (res < 0) return res;
200  return (XrootPath.URL(unref, 0, 0)
201  ? Xunix.Acl("/tmp", cmd,nentries,aclbufp)
202  : Xunix.Acl(path, cmd,nentries,aclbufp));
203 }
Retv_Acl(* Acl)(Args_Acl)

References XrdPosixLinkage::Acl, XrdPosixXrootPath::URL(), XrdResolveLink(), XrootPath, and Xunix.

Referenced by acl().

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

◆ XrdPosix_Chdir()

int XrdPosix_Chdir ( const char *  path)

Definition at line 212 of file XrdPosix.cc.

213 {
214  int rc;
215  char unref[2049];
216 
217  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
218  if (res < 0) return res;
219 
220  // Set the working directory if the actual chdir succeeded
221  //
222  if (!(rc = Xunix.Chdir(path))) XrootPath.CWD(unref);
223  return rc;
224 }
Retv_Chdir(* Chdir)(Args_Chdir)
void CWD(const char *path)

References XrdPosixLinkage::Chdir, XrdPosixXrootPath::CWD(), XrdResolveLink(), XrootPath, and Xunix.

Referenced by chdir().

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

◆ XrdPosix_Close()

int XrdPosix_Close ( int  fildes)

Definition at line 233 of file XrdPosix.cc.

234 {
235 
236 // Return result of the close
237 //
238  return (Xroot.myFD(fildes) ? Xroot.Close(fildes) : Xunix.Close(fildes));
239 }
Retv_Close(* Close)(Args_Close)
static int Close(int fildes)
Close() conforms to POSIX.1-2001 close()
static bool myFD(int fd)

References XrdPosixXrootd::Close(), XrdPosixLinkage::Close, XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by close().

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

◆ XrdPosix_Closedir()

int XrdPosix_Closedir ( DIR *  dirp)

Definition at line 248 of file XrdPosix.cc.

249 {
250 
251  return (Xroot.isXrootdDir(dirp) ? Xroot.Closedir(dirp)
252  : Xunix.Closedir(dirp));
253 }
Retv_Closedir(* Closedir)(Args_Closedir)
static int Closedir(DIR *dirp)
Closedir() conforms to POSIX.1-2001 closedir()
static bool isXrootdDir(DIR *dirp)

References XrdPosixXrootd::Closedir(), XrdPosixLinkage::Closedir, XrdPosixXrootd::isXrootdDir(), Xroot, and Xunix.

Referenced by closedir().

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

◆ XrdPosix_Creat()

int XrdPosix_Creat ( const char *  path,
mode_t  mode 
)

Definition at line 262 of file XrdPosix.cc.

263 {
264  extern int XrdPosix_Open(const char *path, int oflag, ...);
265 
266  return XrdPosix_Open(path, O_WRONLY | O_CREAT | O_TRUNC, mode);
267 }
int XrdPosix_Open(const char *path, int oflag,...)
Definition: XrdPosix.cc:760

References XrdPosix_Open().

Referenced by creat64().

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

◆ XrdPosix_Fclose()

int XrdPosix_Fclose ( FILE *  stream)

Definition at line 276 of file XrdPosix.cc.

277 {
278  int nullfd = fileno(stream);
279 
280 // Close the associated file
281 //
282  if (Xroot.myFD(nullfd)) Xroot.Close(nullfd);
283 
284 // Now close the stream
285 //
286  return Xunix.Fclose(stream);
287 }
Retv_Fclose(* Fclose)(Args_Fclose)

References XrdPosixXrootd::Close(), XrdPosixLinkage::Fclose, XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by fclose().

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

◆ XrdPosix_Fcntl()

int XrdPosix_Fcntl ( int  fd,
int  cmd,
  ... 
)

Definition at line 296 of file XrdPosix.cc.

297 {
298  va_list ap;
299  void *theArg;
300 
301  if (Xroot.myFD(fd)) return 0;
302  va_start(ap, cmd);
303  theArg = va_arg(ap, void *);
304  va_end(ap);
305  return Xunix.Fcntl64(fd, cmd, theArg);
306 }
Retv_Fcntl64(* Fcntl64)(Args_Fcntl64)

References XrdPosixLinkage::Fcntl64, XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by fcntl64().

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

◆ XrdPosix_Fdatasync()

int XrdPosix_Fdatasync ( int  fildes)

Definition at line 315 of file XrdPosix.cc.

316 {
317 
318 // Return the result of the sync
319 //
320  return (Xroot.myFD(fildes) ? Xroot.Fsync(fildes)
321  : Xunix.Fsync(fildes));
322 }
Retv_Fsync(* Fsync)(Args_Fsync)
static int Fsync(int fildes)
Fsync() conforms to POSIX.1-2001 fsync()

References XrdPosixXrootd::Fsync(), XrdPosixLinkage::Fsync, XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by fdatasync().

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

◆ XrdPosix_Fflush()

int XrdPosix_Fflush ( FILE *  stream)

Definition at line 346 of file XrdPosix.cc.

347 {
348 
349 // Return the result of the fseek
350 //
351  if (!stream || !Xroot.myFD(fileno(stream)))
352  return Xunix.Fflush(stream);
353 
354  return Xroot.Fsync(fileno(stream));
355 }
Retv_Fflush(* Fflush)(Args_Fflush)

References XrdPosixLinkage::Fflush, XrdPosixXrootd::Fsync(), XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by fflush().

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

◆ XrdPosix_Fopen()

FILE* XrdPosix_Fopen ( const char *  path,
const char *  mode 
)

Definition at line 366 of file XrdPosix.cc.

367 {
368  char *myPath, buff[2048];
369  int erc, fd, omode;
370  FILE *stream;
371 
372  char unref[2049];
373 
374  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
375  if (res < 0) return 0;
376 
377 // Transfer to unix if this is not our path
378 //
379  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
380  return Xunix.Fopen64(path, mode);
381 
382 // Translate the mode flags
383 //
384  if (ISMODE("r") || ISMODE("rb")) omode = O_RDONLY;
385  else if (ISMODE("w") || ISMODE("wb")) omode = O_WRONLY
386  | O_CREAT | O_TRUNC;
387  else if (ISMODE("a") || ISMODE("ab")) omode = O_WRONLY
388  | O_CREAT | O_APPEND;
389  else if (ISMODE("r+") || ISMODE("rb+") || ISMODE("r+b")) omode = O_RDWR;
390  else if (ISMODE("w+") || ISMODE("wb+") || ISMODE("w+b")) omode = O_RDWR
391  | O_CREAT | O_TRUNC;
392  else if (ISMODE("a+") || ISMODE("ab+") || ISMODE("a+b")) omode = O_RDWR
393  | O_CREAT | O_APPEND;
394  else {errno = EINVAL; return 0;}
395 
396 // Now open the file
397 //
398  if ((fd = Xroot.Open(myPath, omode | XrdPosixXrootd::isStream , 0)) < 0)
399  return 0;
400 
401 // First obtain a free stream
402 //
403  if (!(stream = fdopen(fd, mode)))
404  {erc = errno; Xroot.Close(fd); errno = erc;}
405 
406 // All done
407 //
408  return stream;
409 }
#define ISMODE(x)
Definition: XrdPosix.cc:362
Retv_Fopen64(* Fopen64)(Args_Fopen64)
static const int isStream
static int Open(const char *path, int oflag, mode_t mode=0, XrdPosixCallBack *cbP=0)

References XrdPosixXrootd::Close(), XrdPosixLinkage::Fopen64, ISMODE, XrdPosixXrootd::isStream, XrdPosixXrootd::Open(), XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, XrootPath, and Xunix.

Referenced by fopen64().

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

◆ XrdPosix_Fread()

size_t XrdPosix_Fread ( void *  ptr,
size_t  size,
size_t  nitems,
FILE *  stream 
)

Definition at line 418 of file XrdPosix.cc.

419 {
420  ssize_t bytes;
421  size_t rc = 0;
422  int fd = fileno(stream);
423 
424  if (!Xroot.myFD(fd)) return Xunix.Fread(ptr, size, nitems, stream);
425 
426  bytes = Xroot.Read(fd, ptr, size*nitems);
427 
428 // Get the right return code. Note that we cannot emulate the flags in sunx86
429 //
430  if (bytes > 0 && size) rc = bytes/size;
431  else if (bytes < 0) fseterr(stream);
432  else fseteof(stream);
433 
434  return rc;
435 }
static void fseterr(FILE *fp)
Definition: XrdPosix.cc:67
static void fseteof(FILE *fp)
Definition: XrdPosix.cc:90
Retv_Fread(* Fread)(Args_Fread)
static ssize_t Read(int fildes, void *buf, size_t nbyte)
Read() conforms to POSIX.1-2001 read()

References XrdPosixLinkage::Fread, fseteof(), fseterr(), XrdPosixXrootd::myFD(), XrdPosixXrootd::Read(), Xroot, and Xunix.

Referenced by fread().

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

◆ XrdPosix_Fseek()

int XrdPosix_Fseek ( FILE *  stream,
long  offset,
int  whence 
)

Definition at line 444 of file XrdPosix.cc.

445 {
446 
447 // Return the result of the fseek
448 //
449  if (!Xroot.myFD(fileno(stream)))
450  return Xunix.Fseek( stream, offset, whence);
451 
452  return (Xroot.Lseek(fileno(stream), offset, whence) < 0 ? -1 : 0);
453 }
Retv_Fseek(* Fseek)(Args_Fseek)
static off_t Lseek(int fildes, off_t offset, int whence)
Lseek() conforms to POSIX.1-2001 lseek()

References XrdPosixLinkage::Fseek, XrdPosixXrootd::Lseek(), XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by fseek().

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

◆ XrdPosix_Fseeko()

int XrdPosix_Fseeko ( FILE *  stream,
long long  offset,
int  whence 
)

Definition at line 462 of file XrdPosix.cc.

463 {
464 
465 // Return the result of the fseek
466 //
467  if (!Xroot.myFD(fileno(stream)))
468  return Xunix.Fseeko64(stream, offset, whence);
469 
470  return (Xroot.Lseek(fileno(stream), offset, whence) < 0 ? -1 : 0);
471 }
Retv_Fseeko64(* Fseeko64)(Args_Fseeko64)

References XrdPosixLinkage::Fseeko64, XrdPosixXrootd::Lseek(), XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by fseeko64().

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

◆ XrdPosix_Fstat()

int XrdPosix_Fstat ( int  fildes,
struct stat buf 
)

Definition at line 480 of file XrdPosix.cc.

481  {
482  if (Xroot.myFD(fildes)){
483  return(Xroot.Fstat(fildes, buf));
484  } else {
485 #ifdef SYS_fstat
486  return syscall(SYS_fstat, fildes, buf);
487 #else
488  errno = ENOSYS;
489  return -1;
490 #endif
491  }
492  }
static int Fstat(int fildes, struct stat *buf)
Fstat() conforms to POSIX.1-2001 fstat()

References XrdPosixXrootd::Fstat(), XrdPosixXrootd::myFD(), and Xroot.

Referenced by fstat64().

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

◆ XrdPosix_Fstatat()

int XrdPosix_Fstatat ( int  dirfd,
const char *  path,
struct stat buf,
int  flags 
)

Definition at line 514 of file XrdPosix.cc.

515 {
516  if (path && *path) {
517  char buff[2048];
518  char unref[2049];
519 
520  if (!(flags & AT_SYMLINK_NOFOLLOW)) {
521  // We need to follow until path is no longer a link
522  ssize_t res = XrdResolveLink(path, unref, sizeof(unref));
523  if (res < 0) return res;
524  // links are pointing to file unref now which is not a link
525  } else {
526  strncpy(unref, path, 2048);
527  }
528  if (char *myPath = XrootPath.URL(unref, buff, sizeof(buff))) {
529  int ret = Xroot.Stat(myPath, (struct stat *)buf);
530  return (ret);
531  } else {
532  // not a root file
533 #ifdef SYS_newfstatat
534  return syscall(SYS_newfstatat, dirfd, path, buf, flags);
535 #else
536 #ifdef SYS_fstatat
537  return syscall(SYS_fstatat, dirfd, path, buf, flags);
538 #else
539  errno = ENOSYS;
540  return -1;
541 #endif
542 #endif
543  }
544  } else {
545  errno = EFAULT;
546  }
547  return -1;
548 }
#define stat(a, b)
Definition: XrdPosix.hh:105
#define dirfd(x)
static int Stat(const char *path, struct stat *buf)
Stat() conforms to POSIX.1-2001 stat()

References dirfd, stat, XrdPosixXrootd::Stat(), XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, and XrootPath.

Referenced by fstatat64().

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

◆ XrdPosix_FstatV()

int XrdPosix_FstatV ( int  ver,
int  fildes,
struct stat buf 
)

Definition at line 493 of file XrdPosix.cc.

494  {
495  if (Xroot.myFD(fildes)){
496  return(Xroot.Fstat(fildes, buf));
497  } else {
498 #ifdef SYS_fstat
499  return syscall(SYS_fstat, fildes, buf);
500 #else
501  errno = ENOSYS;
502  return -1;
503 #endif
504  }
505  }

References XrdPosixXrootd::Fstat(), XrdPosixXrootd::myFD(), and Xroot.

Referenced by fstat64().

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

◆ XrdPosix_Fsync()

int XrdPosix_Fsync ( int  fildes)

Definition at line 557 of file XrdPosix.cc.

558 {
559 
560 // Return the result of the sync
561 //
562  return (Xroot.myFD(fildes) ? Xroot.Fsync(fildes)
563  : Xunix.Fsync(fildes));
564 }

References XrdPosixXrootd::Fsync(), XrdPosixLinkage::Fsync, XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by fsync().

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

◆ XrdPosix_Ftell()

long XrdPosix_Ftell ( FILE *  stream)

Definition at line 573 of file XrdPosix.cc.

574 {
575 
576 // Return the result of the tell
577 //
578  if (!Xroot.myFD(fileno(stream))) return Xunix.Ftell(stream);
579 
580  return static_cast<long>(Xroot.Lseek(fileno(stream), 0, SEEK_CUR));
581 }
Retv_Ftell(* Ftell)(Args_Ftell)

References XrdPosixLinkage::Ftell, XrdPosixXrootd::Lseek(), XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by ftell().

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

◆ XrdPosix_Ftello()

long long XrdPosix_Ftello ( FILE *  stream)

Definition at line 590 of file XrdPosix.cc.

591 {
592 
593 // Return the result of the tell
594 //
595  if (!Xroot.myFD(fileno(stream))) return Xunix.Ftello64(stream);
596 
597  return Xroot.Lseek(fileno(stream), 0, SEEK_CUR);
598 }
Retv_Ftello64(* Ftello64)(Args_Ftello64)

References XrdPosixLinkage::Ftello64, XrdPosixXrootd::Lseek(), XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by ftello64().

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

◆ XrdPosix_Ftruncate()

int XrdPosix_Ftruncate ( int  fildes,
long long  offset 
)

Definition at line 607 of file XrdPosix.cc.

608 {
609 
610 // Return the result of the ftruncate
611 //
612  return (Xroot.myFD(fildes) ? Xroot.Ftruncate (fildes, offset)
613  : Xunix.Ftruncate64(fildes, offset));
614 }
Retv_Ftruncate64(* Ftruncate64)(Args_Ftruncate64)
static int Ftruncate(int fildes, off_t offset)
Ftruncate() conforms to POSIX.1-2001 ftruncate()

References XrdPosixXrootd::Ftruncate(), XrdPosixLinkage::Ftruncate64, XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by ftruncate64().

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

◆ XrdPosix_Fwrite()

size_t XrdPosix_Fwrite ( const void *  ptr,
size_t  size,
size_t  nitems,
FILE *  stream 
)

Definition at line 623 of file XrdPosix.cc.

624 {
625  size_t bytes, rc = 0;
626  int fd = fileno(stream);
627 
628  if (!Xroot.myFD(fd)) return Xunix.Fwrite(ptr, size, nitems, stream);
629 
630  bytes = Xroot.Write(fd, ptr, size*nitems);
631 
632 // Get the right return code.
633 //
634  if (bytes > 0 && size) rc = bytes/size;
635  else fseterr(stream);
636 
637  return rc;
638 }
Retv_Fwrite(* Fwrite)(Args_Fwrite)
static ssize_t Write(int fildes, const void *buf, size_t nbyte)
Write() conforms to POSIX.1-2001 write()

References fseterr(), XrdPosixLinkage::Fwrite, XrdPosixXrootd::myFD(), XrdPosixXrootd::Write(), Xroot, and Xunix.

Referenced by fwrite().

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

◆ XrdPosix_isMyPath()

int XrdPosix_isMyPath ( const char *  path)

Definition at line 1287 of file XrdPosix.cc.

1288 {
1289  return (0 != XrootPath.URL(path, 0, 0));
1290 }

References XrdPosixXrootPath::URL(), and XrootPath.

+ Here is the call graph for this function:

◆ XrdPosix_Lseek()

off_t XrdPosix_Lseek ( int  fildes,
off_t  offset,
int  whence 
)

Definition at line 689 of file XrdPosix.cc.

690 {
691 
692 // Return the operation of the seek
693 //
694  return (Xroot.myFD(fildes) ? Xroot.Lseek (fildes, offset, whence)
695  : Xunix.Lseek64(fildes, offset, whence));
696 }
Retv_Lseek64(* Lseek64)(Args_Lseek64)

References XrdPosixXrootd::Lseek(), XrdPosixLinkage::Lseek64, XrdPosixXrootd::myFD(), Xroot, and Xunix.

Referenced by llseek(), and lseek64().

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

◆ XrdPosix_Lstat()

int XrdPosix_Lstat ( const char *  path,
struct stat buf 
)

Definition at line 705 of file XrdPosix.cc.

706 {
707  char *myPath, buff[2048];
708 
709 // Make sure a path was passed
710 //
711  if (!path) {errno = EFAULT; return -1;}
712 
713 // Return the results of an open of a Unix file
714 //
715  myPath = XrootPath.URL(path, buff, sizeof(buff));
716  if (myPath){
717  return Xroot.Stat(myPath, buf);
718  } else {
719 #ifdef SYS_lstat
720  return syscall(SYS_lstat, path, buf);
721 #else
722  errno = ENOSYS;
723  return -1;
724 #endif
725  }
726 }

References XrdPosixXrootd::Stat(), XrdPosixXrootPath::URL(), Xroot, and XrootPath.

Referenced by lstat64().

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

◆ XrdPosix_Mkdir()

int XrdPosix_Mkdir ( const char *  path,
mode_t  mode 
)

Definition at line 735 of file XrdPosix.cc.

736 {
737  char *myPath, buff[2048];
738  char unref[2049];
739 
740  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
741  if (res < 0) return res;
742 
743 // Return the results of a mkdir of a Unix file system
744 //
745  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
746  return Xunix.Mkdir(path, mode);
747 
748 // Return the results of an mkdir of an xrootd file system
749 //
750  return Xroot.Mkdir(myPath, mode);
751 }
Retv_Mkdir(* Mkdir)(Args_Mkdir)
static int Mkdir(const char *path, mode_t mode)
Mkdir() conforms to POSIX.1-2001 mkdir()

References XrdPosixXrootd::Mkdir(), XrdPosixLinkage::Mkdir, XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, XrootPath, and Xunix.

Referenced by mkdir().

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

◆ XrdPosix_Open()

int XrdPosix_Open ( const char *  path,
int  oflag,
  ... 
)

Definition at line 760 of file XrdPosix.cc.

761 {
762  char *myPath, buff[2048];
763  char unref[2049];
764  va_list ap;
765  int mode;
766  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
767  if (res < 0) return res;
768  // Return the results of an open of a Unix file
769  //
770  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
771  {if (!(oflag & O_CREAT)) return Xunix.Open64(unref, oflag);
772  va_start(ap, oflag);
773  mode = va_arg(ap, int);
774  va_end(ap);
775  return Xunix.Open64(unref, oflag, (mode_t)mode);
776  }
777 
778  // Return the results of an open of an xrootd file
779  //
780  if (!(oflag & O_CREAT)) return Xroot.Open(myPath, oflag);
781  va_start(ap, oflag);
782  mode = va_arg(ap, int);
783  va_end(ap);
784  return Xroot.Open(myPath, oflag, (mode_t)mode);
785 }
Retv_Open64(* Open64)(Args_Open64)

References XrdPosixXrootd::Open(), XrdPosixLinkage::Open64, XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, XrootPath, and Xunix.

Referenced by open64(), and XrdPosix_Creat().

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

◆ XrdPosix_Openat()

int XrdPosix_Openat ( int  dirfd,
const char *  path,
int  flag,
  ... 
)

Definition at line 794 of file XrdPosix.cc.

795 {
796  char *myPath, buff[2048];
797  char unref[2049];
798  va_list ap;
799  int mode;
800  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
801  if (res < 0) return res;
802 
803  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff)))){
804  mode_t mode = 0;
805  if (flag & (O_CREAT)) {
806  va_start(ap, flag);
807  mode = va_arg(ap, int);
808  va_end(ap);
809  }
810 #ifdef SYS_openat
811  return (syscall(SYS_openat, dirfd, path, flag, (mode_t)mode));
812 #else
813  errno = ENOSYS;
814  return -1;
815 #endif
816  } else {
817  // Return the results of an open of an xrootd file
818  //
819  if (!(flag & O_CREAT)) return Xroot.Open(myPath, flag);
820  va_start(ap, flag);
821  mode = va_arg(ap, int);
822  va_end(ap);
823  return Xroot.Open(myPath, flag, (mode_t)mode);
824  }
825 }

References dirfd, XrdPosixXrootd::Open(), XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, and XrootPath.

Referenced by openat().

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

◆ XrdPosix_Opendir()

DIR* XrdPosix_Opendir ( const char *  path)

Definition at line 834 of file XrdPosix.cc.

835 {
836  char *myPath, buff[2048];
837  char unref[2049];
838 
839  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
840  if (res < 0) return NULL;
841 
842 // Unix opendir
843 //
844  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
845  return Xunix.Opendir(path);
846 
847 // Xrootd opendir
848 //
849  return Xroot.Opendir(myPath);
850 }
Retv_Opendir(* Opendir)(Args_Opendir)
static DIR * Opendir(const char *path)
Opendir() conforms to POSIX.1-2001 opendir()

References XrdPosixXrootd::Opendir(), XrdPosixLinkage::Opendir, XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, XrootPath, and Xunix.

Referenced by opendir().

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

◆ XrdPosix_Pathconf()

long XrdPosix_Pathconf ( const char *  path,
int  name 
)

Definition at line 861 of file XrdPosix.cc.

862 {
863  char unref[2049];
864 
865  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
866  if (res < 0) return res;
867 
868  return (XrootPath.URL(unref, 0, 0) ? Xunix.Pathconf("/tmp", name)
869  : Xunix.Pathconf(unref, name));
870 }
Retv_Pathconf(* Pathconf)(Args_Pathconf)

References XrdPosixLinkage::Pathconf, XrdPosixXrootPath::URL(), XrdResolveLink(), XrootPath, and Xunix.

Referenced by pathconf().

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

◆ XrdPosix_Pread()

ssize_t XrdPosix_Pread ( int  fildes,
void *  buf,
size_t  nbyte,
off_t  offset 
)

Definition at line 879 of file XrdPosix.cc.

880 {
881 
882 // Return the results of the read
883 //
884  return (Xroot.myFD(fildes) ? Xroot.Pread (fildes, buf, nbyte, offset)
885  : Xunix.Pread64(fildes, buf, nbyte, offset));
886 }
Retv_Pread64(* Pread64)(Args_Pread64)
static ssize_t Pread(int fildes, void *buf, size_t nbyte, off_t offset)
Pread() conforms to POSIX.1-2001 pread()

References XrdPosixXrootd::myFD(), XrdPosixXrootd::Pread(), XrdPosixLinkage::Pread64, Xroot, and Xunix.

Referenced by pread64().

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

◆ XrdPosix_Pwrite()

ssize_t XrdPosix_Pwrite ( int  fildes,
const void *  buf,
size_t  nbyte,
off_t  offset 
)

Definition at line 895 of file XrdPosix.cc.

896 {
897 
898 // Return the results of the write
899 //
900  return (Xroot.myFD(fildes) ? Xroot.Pwrite (fildes, buf, nbyte, offset)
901  : Xunix.Pwrite64(fildes, buf, nbyte, offset));
902 }
Retv_Pwrite64(* Pwrite64)(Args_Pwrite64)
static ssize_t Pwrite(int fildes, const void *buf, size_t nbyte, off_t offset)
Pwrite() conforms to POSIX.1-2001 pwrite()

References XrdPosixXrootd::myFD(), XrdPosixXrootd::Pwrite(), XrdPosixLinkage::Pwrite64, Xroot, and Xunix.

Referenced by pwrite64().

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

◆ XrdPosix_Read()

ssize_t XrdPosix_Read ( int  fildes,
void *  buf,
size_t  nbyte 
)

Definition at line 911 of file XrdPosix.cc.

912 {
913 
914 // Return the results of the read
915 //
916  return (Xroot.myFD(fildes) ? Xroot.Read(fildes, buf, nbyte)
917  : Xunix.Read(fildes, buf, nbyte));
918 }
Retv_Read(* Read)(Args_Read)

References XrdPosixXrootd::myFD(), XrdPosixXrootd::Read(), XrdPosixLinkage::Read, Xroot, and Xunix.

Referenced by read().

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

◆ XrdPosix_Readdir()

struct dirent* XrdPosix_Readdir ( DIR *  dirp)

Definition at line 945 of file XrdPosix.cc.

946 {
947 
948 // Return result of readdir
949 //
950  return (Xroot.isXrootdDir(dirp) ? Xroot.Readdir(dirp)
951  : Xunix.Readdir(dirp));
952 }
Retv_Readdir(* Readdir)(Args_Readdir)
static struct dirent * Readdir(DIR *dirp)

References XrdPosixXrootd::isXrootdDir(), XrdPosixXrootd::Readdir(), XrdPosixLinkage::Readdir, Xroot, and Xunix.

+ Here is the call graph for this function:

◆ XrdPosix_Readdir64()

struct dirent64* XrdPosix_Readdir64 ( DIR *  dirp)

Definition at line 954 of file XrdPosix.cc.

955 {
956 
957 // Return result of readdir
958 //
959  return (Xroot.isXrootdDir(dirp) ? Xroot.Readdir64(dirp)
960  : Xunix.Readdir64(dirp));
961 }
Retv_Readdir64(* Readdir64)(Args_Readdir64)
static struct dirent64 * Readdir64(DIR *dirp)

References XrdPosixXrootd::isXrootdDir(), XrdPosixXrootd::Readdir64(), XrdPosixLinkage::Readdir64, Xroot, and Xunix.

Referenced by readdir64().

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

◆ XrdPosix_Readdir64_r()

int XrdPosix_Readdir64_r ( DIR *  dirp,
struct dirent64 *  entry,
struct dirent64 **  result 
)

Definition at line 979 of file XrdPosix.cc.

980 {
981 
982 // Return result of readdir
983 //
984  return (Xroot.isXrootdDir(dirp) ? Xroot.Readdir64_r(dirp,entry,result)
985  : Xunix.Readdir64_r(dirp,entry,result));
986 }
Retv_Readdir64_r(* Readdir64_r)(Args_Readdir64_r)
static int Readdir64_r(DIR *dirp, struct dirent64 *entry, struct dirent64 **result)

References XrdPosixXrootd::isXrootdDir(), XrdPosixXrootd::Readdir64_r(), XrdPosixLinkage::Readdir64_r, Xroot, and Xunix.

Referenced by readdir64_r().

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

◆ XrdPosix_Readdir_r()

int XrdPosix_Readdir_r ( DIR *  dirp,
struct dirent *  entry,
struct dirent **  result 
)

Definition at line 970 of file XrdPosix.cc.

971 {
972 
973 // Return result of readdir
974 //
975  return (Xroot.isXrootdDir(dirp) ? Xroot.Readdir_r(dirp,entry,result)
976  : Xunix.Readdir_r(dirp,entry,result));
977 }
Retv_Readdir_r(* Readdir_r)(Args_Readdir_r)
static int Readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)

References XrdPosixXrootd::isXrootdDir(), XrdPosixXrootd::Readdir_r(), XrdPosixLinkage::Readdir_r, Xroot, and Xunix.

+ Here is the call graph for this function:

◆ XrdPosix_Readv()

ssize_t XrdPosix_Readv ( int  fildes,
const struct iovec *  iov,
int  iovcnt 
)

Definition at line 927 of file XrdPosix.cc.

928 {
929 
930 // Return results of the readv
931 //
932  return (Xroot.myFD(fildes) ? Xroot.Readv(fildes, iov, iovcnt)
933  : Xunix.Readv(fildes, iov, iovcnt));
934 }
Retv_Readv(* Readv)(Args_Readv)
static ssize_t Readv(int fildes, const struct iovec *iov, int iovcnt)
Readv() conforms to POSIX.1-2001 readv()

References XrdPosixXrootd::myFD(), XrdPosixXrootd::Readv(), XrdPosixLinkage::Readv, Xroot, and Xunix.

Referenced by readv().

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

◆ XrdPosix_Rename()

int XrdPosix_Rename ( const char *  oldpath,
const char *  newpath 
)

Definition at line 995 of file XrdPosix.cc.

996 {
997  char *oldPath, buffold[2048], *newPath, buffnew[2048];
998 
999 // Make sure a path was passed
1000 //
1001  if (!oldpath || !newpath) {errno = EFAULT; return -1;}
1002 
1003 // Return the results of a mkdir of a Unix file system
1004 //
1005  if (!(oldPath = XrootPath.URL(oldpath, buffold, sizeof(buffold)))
1006  || !(newPath = XrootPath.URL(newpath, buffnew, sizeof(buffnew))))
1007  return Xunix.Rename(oldpath, newpath);
1008 
1009 // Return the results of an mkdir of an xrootd file system
1010 //
1011  return Xroot.Rename(oldPath, newPath);
1012 }
Retv_Rename(* Rename)(Args_Rename)
static int Rename(const char *oldpath, const char *newpath)
Rename() conforms to POSIX.1-2001 rename()

References XrdPosixXrootd::Rename(), XrdPosixLinkage::Rename, XrdPosixXrootPath::URL(), Xroot, XrootPath, and Xunix.

Referenced by rename().

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

◆ XrdPosix_Rewinddir()

void XrdPosix_Rewinddir ( DIR *  dirp)

Definition at line 1021 of file XrdPosix.cc.

1022 {
1023 
1024 // Return result of rewind
1025 //
1026  return (Xroot.isXrootdDir(dirp) ? Xroot.Rewinddir(dirp)
1027  : Xunix.Rewinddir(dirp));
1028 }
Retv_Rewinddir(* Rewinddir)(Args_Rewinddir)
static void Rewinddir(DIR *dirp)
Rewinddir() conforms to POSIX.1-2001 rewinddir()

References XrdPosixXrootd::isXrootdDir(), XrdPosixXrootd::Rewinddir(), XrdPosixLinkage::Rewinddir, Xroot, and Xunix.

Referenced by rewinddir().

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

◆ XrdPosix_Rmdir()

int XrdPosix_Rmdir ( const char *  path)

Definition at line 1037 of file XrdPosix.cc.

1038 {
1039  char *myPath, buff[2048];
1040 
1041 // Make sure a path was passed
1042 //
1043  if (!path) {errno = EFAULT; return -1;}
1044 
1045 // Return the results of a mkdir of a Unix file system
1046 //
1047  if (!(myPath = XrootPath.URL(path, buff, sizeof(buff))))
1048  return Xunix.Rmdir(path);
1049 
1050 // Return the results of an mkdir of an xrootd file system
1051 //
1052  return Xroot.Rmdir(myPath);
1053 }
Retv_Rmdir(* Rmdir)(Args_Rmdir)
static int Rmdir(const char *path)
Rmdir() conforms to POSIX.1-2001 rmdir()

References XrdPosixXrootd::Rmdir(), XrdPosixLinkage::Rmdir, XrdPosixXrootPath::URL(), Xroot, XrootPath, and Xunix.

Referenced by rmdir().

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

◆ XrdPosix_Seekdir()

void XrdPosix_Seekdir ( DIR *  dirp,
long  loc 
)

Definition at line 1062 of file XrdPosix.cc.

1063 {
1064 
1065 // Call seekdir
1066 //
1067  (Xroot.isXrootdDir(dirp) ? Xroot.Seekdir(dirp, loc)
1068  : Xunix.Seekdir(dirp, loc));
1069 }
Retv_Seekdir(* Seekdir)(Args_Seekdir)
static void Seekdir(DIR *dirp, long loc)
Seekdir() conforms to POSIX.1-2001 seekdir()

References XrdPosixXrootd::isXrootdDir(), XrdPosixXrootd::Seekdir(), XrdPosixLinkage::Seekdir, Xroot, and Xunix.

Referenced by seekdir().

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

◆ XrdPosix_Stat()

int XrdPosix_Stat ( const char *  path,
struct stat buf 
)

Definition at line 1078 of file XrdPosix.cc.

1079 {
1080  char buff[2048];
1081  char unref[2049];
1082 
1083  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
1084  if (res < 0) return res;
1085 
1086  // links are pointing to file unref now which is not a link
1087  if (char *myPath = XrootPath.URL(unref, buff, sizeof(buff))) {
1088  int ret = Xroot.Stat(myPath, buf);
1089  return (ret);
1090  } else {
1091  // not a root file
1092 #ifdef SYS_stat
1093  return syscall(SYS_stat, path, buf);
1094 #else
1095  errno = ENOSYS;
1096  return -1;
1097 #endif
1098  }
1099 }

References XrdPosixXrootd::Stat(), XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, and XrootPath.

Referenced by stat64(), and XrdPosix_Statx().

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

◆ XrdPosix_Statfs()

int XrdPosix_Statfs ( const char *  path,
struct statfs buf 
)

Definition at line 1146 of file XrdPosix.cc.

1147 {
1148  char *myPath, buff[2048];
1149 
1150  char unref[2049];
1151 
1152  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
1153  if (res < 0) return res;
1154 
1155 // Return the results of an open of a Unix file
1156 //
1157  return ((myPath = XrootPath.URL(unref, buff, sizeof(buff)))
1158  ? Xroot.Statfs(myPath, buf)
1159  : Xunix.Statfs64(path, (struct statfs64 *)buf));
1160 }
int statfs64(const char *path, struct statfs64 *buf)
Retv_Statfs64(* Statfs64)(Args_Statfs64)
static int Statfs(const char *path, struct statfs *buf)

References XrdPosixXrootd::Statfs(), statfs64(), XrdPosixLinkage::Statfs64, XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, XrootPath, and Xunix.

Referenced by statfs64().

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

◆ XrdPosix_Statvfs()

int XrdPosix_Statvfs ( const char *  path,
struct statvfs buf 
)

Definition at line 1169 of file XrdPosix.cc.

1170 {
1171  char *myPath, buff[2048];
1172  char unref[2049];
1173 
1174  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
1175  if (res < 0) return res;
1176 
1177 // Return the results of an open of a Unix file
1178 //
1179  return ((myPath = XrootPath.URL(unref, buff, sizeof(buff)))
1180  ? Xroot.Statvfs(myPath, buf)
1181  : Xunix.Statvfs64(path, (struct statvfs64 *)buf));
1182 }
int statvfs64(const char *path, struct statvfs64 *buf)
Retv_Statvfs64(* Statvfs64)(Args_Statvfs64)
static int Statvfs(const char *path, struct statvfs *buf)
Statvfs() conforms to POSIX.1-2001 statvfs()

References XrdPosixXrootd::Statvfs(), statvfs64(), XrdPosixLinkage::Statvfs64, XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, XrootPath, and Xunix.

Referenced by statvfs64().

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

◆ XrdPosix_Statx()

int XrdPosix_Statx ( int  dirfd,
const char *  path,
int  flags,
unsigned int  mask,
XrdSysStatx stx 
)

Definition at line 1104 of file XrdPosix.cc.

1106 {
1107  if (path && *path) {
1108  char buff[2048];
1109  char unref[2049];
1110 
1111  if (!(flags & AT_SYMLINK_NOFOLLOW)) {
1112  // We need to follow until path is no longer a link
1113  ssize_t res = XrdResolveLink(path, unref, sizeof(unref));
1114  if (res < 0) return res;
1115  } else {
1116  strncpy(unref, path, 2048);
1117  }
1118  if (char *myPath = XrootPath.URL(unref, buff, sizeof(buff))) {
1119  struct stat st{};
1120  if (int ret = XrdPosix_Stat(myPath, &st))
1121  return ret;
1122  XrdSysStatxHelpers::Stat2Statx(st, *stx);
1123  return 0;
1124  } else {
1125 #ifdef SYS_statx
1126  int ret = syscall(SYS_statx, dirfd, path, flags, mask, stx);
1127  return ret;
1128 #else
1129  errno = ENOSYS;
1130  return -1;
1131 #endif
1132  }
1133  } else {
1134  errno = EFAULT;
1135  }
1136  return -1;
1137 }
int XrdPosix_Stat(const char *path, struct stat *buf)
Definition: XrdPosix.cc:1078

References dirfd, stat, XrdPosixXrootPath::URL(), XrdPosix_Stat(), XrdResolveLink(), and XrootPath.

+ Here is the call graph for this function:

◆ XrdPosix_Telldir()

long XrdPosix_Telldir ( DIR *  dirp)

Definition at line 1191 of file XrdPosix.cc.

1192 {
1193 
1194 // Return result of telldir
1195 //
1196  return (Xroot.isXrootdDir(dirp) ? Xroot.Telldir(dirp)
1197  : Xunix.Telldir(dirp));
1198 }
Retv_Telldir(* Telldir)(Args_Telldir)
static long Telldir(DIR *dirp)
Telldir() conforms to POSIX.1-2001 telldir()

References XrdPosixXrootd::isXrootdDir(), XrdPosixXrootd::Telldir(), XrdPosixLinkage::Telldir, Xroot, and Xunix.

+ Here is the call graph for this function:

◆ XrdPosix_Truncate()

int XrdPosix_Truncate ( const char *  path,
off_t  offset 
)

Definition at line 1207 of file XrdPosix.cc.

1208 {
1209  char *myPath, buff[2048];
1210  char unref[2049];
1211 
1212  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
1213  if (res < 0) return res;
1214 
1215 // Return the results of a truncate of a Unix file system
1216 //
1217  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
1218  return Xunix.Truncate64(path, offset);
1219 
1220 // Return the results of an truncate of an xrootd file system
1221 //
1222  return Xroot.Truncate(myPath, offset);
1223 }
Retv_Truncate64(* Truncate64)(Args_Truncate64)
static int Truncate(const char *path, off_t offset)
Telldir() conforms to POSIX.1-2001 telldir()

References XrdPosixXrootd::Truncate(), XrdPosixLinkage::Truncate64, XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, XrootPath, and Xunix.

+ Here is the call graph for this function:

◆ XrdPosix_Unlink()

int XrdPosix_Unlink ( const char *  path)

Definition at line 1232 of file XrdPosix.cc.

1233 {
1234  char *myPath, buff[2048];
1235  char unref[2049];
1236 
1237  ssize_t res=XrdResolveLink(path, unref, sizeof(unref));
1238  if (res < 0) return res;
1239 
1240 // Return the result of a unlink of a Unix file
1241 //
1242  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
1243  return Xunix.Unlink(path);
1244 
1245 // Return the results of an unlink of an xrootd file
1246 //
1247  return Xroot.Unlink(myPath);
1248 }
Retv_Unlink(* Unlink)(Args_Unlink)
static int Unlink(const char *path)
Unlink() conforms to POSIX.1-2001 unlink()

References XrdPosixXrootd::Unlink(), XrdPosixLinkage::Unlink, XrdPosixXrootPath::URL(), XrdResolveLink(), Xroot, XrootPath, and Xunix.

+ Here is the call graph for this function:

◆ XrdPosix_URL()

char* XrdPosix_URL ( const char *  path,
char *  buff,
int  blen 
)

Definition at line 1296 of file XrdPosix.cc.

1297 {
1298  return XrootPath.URL(path, buff, blen);
1299 }

References XrdPosixXrootPath::URL(), and XrootPath.

+ Here is the call graph for this function:

◆ XrdPosix_Write()

ssize_t XrdPosix_Write ( int  fildes,
const void *  buf,
size_t  nbyte 
)

Definition at line 1257 of file XrdPosix.cc.

1258 {
1259 
1260 // Return the results of the write
1261 //
1262  return (Xroot.myFD(fildes) ? Xroot.Write(fildes, buf, nbyte)
1263  : Xunix.Write(fildes, buf, nbyte));
1264 }
Retv_Write(* Write)(Args_Write)

References XrdPosixXrootd::myFD(), XrdPosixXrootd::Write(), XrdPosixLinkage::Write, Xroot, and Xunix.

+ Here is the call graph for this function:

◆ XrdPosix_Writev()

ssize_t XrdPosix_Writev ( int  fildes,
const struct iovec *  iov,
int  iovcnt 
)

Definition at line 1273 of file XrdPosix.cc.

1274 {
1275 
1276 // Return results of the writev
1277 //
1278  return (Xroot.myFD(fildes) ? Xroot.Writev(fildes, iov, iovcnt)
1279  : Xunix.Writev(fildes, iov, iovcnt));
1280 }
Retv_Writev(* Writev)(Args_Writev)
static ssize_t Writev(int fildes, const struct iovec *iov, int iovcnt)
Writev() conforms to POSIX.1-2001 writev()

References XrdPosixXrootd::myFD(), XrdPosixXrootd::Writev(), XrdPosixLinkage::Writev, Xroot, and Xunix.

+ Here is the call graph for this function:

◆ XrdResolveLink()

static ssize_t XrdResolveLink ( const char *  path,
char *  resolved,
size_t  rsize 
)
static

Definition at line 114 of file XrdPosix.cc.

115 {
116  // Make sure a path was passed
117  //
118  if (!path) {
119  errno = EINVAL;
120  return -1;
121  }
122 
123  char unref[2049], filename[2049];
124  char *result = realpath(path, nullptr);
125 
126  if (result) {
127  strlcpy(filename, result, sizeof(filename));
128  free(result);
129  } else {
130  bzero(filename, sizeof(filename));
131  bzero(unref, sizeof(unref));
132 
133  strlcpy(filename, path, sizeof(filename));
134 
135  // if it is a link, follow it until the end
136  int i = 0;
137  errno = 0;
138  while (readlink(filename, unref, sizeof(unref)) > 0 && ++i < 10) {
139  strlcpy(filename, unref, sizeof(filename));
140  bzero(unref, sizeof(unref)); // reset unref buffer
141  }
142  if (i == 10) {
143  errno = ELOOP;
144  return -1;
145  }
146  // succeed only if we found a file (EINVAL returned),
147  // or a link to a remote file (ENOENT returned)
148  if (errno != EINVAL && errno != ENOENT)
149  return -1;
150  }
151  size_t len = strlen(filename);
152  if (len > rsize) {
153  errno = ENAMETOOLONG;
154  return -1;
155  }
156  strlcpy(resolved, filename, rsize);
157  return len;
158 }
size_t strlcpy(char *dst, const char *src, size_t sz)

References strlcpy().

Referenced by XrdPosix_Access(), XrdPosix_Acl(), XrdPosix_Chdir(), XrdPosix_Fopen(), XrdPosix_Fstatat(), XrdPosix_Mkdir(), XrdPosix_Open(), XrdPosix_Openat(), XrdPosix_Opendir(), XrdPosix_Pathconf(), XrdPosix_Stat(), XrdPosix_Statfs(), XrdPosix_Statvfs(), XrdPosix_Statx(), XrdPosix_Truncate(), and XrdPosix_Unlink().

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

Variable Documentation

◆ Xroot

◆ XrootPath

◆ Xunix