XRootD
XrdPosix.cc
Go to the documentation of this file.
1 /******************************************************************************/
2 /* */
3 /* X r d P o s i x . c c */
4 /* */
5 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */
6 /* All Rights Reserved */
7 /* Produced by Andrew Hanushevsky for Stanford University under contract */
8 /* DE-AC02-76-SFO0515 with the Department of Energy */
9 /* */
10 /* This file is part of the XRootD software suite. */
11 /* */
12 /* XRootD is free software: you can redistribute it and/or modify it under */
13 /* the terms of the GNU Lesser General Public License as published by the */
14 /* Free Software Foundation, either version 3 of the License, or (at your */
15 /* option) any later version. */
16 /* */
17 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20 /* License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25 /* */
26 /* The copyright holder's institutional names and contributor's names may not */
27 /* be used to endorse or promote products derived from this software without */
28 /* specific prior written permission of the institution or contributor. */
29 /******************************************************************************/
30 
31 #include <cstdarg>
32 #include <cstdio>
33 #include <cstdlib>
34 #include <sys/param.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <sys/syscall.h>
38 #include <limits.h>
39 #include <fcntl.h>
40 #include <unistd.h>
41 #include <sys/uio.h>
42 
43 #include "XrdSys/XrdSysHeaders.hh"
47 #include "XrdSys/XrdSysStatx.hh"
48 
49 /******************************************************************************/
50 /* G l o b a l O b j e c t s */
51 /******************************************************************************/
52 
54 
56 
57 extern XrdPosixLinkage Xunix;
58 
59 /******************************************************************************/
60 /* U t i l i t y F u n c t i o n s */
61 /******************************************************************************/
62 
63 #ifdef MUSL
64 #include <stdio_ext.h>
65 #endif
66 
67 static inline void fseterr(FILE *fp)
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 }
89 
90 static inline void fseteof(FILE *fp)
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 }
110 
111 /******************************************************************************/
112 /* X r d R e s o l v e L i n k */
113 /******************************************************************************/
114 static ssize_t XrdResolveLink(const char *path, char *resolved){
115  char unref[2049], filename[2049];
116  char * result;
117  // Make sure a path was passed
118  //
119  if (!path) {errno = EFAULT; return -1;}
120  result = realpath(path, NULL);
121  if (result == NULL){
122  strncpy(filename, path, 2048);
123  strncpy(unref, path, 2048);
124  // if it is a link, follow it until the end
125  int i = 0;
126  bzero(unref, 2049);
127  int lsize = readlink(filename, unref, 2048);
128  while (lsize > 0 && i<10){
129  strncpy(filename, unref, 2049);
130  // ensure zero termination
131  bzero(unref, 2049);
132  lsize = readlink(filename, unref, 2048);
133  i++;
134  }
135  if (i == 10){
136  errno = ELOOP;
137  return(-1);
138  }
139  } else {
140  strncpy(filename, result, 2048);
141  free(result);
142  }
143  strncpy(resolved, filename, 2049);
144  return(strlen(filename));
145 }
146 
147 /******************************************************************************/
148 /* X r d P o s i x _ A c c e s s */
149 /******************************************************************************/
150 extern "C"
151 {
152 int XrdPosix_Access(const char *path, int amode)
153 {
154  char *myPath, buff[2048];
155  char unref[2049];
156 
157  ssize_t res=XrdResolveLink(path, unref);
158  if (res > 0) {
159  // Return the results of a mkdir of a Unix file system
160  //
161  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
162  return Xunix.Access( path, amode);
163 
164  // Return the results of our version of access()
165  //
166  return Xroot.Access(myPath, amode);
167  } else {
168  return res;
169  }
170 }
171 }
172 
173 /******************************************************************************/
174 /* X r d P o s i x _ A c l */
175 /******************************************************************************/
176 
177 // This is a required addition for Solaris 10+ systems
178 
179 extern "C"
180 {
181 int XrdPosix_Acl(const char *path, int cmd, int nentries, void *aclbufp)
182 {
183  char unref[2049];
184 
185  ssize_t res=XrdResolveLink(path, unref);
186  if (res < 0) return res;
187  return (XrootPath.URL(unref, 0, 0)
188  ? Xunix.Acl("/tmp", cmd,nentries,aclbufp)
189  : Xunix.Acl(path, cmd,nentries,aclbufp));
190 }
191 }
192 
193 /******************************************************************************/
194 /* X r d P o s i x _ C h d i r */
195 /******************************************************************************/
196 
197 extern "C"
198 {
199 int XrdPosix_Chdir(const char *path)
200 {
201  int rc;
202  char unref[2049];
203 
204  ssize_t res=XrdResolveLink(path, unref);
205  if (res < 0) return res;
206 
207  // Set the working directory if the actual chdir succeeded
208  //
209  if (!(rc = Xunix.Chdir(path))) XrootPath.CWD(unref);
210  return rc;
211 }
212 }
213 
214 /******************************************************************************/
215 /* X r d P o s i x _ C l o s e */
216 /******************************************************************************/
217 
218 extern "C"
219 {
220 int XrdPosix_Close(int fildes)
221 {
222 
223 // Return result of the close
224 //
225  return (Xroot.myFD(fildes) ? Xroot.Close(fildes) : Xunix.Close(fildes));
226 }
227 }
228 
229 /******************************************************************************/
230 /* X r d P o s i x _ C l o s e d i r */
231 /******************************************************************************/
232 
233 extern "C"
234 {
235 int XrdPosix_Closedir(DIR *dirp)
236 {
237 
238  return (Xroot.isXrootdDir(dirp) ? Xroot.Closedir(dirp)
239  : Xunix.Closedir(dirp));
240 }
241 }
242 
243 /******************************************************************************/
244 /* X r d P o s i x _ C r e a t */
245 /******************************************************************************/
246 
247 extern "C"
248 {
249 int XrdPosix_Creat(const char *path, mode_t mode)
250 {
251  extern int XrdPosix_Open(const char *path, int oflag, ...);
252 
253  return XrdPosix_Open(path, O_WRONLY | O_CREAT | O_TRUNC, mode);
254 }
255 }
256 
257 /******************************************************************************/
258 /* X r d P o s i x _ F c l o s e */
259 /******************************************************************************/
260 
261 extern "C"
262 {
263 int XrdPosix_Fclose(FILE *stream)
264 {
265  int nullfd = fileno(stream);
266 
267 // Close the associated file
268 //
269  if (Xroot.myFD(nullfd)) Xroot.Close(nullfd);
270 
271 // Now close the stream
272 //
273  return Xunix.Fclose(stream);
274 }
275 }
276 
277 /******************************************************************************/
278 /* X r d P o s i x _ F c n t l */
279 /******************************************************************************/
280 
281 extern "C"
282 {
283 int XrdPosix_Fcntl(int fd, int cmd, ...)
284 {
285  va_list ap;
286  void *theArg;
287 
288  if (Xroot.myFD(fd)) return 0;
289  va_start(ap, cmd);
290  theArg = va_arg(ap, void *);
291  va_end(ap);
292  return Xunix.Fcntl64(fd, cmd, theArg);
293 }
294 }
295 
296 /******************************************************************************/
297 /* X r d P o s i x _ F d a t a s y n c */
298 /******************************************************************************/
299 
300 extern "C"
301 {
302 int XrdPosix_Fdatasync(int fildes)
303 {
304 
305 // Return the result of the sync
306 //
307  return (Xroot.myFD(fildes) ? Xroot.Fsync(fildes)
308  : Xunix.Fsync(fildes));
309 }
310 }
311 
312 /******************************************************************************/
313 /* X r d P o s i x _ F g e t x a t t r */
314 /******************************************************************************/
315 
316 #if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
317 extern "C"
318 {
319 ssize_t XrdPosix_Fgetxattr (int fd, const char *name, void *value, size_t size)
320 {
321  if (Xroot.myFD(fd)) {errno = ENOTSUP; return -1;}
322  return Xunix.Fgetxattr(fd, name, value, size);
323 }
324 }
325 #endif
326 
327 /******************************************************************************/
328 /* X r d P o s i x _ F f l u s h */
329 /******************************************************************************/
330 
331 extern "C"
332 {
333 int XrdPosix_Fflush(FILE *stream)
334 {
335 
336 // Return the result of the fseek
337 //
338  if (!stream || !Xroot.myFD(fileno(stream)))
339  return Xunix.Fflush(stream);
340 
341  return Xroot.Fsync(fileno(stream));
342 }
343 }
344 
345 /******************************************************************************/
346 /* X r d P o s i x _ F o p e n */
347 /******************************************************************************/
348 
349 #define ISMODE(x) !strcmp(mode, x)
350 
351 extern "C"
352 {
353 FILE *XrdPosix_Fopen(const char *path, const char *mode)
354 {
355  char *myPath, buff[2048];
356  int erc, fd, omode;
357  FILE *stream;
358 
359  char unref[2049];
360 
361  ssize_t res=XrdResolveLink(path, unref);
362  if (res < 0) return 0;
363 
364 // Transfer to unix if this is not our path
365 //
366  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
367  return Xunix.Fopen64(path, mode);
368 
369 // Translate the mode flags
370 //
371  if (ISMODE("r") || ISMODE("rb")) omode = O_RDONLY;
372  else if (ISMODE("w") || ISMODE("wb")) omode = O_WRONLY
373  | O_CREAT | O_TRUNC;
374  else if (ISMODE("a") || ISMODE("ab")) omode = O_WRONLY
375  | O_CREAT | O_APPEND;
376  else if (ISMODE("r+") || ISMODE("rb+") || ISMODE("r+b")) omode = O_RDWR;
377  else if (ISMODE("w+") || ISMODE("wb+") || ISMODE("w+b")) omode = O_RDWR
378  | O_CREAT | O_TRUNC;
379  else if (ISMODE("a+") || ISMODE("ab+") || ISMODE("a+b")) omode = O_RDWR
380  | O_CREAT | O_APPEND;
381  else {errno = EINVAL; return 0;}
382 
383 // Now open the file
384 //
385  if ((fd = Xroot.Open(myPath, omode | XrdPosixXrootd::isStream , 0)) < 0)
386  return 0;
387 
388 // First obtain a free stream
389 //
390  if (!(stream = fdopen(fd, mode)))
391  {erc = errno; Xroot.Close(fd); errno = erc;}
392 
393 // All done
394 //
395  return stream;
396 }
397 }
398 
399 /******************************************************************************/
400 /* X r d P o s i x _ F r e a d */
401 /******************************************************************************/
402 
403 extern "C"
404 {
405 size_t XrdPosix_Fread(void *ptr, size_t size, size_t nitems, FILE *stream)
406 {
407  ssize_t bytes;
408  size_t rc = 0;
409  int fd = fileno(stream);
410 
411  if (!Xroot.myFD(fd)) return Xunix.Fread(ptr, size, nitems, stream);
412 
413  bytes = Xroot.Read(fd, ptr, size*nitems);
414 
415 // Get the right return code. Note that we cannot emulate the flags in sunx86
416 //
417  if (bytes > 0 && size) rc = bytes/size;
418  else if (bytes < 0) fseterr(stream);
419  else fseteof(stream);
420 
421  return rc;
422 }
423 }
424 
425 /******************************************************************************/
426 /* X r d P o s i x _ F s e e k */
427 /******************************************************************************/
428 
429 extern "C"
430 {
431 int XrdPosix_Fseek(FILE *stream, long offset, int whence)
432 {
433 
434 // Return the result of the fseek
435 //
436  if (!Xroot.myFD(fileno(stream)))
437  return Xunix.Fseek( stream, offset, whence);
438 
439  return (Xroot.Lseek(fileno(stream), offset, whence) < 0 ? -1 : 0);
440 }
441 }
442 
443 /******************************************************************************/
444 /* X r d P o s i x _ F s e e k o */
445 /******************************************************************************/
446 
447 extern "C"
448 {
449 int XrdPosix_Fseeko(FILE *stream, long long offset, int whence)
450 {
451 
452 // Return the result of the fseek
453 //
454  if (!Xroot.myFD(fileno(stream)))
455  return Xunix.Fseeko64(stream, offset, whence);
456 
457  return (Xroot.Lseek(fileno(stream), offset, whence) < 0 ? -1 : 0);
458 }
459 }
460 
461 /******************************************************************************/
462 /* X r d P o s i x _ F s t a t */
463 /******************************************************************************/
464 
465 extern "C"
466 {
467  int XrdPosix_Fstat(int fildes, struct stat *buf)
468  {
469  if (Xroot.myFD(fildes)){
470  return(Xroot.Fstat(fildes, buf));
471  } else {
472 #ifdef SYS_fstat
473  return syscall(SYS_fstat, fildes, buf);
474 #else
475  errno = ENOSYS;
476  return -1;
477 #endif
478  }
479  }
480  int XrdPosix_FstatV(int ver, int fildes, struct stat *buf)
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  }
493 }
494 
495 /******************************************************************************/
496 /* X r d P o s i x _ F s t a t a t */
497 /******************************************************************************/
498 
499 extern "C"
500 {
501  int XrdPosix_Fstatat(int dirfd, const char *path, struct stat *buf, int flags)
502 {
503  if (path && *path) {
504  char buff[2048];
505  char unref[2049];
506 
507  if (!(flags & AT_SYMLINK_NOFOLLOW)) {
508  // We need to follow until path is no longer a link
509  ssize_t res = XrdResolveLink(path, unref);
510  if (res < 0) return res;
511  // links are pointing to file unref now which is not a link
512  } else {
513  strncpy(unref, path, 2048);
514  }
515  if (char *myPath = XrootPath.URL(unref, buff, sizeof(buff))) {
516  int ret = Xroot.Stat(myPath, (struct stat *)buf);
517  return (ret);
518  } else {
519  // not a root file
520 #ifdef SYS_newfstatat
521  return syscall(SYS_newfstatat, dirfd, path, buf, flags);
522 #else
523 #ifdef SYS_fstatat
524  return syscall(SYS_fstatat, dirfd, path, buf, flags);
525 #else
526  errno = ENOSYS;
527  return -1;
528 #endif
529 #endif
530  }
531  } else {
532  errno = EFAULT;
533  }
534  return -1;
535 }
536 }
537 
538 /******************************************************************************/
539 /* X r d P o s i x _ F s y n c */
540 /******************************************************************************/
541 
542 extern "C"
543 {
544 int XrdPosix_Fsync(int fildes)
545 {
546 
547 // Return the result of the sync
548 //
549  return (Xroot.myFD(fildes) ? Xroot.Fsync(fildes)
550  : Xunix.Fsync(fildes));
551 }
552 }
553 
554 /******************************************************************************/
555 /* X r d P o s i x _ F t e l l */
556 /******************************************************************************/
557 
558 extern "C"
559 {
560 long XrdPosix_Ftell(FILE *stream)
561 {
562 
563 // Return the result of the tell
564 //
565  if (!Xroot.myFD(fileno(stream))) return Xunix.Ftell(stream);
566 
567  return static_cast<long>(Xroot.Lseek(fileno(stream), 0, SEEK_CUR));
568 }
569 }
570 
571 /******************************************************************************/
572 /* X r d P o s i x _ F t e l l o */
573 /******************************************************************************/
574 
575 extern "C"
576 {
577 long long XrdPosix_Ftello(FILE *stream)
578 {
579 
580 // Return the result of the tell
581 //
582  if (!Xroot.myFD(fileno(stream))) return Xunix.Ftello64(stream);
583 
584  return Xroot.Lseek(fileno(stream), 0, SEEK_CUR);
585 }
586 }
587 
588 /******************************************************************************/
589 /* X r d P o s i x _ F t r u n c a t e */
590 /******************************************************************************/
591 
592 extern "C"
593 {
594 int XrdPosix_Ftruncate(int fildes, long long offset)
595 {
596 
597 // Return the result of the ftruncate
598 //
599  return (Xroot.myFD(fildes) ? Xroot.Ftruncate (fildes, offset)
600  : Xunix.Ftruncate64(fildes, offset));
601 }
602 }
603 
604 /******************************************************************************/
605 /* X r d P o s i x _ F w r i t e */
606 /******************************************************************************/
607 
608 extern "C"
609 {
610 size_t XrdPosix_Fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream)
611 {
612  size_t bytes, rc = 0;
613  int fd = fileno(stream);
614 
615  if (!Xroot.myFD(fd)) return Xunix.Fwrite(ptr, size, nitems, stream);
616 
617  bytes = Xroot.Write(fd, ptr, size*nitems);
618 
619 // Get the right return code.
620 //
621  if (bytes > 0 && size) rc = bytes/size;
622  else fseterr(stream);
623 
624  return rc;
625 }
626 }
627 
628 /******************************************************************************/
629 /* X r d P o s i x _ G e t x a t t r */
630 /******************************************************************************/
631 
632 #if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
633 extern "C"
634 {
635 ssize_t XrdPosix_Getxattr (const char *path, const char *name, void *value, size_t size)
636 {
637  char *myPath, buff[2048];
638  char unref[2049];
639 
640  ssize_t res=XrdResolveLink(path, unref);
641  if (res < 0) return res;
642  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
643  return Xunix.Getxattr(path, name, value, size);
644 
645  return Xroot.Getxattr(myPath, name, value, size);
646 }
647 }
648 #endif
649 
650 /******************************************************************************/
651 /* X r d P o s i x _ L g e t x a t t r */
652 /******************************************************************************/
653 
654 #if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
655 extern "C"
656 {
657 ssize_t XrdPosix_Lgetxattr (const char *path, const char *name, void *value, size_t size)
658 {
659  char unref[2049];
660 
661  ssize_t res=XrdResolveLink(path, unref);
662  if (res < 0) return res;
663 
664  if (XrootPath.URL(unref, 0, 0)) {errno = ENOTSUP; return -1;}
665  return Xunix.Lgetxattr(path, name, value, size);
666 }
667 }
668 #endif
669 
670 /******************************************************************************/
671 /* X r d P o s i x _ L s e e k */
672 /******************************************************************************/
673 
674 extern "C"
675 {
676 off_t XrdPosix_Lseek(int fildes, off_t offset, int whence)
677 {
678 
679 // Return the operation of the seek
680 //
681  return (Xroot.myFD(fildes) ? Xroot.Lseek (fildes, offset, whence)
682  : Xunix.Lseek64(fildes, offset, whence));
683 }
684 }
685 
686 /******************************************************************************/
687 /* X r d P o s i x _ L s t a t */
688 /******************************************************************************/
689 
690 extern "C"
691 {
692 int XrdPosix_Lstat(const char *path, struct stat *buf)
693 {
694  char *myPath, buff[2048];
695 
696 // Make sure a path was passed
697 //
698  if (!path) {errno = EFAULT; return -1;}
699 
700 // Return the results of an open of a Unix file
701 //
702  myPath = XrootPath.URL(path, buff, sizeof(buff));
703  if (myPath){
704  return Xroot.Stat(myPath, buf);
705  } else {
706 #ifdef SYS_lstat
707  return syscall(SYS_lstat, path, buf);
708 #else
709  errno = ENOSYS;
710  return -1;
711 #endif
712  }
713 }
714 }
715 
716 /******************************************************************************/
717 /* X r d P o s i x _ M k d i r */
718 /******************************************************************************/
719 
720 extern "C"
721 {
722 int XrdPosix_Mkdir(const char *path, mode_t mode)
723 {
724  char *myPath, buff[2048];
725  char unref[2049];
726 
727  ssize_t res=XrdResolveLink(path, unref);
728  if (res < 0) return res;
729 
730 // Return the results of a mkdir of a Unix file system
731 //
732  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
733  return Xunix.Mkdir(path, mode);
734 
735 // Return the results of an mkdir of an xrootd file system
736 //
737  return Xroot.Mkdir(myPath, mode);
738 }
739 }
740 
741 /******************************************************************************/
742 /* X r d P o s i x _ O p e n */
743 /******************************************************************************/
744 
745 extern "C"
746 {
747 int XrdPosix_Open(const char *path, int oflag, ...)
748 {
749  char *myPath, buff[2048];
750  char unref[2049];
751  va_list ap;
752  int mode;
753  ssize_t res=XrdResolveLink(path, unref);
754  if (res < 0) return res;
755  // Return the results of an open of a Unix file
756  //
757  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
758  {if (!(oflag & O_CREAT)) return Xunix.Open64(unref, oflag);
759  va_start(ap, oflag);
760  mode = va_arg(ap, int);
761  va_end(ap);
762  return Xunix.Open64(unref, oflag, (mode_t)mode);
763  }
764 
765  // Return the results of an open of an xrootd file
766  //
767  if (!(oflag & O_CREAT)) return Xroot.Open(myPath, oflag);
768  va_start(ap, oflag);
769  mode = va_arg(ap, int);
770  va_end(ap);
771  return Xroot.Open(myPath, oflag, (mode_t)mode);
772 }
773 }
774 
775 /******************************************************************************/
776 /* X r d P o s i x _ O p e n a t */
777 /******************************************************************************/
778 
779 extern "C"
780 {
781 int XrdPosix_Openat(int dirfd, const char *path, int flag, ...)
782 {
783  char *myPath, buff[2048];
784  char unref[2049];
785  va_list ap;
786  int mode;
787  ssize_t res=XrdResolveLink(path, unref);
788  if (res < 0) return res;
789 
790  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff)))){
791  mode_t mode = 0;
792  if (flag & (O_CREAT)) {
793  va_start(ap, flag);
794  mode = va_arg(ap, int);
795  va_end(ap);
796  }
797 #ifdef SYS_openat
798  return (syscall(SYS_openat, dirfd, path, flag, (mode_t)mode));
799 #else
800  errno = ENOSYS;
801  return -1;
802 #endif
803  } else {
804  // Return the results of an open of an xrootd file
805  //
806  if (!(flag & O_CREAT)) return Xroot.Open(myPath, flag);
807  va_start(ap, flag);
808  mode = va_arg(ap, int);
809  va_end(ap);
810  return Xroot.Open(myPath, flag, (mode_t)mode);
811  }
812 }
813 }
814 
815 /******************************************************************************/
816 /* X r d P o s i x _ O p e n d i r */
817 /******************************************************************************/
818 
819 extern "C"
820 {
821 DIR* XrdPosix_Opendir(const char *path)
822 {
823  char *myPath, buff[2048];
824  char unref[2049];
825 
826  ssize_t res=XrdResolveLink(path, unref);
827  if (res < 0) return NULL;
828 
829 // Unix opendir
830 //
831  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
832  return Xunix.Opendir(path);
833 
834 // Xrootd opendir
835 //
836  return Xroot.Opendir(myPath);
837 }
838 }
839 
840 /******************************************************************************/
841 /* X r d P o s i x _ P a t h c o n f */
842 /******************************************************************************/
843 
844 // This is a required addition for Solaris 10+ systems
845 
846 extern "C"
847 {
848 long XrdPosix_Pathconf(const char *path, int name)
849 {
850  char unref[2049];
851 
852  ssize_t res=XrdResolveLink(path, unref);
853  if (res < 0) return res;
854 
855  return (XrootPath.URL(unref, 0, 0) ? Xunix.Pathconf("/tmp", name)
856  : Xunix.Pathconf(unref, name));
857 }
858 }
859 
860 /******************************************************************************/
861 /* X r d P o s i x _ P r e a d */
862 /******************************************************************************/
863 
864 extern "C"
865 {
866 ssize_t XrdPosix_Pread(int fildes, void *buf, size_t nbyte, off_t offset)
867 {
868 
869 // Return the results of the read
870 //
871  return (Xroot.myFD(fildes) ? Xroot.Pread (fildes, buf, nbyte, offset)
872  : Xunix.Pread64(fildes, buf, nbyte, offset));
873 }
874 }
875 
876 /******************************************************************************/
877 /* X r d P o s i x _ P w r i t e */
878 /******************************************************************************/
879 
880 extern "C"
881 {
882 ssize_t XrdPosix_Pwrite(int fildes, const void *buf, size_t nbyte, off_t offset)
883 {
884 
885 // Return the results of the write
886 //
887  return (Xroot.myFD(fildes) ? Xroot.Pwrite (fildes, buf, nbyte, offset)
888  : Xunix.Pwrite64(fildes, buf, nbyte, offset));
889 }
890 }
891 
892 /******************************************************************************/
893 /* X r d P o s i x _ R e a d */
894 /******************************************************************************/
895 
896 extern "C"
897 {
898 ssize_t XrdPosix_Read(int fildes, void *buf, size_t nbyte)
899 {
900 
901 // Return the results of the read
902 //
903  return (Xroot.myFD(fildes) ? Xroot.Read(fildes, buf, nbyte)
904  : Xunix.Read(fildes, buf, nbyte));
905 }
906 }
907 
908 /******************************************************************************/
909 /* X r d P o s i x _ R e a d v */
910 /******************************************************************************/
911 
912 extern "C"
913 {
914 ssize_t XrdPosix_Readv(int fildes, const struct iovec *iov, int iovcnt)
915 {
916 
917 // Return results of the readv
918 //
919  return (Xroot.myFD(fildes) ? Xroot.Readv(fildes, iov, iovcnt)
920  : Xunix.Readv(fildes, iov, iovcnt));
921 }
922 }
923 
924 /******************************************************************************/
925 /* X r d P o s i x _ R e a d d i r */
926 /******************************************************************************/
927 
928 extern "C"
929 {
930 // On some platforms both 32- and 64-bit versions are callable. so do the same
931 //
932 struct dirent * XrdPosix_Readdir (DIR *dirp)
933 {
934 
935 // Return result of readdir
936 //
937  return (Xroot.isXrootdDir(dirp) ? Xroot.Readdir(dirp)
938  : Xunix.Readdir(dirp));
939 }
940 
941 struct dirent64 * XrdPosix_Readdir64(DIR *dirp)
942 {
943 
944 // Return result of readdir
945 //
946  return (Xroot.isXrootdDir(dirp) ? Xroot.Readdir64(dirp)
947  : Xunix.Readdir64(dirp));
948 }
949 }
950 
951 /******************************************************************************/
952 /* X r d P o s i x _ R e a d d i r _ r */
953 /******************************************************************************/
954 
955 extern "C"
956 {
957 int XrdPosix_Readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
958 {
959 
960 // Return result of readdir
961 //
962  return (Xroot.isXrootdDir(dirp) ? Xroot.Readdir_r(dirp,entry,result)
963  : Xunix.Readdir_r(dirp,entry,result));
964 }
965 
966 int XrdPosix_Readdir64_r(DIR *dirp, struct dirent64 *entry, struct dirent64 **result)
967 {
968 
969 // Return result of readdir
970 //
971  return (Xroot.isXrootdDir(dirp) ? Xroot.Readdir64_r(dirp,entry,result)
972  : Xunix.Readdir64_r(dirp,entry,result));
973 }
974 }
975 
976 /******************************************************************************/
977 /* X r d P o s i x _ R e n a m e */
978 /******************************************************************************/
979 
980 extern "C"
981 {
982 int XrdPosix_Rename(const char *oldpath, const char *newpath)
983 {
984  char *oldPath, buffold[2048], *newPath, buffnew[2048];
985 
986 // Make sure a path was passed
987 //
988  if (!oldpath || !newpath) {errno = EFAULT; return -1;}
989 
990 // Return the results of a mkdir of a Unix file system
991 //
992  if (!(oldPath = XrootPath.URL(oldpath, buffold, sizeof(buffold)))
993  || !(newPath = XrootPath.URL(newpath, buffnew, sizeof(buffnew))))
994  return Xunix.Rename(oldpath, newpath);
995 
996 // Return the results of an mkdir of an xrootd file system
997 //
998  return Xroot.Rename(oldPath, newPath);
999 }
1000 }
1001 
1002 /******************************************************************************/
1003 /* X r d P o s i x _ R e w i n d d i r */
1004 /******************************************************************************/
1005 
1006 extern "C"
1007 {
1008 void XrdPosix_Rewinddir(DIR *dirp)
1009 {
1010 
1011 // Return result of rewind
1012 //
1013  return (Xroot.isXrootdDir(dirp) ? Xroot.Rewinddir(dirp)
1014  : Xunix.Rewinddir(dirp));
1015 }
1016 }
1017 
1018 /******************************************************************************/
1019 /* X r d P o s i x _ R m d i r */
1020 /******************************************************************************/
1021 
1022 extern "C"
1023 {
1024 int XrdPosix_Rmdir(const char *path)
1025 {
1026  char *myPath, buff[2048];
1027 
1028 // Make sure a path was passed
1029 //
1030  if (!path) {errno = EFAULT; return -1;}
1031 
1032 // Return the results of a mkdir of a Unix file system
1033 //
1034  if (!(myPath = XrootPath.URL(path, buff, sizeof(buff))))
1035  return Xunix.Rmdir(path);
1036 
1037 // Return the results of an mkdir of an xrootd file system
1038 //
1039  return Xroot.Rmdir(myPath);
1040 }
1041 }
1042 
1043 /******************************************************************************/
1044 /* X r d P o s i x _ S e e k d i r */
1045 /******************************************************************************/
1046 
1047 extern "C"
1048 {
1049 void XrdPosix_Seekdir(DIR *dirp, long loc)
1050 {
1051 
1052 // Call seekdir
1053 //
1054  (Xroot.isXrootdDir(dirp) ? Xroot.Seekdir(dirp, loc)
1055  : Xunix.Seekdir(dirp, loc));
1056 }
1057 }
1058 
1059 /******************************************************************************/
1060 /* X r d P o s i x _ S t a t */
1061 /******************************************************************************/
1062 
1063 extern "C"
1064 {
1065 int XrdPosix_Stat(const char *path, struct stat *buf)
1066 {
1067  char buff[2048];
1068  char unref[2049];
1069 
1070  ssize_t res=XrdResolveLink(path, unref);
1071  if (res < 0) return res;
1072 
1073  // links are pointing to file unref now which is not a link
1074  if (char *myPath = XrootPath.URL(unref, buff, sizeof(buff))) {
1075  int ret = Xroot.Stat(myPath, buf);
1076  return (ret);
1077  } else {
1078  // not a root file
1079 #ifdef SYS_stat
1080  return syscall(SYS_stat, path, buf);
1081 #else
1082  errno = ENOSYS;
1083  return -1;
1084 #endif
1085  }
1086 }
1087 }
1088 
1089 extern "C"
1090 {
1091 int XrdPosix_Statx(int dirfd, const char *path, int flags,
1092  unsigned int mask, XrdSysStatx *stx)
1093 {
1094  if (path && *path) {
1095  char buff[2048];
1096  char unref[2049];
1097 
1098  if (!(flags & AT_SYMLINK_NOFOLLOW)) {
1099  // We need to follow until path is no longer a link
1100  ssize_t res = XrdResolveLink(path, unref);
1101  if (res < 0) return res;
1102  } else {
1103  strncpy(unref, path, 2048);
1104  }
1105  if (char *myPath = XrootPath.URL(unref, buff, sizeof(buff))) {
1106  struct stat st{};
1107  if (int ret = XrdPosix_Stat(myPath, &st))
1108  return ret;
1110  return 0;
1111  } else {
1112 #ifdef SYS_statx
1113  int ret = syscall(SYS_statx, dirfd, path, flags, mask, stx);
1114  return ret;
1115 #else
1116  errno = ENOSYS;
1117  return -1;
1118 #endif
1119  }
1120  } else {
1121  errno = EFAULT;
1122  }
1123  return -1;
1124 }
1125 }
1126 
1127 /******************************************************************************/
1128 /* X r d P o s i x _ S t a t f s */
1129 /******************************************************************************/
1130 
1131 extern "C"
1132 {
1133 int XrdPosix_Statfs(const char *path, struct statfs *buf)
1134 {
1135  char *myPath, buff[2048];
1136 
1137  char unref[2049];
1138 
1139  ssize_t res=XrdResolveLink(path, unref);
1140  if (res < 0) return res;
1141 
1142 // Return the results of an open of a Unix file
1143 //
1144  return ((myPath = XrootPath.URL(unref, buff, sizeof(buff)))
1145  ? Xroot.Statfs(myPath, buf)
1146  : Xunix.Statfs64(path, (struct statfs64 *)buf));
1147 }
1148 }
1149 
1150 /******************************************************************************/
1151 /* X r d P o s i x _ S t a t v f s */
1152 /******************************************************************************/
1153 
1154 extern "C"
1155 {
1156 int XrdPosix_Statvfs(const char *path, struct statvfs *buf)
1157 {
1158  char *myPath, buff[2048];
1159  char unref[2049];
1160 
1161  ssize_t res=XrdResolveLink(path, unref);
1162  if (res < 0) return res;
1163 
1164 // Return the results of an open of a Unix file
1165 //
1166  return ((myPath = XrootPath.URL(unref, buff, sizeof(buff)))
1167  ? Xroot.Statvfs(myPath, buf)
1168  : Xunix.Statvfs64(path, (struct statvfs64 *)buf));
1169 }
1170 }
1171 
1172 /******************************************************************************/
1173 /* X r d P o s i x _ T e l l d i r */
1174 /******************************************************************************/
1175 
1176 extern "C"
1177 {
1178 long XrdPosix_Telldir(DIR *dirp)
1179 {
1180 
1181 // Return result of telldir
1182 //
1183  return (Xroot.isXrootdDir(dirp) ? Xroot.Telldir(dirp)
1184  : Xunix.Telldir(dirp));
1185 }
1186 }
1187 
1188 /******************************************************************************/
1189 /* X r d P o s i x _ T r u n c a t e */
1190 /******************************************************************************/
1191 
1192 extern "C"
1193 {
1194 int XrdPosix_Truncate(const char *path, off_t offset)
1195 {
1196  char *myPath, buff[2048];
1197  char unref[2049];
1198 
1199  ssize_t res=XrdResolveLink(path, unref);
1200  if (res < 0) return res;
1201 
1202 // Return the results of a truncate of a Unix file system
1203 //
1204  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
1205  return Xunix.Truncate64(path, offset);
1206 
1207 // Return the results of an truncate of an xrootd file system
1208 //
1209  return Xroot.Truncate(myPath, offset);
1210 }
1211 }
1212 
1213 /******************************************************************************/
1214 /* X r d P o s i x _ U n l i n k */
1215 /******************************************************************************/
1216 
1217 extern "C"
1218 {
1219 int XrdPosix_Unlink(const char *path)
1220 {
1221  char *myPath, buff[2048];
1222  char unref[2049];
1223 
1224  ssize_t res=XrdResolveLink(path, unref);
1225  if (res < 0) return res;
1226 
1227 // Return the result of a unlink of a Unix file
1228 //
1229  if (!(myPath = XrootPath.URL(unref, buff, sizeof(buff))))
1230  return Xunix.Unlink(path);
1231 
1232 // Return the results of an unlink of an xrootd file
1233 //
1234  return Xroot.Unlink(myPath);
1235 }
1236 }
1237 
1238 /******************************************************************************/
1239 /* X r d P o s i x _ W r i t e */
1240 /******************************************************************************/
1241 
1242 extern "C"
1243 {
1244 ssize_t XrdPosix_Write(int fildes, const void *buf, size_t nbyte)
1245 {
1246 
1247 // Return the results of the write
1248 //
1249  return (Xroot.myFD(fildes) ? Xroot.Write(fildes, buf, nbyte)
1250  : Xunix.Write(fildes, buf, nbyte));
1251 }
1252 }
1253 
1254 /******************************************************************************/
1255 /* X r d P o s i x _ W r i t e v */
1256 /******************************************************************************/
1257 
1258 extern "C"
1259 {
1260 ssize_t XrdPosix_Writev(int fildes, const struct iovec *iov, int iovcnt)
1261 {
1262 
1263 // Return results of the writev
1264 //
1265  return (Xroot.myFD(fildes) ? Xroot.Writev(fildes, iov, iovcnt)
1266  : Xunix.Writev(fildes, iov, iovcnt));
1267 }
1268 }
1269 
1270 /******************************************************************************/
1271 /* X r d P o s i x _ i s M y P a t h */
1272 /******************************************************************************/
1273 
1274 int XrdPosix_isMyPath(const char *path)
1275 {
1276  return (0 != XrootPath.URL(path, 0, 0));
1277 }
1278 
1279 /******************************************************************************/
1280 /* X r d P o s i x _ U R L */
1281 /******************************************************************************/
1282 
1283 char *XrdPosix_URL(const char *path, char *buff, int blen)
1284 {
1285  return XrootPath.URL(path, buff, blen);
1286 }
int statvfs64(const char *path, struct statvfs64 *buf)
int fseek(FILE *stream, long offset, int whence)
int statfs64(const char *path, struct statfs64 *buf)
int XrdPosix_Statfs(const char *path, struct statfs *buf)
Definition: XrdPosix.cc:1133
int XrdPosix_Truncate(const char *path, off_t offset)
Definition: XrdPosix.cc:1194
ssize_t XrdPosix_Read(int fildes, void *buf, size_t nbyte)
Definition: XrdPosix.cc:898
#define ISMODE(x)
Definition: XrdPosix.cc:349
int XrdPosix_Closedir(DIR *dirp)
Definition: XrdPosix.cc:235
int XrdPosix_Fsync(int fildes)
Definition: XrdPosix.cc:544
ssize_t XrdPosix_Readv(int fildes, const struct iovec *iov, int iovcnt)
Definition: XrdPosix.cc:914
static void fseterr(FILE *fp)
Definition: XrdPosix.cc:67
int XrdPosix_isMyPath(const char *path)
Definition: XrdPosix.cc:1274
long long XrdPosix_Ftello(FILE *stream)
Definition: XrdPosix.cc:577
int XrdPosix_Open(const char *path, int oflag,...)
Definition: XrdPosix.cc:747
void XrdPosix_Rewinddir(DIR *dirp)
Definition: XrdPosix.cc:1008
ssize_t XrdPosix_Pread(int fildes, void *buf, size_t nbyte, off_t offset)
Definition: XrdPosix.cc:866
int XrdPosix_Readdir64_r(DIR *dirp, struct dirent64 *entry, struct dirent64 **result)
Definition: XrdPosix.cc:966
int XrdPosix_Close(int fildes)
Definition: XrdPosix.cc:220
static ssize_t XrdResolveLink(const char *path, char *resolved)
Definition: XrdPosix.cc:114
int XrdPosix_Openat(int dirfd, const char *path, int flag,...)
Definition: XrdPosix.cc:781
void XrdPosix_Seekdir(DIR *dirp, long loc)
Definition: XrdPosix.cc:1049
int XrdPosix_Rmdir(const char *path)
Definition: XrdPosix.cc:1024
int XrdPosix_Chdir(const char *path)
Definition: XrdPosix.cc:199
FILE * XrdPosix_Fopen(const char *path, const char *mode)
Definition: XrdPosix.cc:353
int XrdPosix_Stat(const char *path, struct stat *buf)
Definition: XrdPosix.cc:1065
int XrdPosix_Rename(const char *oldpath, const char *newpath)
Definition: XrdPosix.cc:982
int XrdPosix_Fcntl(int fd, int cmd,...)
Definition: XrdPosix.cc:283
int XrdPosix_Fseek(FILE *stream, long offset, int whence)
Definition: XrdPosix.cc:431
long XrdPosix_Ftell(FILE *stream)
Definition: XrdPosix.cc:560
static void fseteof(FILE *fp)
Definition: XrdPosix.cc:90
int XrdPosix_Readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
Definition: XrdPosix.cc:957
XrdPosixXrootd Xroot
Definition: XrdPosix.cc:53
int XrdPosix_Mkdir(const char *path, mode_t mode)
Definition: XrdPosix.cc:722
int XrdPosix_Fflush(FILE *stream)
Definition: XrdPosix.cc:333
char * XrdPosix_URL(const char *path, char *buff, int blen)
Definition: XrdPosix.cc:1283
ssize_t XrdPosix_Writev(int fildes, const struct iovec *iov, int iovcnt)
Definition: XrdPosix.cc:1260
XrdPosixXrootPath XrootPath
Definition: XrdPosix.cc:55
DIR * XrdPosix_Opendir(const char *path)
Definition: XrdPosix.cc:821
long XrdPosix_Telldir(DIR *dirp)
Definition: XrdPosix.cc:1178
int XrdPosix_FstatV(int ver, int fildes, struct stat *buf)
Definition: XrdPosix.cc:480
ssize_t XrdPosix_Pwrite(int fildes, const void *buf, size_t nbyte, off_t offset)
Definition: XrdPosix.cc:882
int XrdPosix_Lstat(const char *path, struct stat *buf)
Definition: XrdPosix.cc:692
int XrdPosix_Fstatat(int dirfd, const char *path, struct stat *buf, int flags)
Definition: XrdPosix.cc:501
int XrdPosix_Creat(const char *path, mode_t mode)
Definition: XrdPosix.cc:249
int XrdPosix_Statx(int dirfd, const char *path, int flags, unsigned int mask, XrdSysStatx *stx)
Definition: XrdPosix.cc:1091
int XrdPosix_Statvfs(const char *path, struct statvfs *buf)
Definition: XrdPosix.cc:1156
int XrdPosix_Acl(const char *path, int cmd, int nentries, void *aclbufp)
Definition: XrdPosix.cc:181
int XrdPosix_Fstat(int fildes, struct stat *buf)
Definition: XrdPosix.cc:467
off_t XrdPosix_Lseek(int fildes, off_t offset, int whence)
Definition: XrdPosix.cc:676
ssize_t XrdPosix_Write(int fildes, const void *buf, size_t nbyte)
Definition: XrdPosix.cc:1244
XrdPosixLinkage Xunix
size_t XrdPosix_Fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream)
Definition: XrdPosix.cc:610
int XrdPosix_Fclose(FILE *stream)
Definition: XrdPosix.cc:263
int XrdPosix_Fdatasync(int fildes)
Definition: XrdPosix.cc:302
int XrdPosix_Ftruncate(int fildes, long long offset)
Definition: XrdPosix.cc:594
struct dirent64 * XrdPosix_Readdir64(DIR *dirp)
Definition: XrdPosix.cc:941
long XrdPosix_Pathconf(const char *path, int name)
Definition: XrdPosix.cc:848
struct dirent * XrdPosix_Readdir(DIR *dirp)
Definition: XrdPosix.cc:932
int XrdPosix_Unlink(const char *path)
Definition: XrdPosix.cc:1219
size_t XrdPosix_Fread(void *ptr, size_t size, size_t nitems, FILE *stream)
Definition: XrdPosix.cc:405
int XrdPosix_Fseeko(FILE *stream, long long offset, int whence)
Definition: XrdPosix.cc:449
int XrdPosix_Access(const char *path, int amode)
Definition: XrdPosix.cc:152
#define statvfs(a, b)
Definition: XrdPosix.hh:135
#define stat(a, b)
Definition: XrdPosix.hh:105
#define statfs(a, b)
Definition: XrdPosix.hh:111
#define dirfd(x)
Retv_Opendir(* Opendir)(Args_Opendir)
Retv_Mkdir(* Mkdir)(Args_Mkdir)
Retv_Readdir64(* Readdir64)(Args_Readdir64)
Retv_Fflush(* Fflush)(Args_Fflush)
Retv_Fclose(* Fclose)(Args_Fclose)
Retv_Fseek(* Fseek)(Args_Fseek)
Retv_Fwrite(* Fwrite)(Args_Fwrite)
Retv_Acl(* Acl)(Args_Acl)
Retv_Writev(* Writev)(Args_Writev)
Retv_Read(* Read)(Args_Read)
Retv_Fsync(* Fsync)(Args_Fsync)
Retv_Rename(* Rename)(Args_Rename)
Retv_Close(* Close)(Args_Close)
Retv_Statfs64(* Statfs64)(Args_Statfs64)
Retv_Lgetxattr(* Lgetxattr)(Args_Lgetxattr)
Retv_Ftruncate64(* Ftruncate64)(Args_Ftruncate64)
Retv_Rewinddir(* Rewinddir)(Args_Rewinddir)
Retv_Readdir(* Readdir)(Args_Readdir)
Retv_Lseek64(* Lseek64)(Args_Lseek64)
Retv_Statvfs64(* Statvfs64)(Args_Statvfs64)
Retv_Truncate64(* Truncate64)(Args_Truncate64)
Retv_Ftell(* Ftell)(Args_Ftell)
Retv_Fread(* Fread)(Args_Fread)
Retv_Open64(* Open64)(Args_Open64)
Retv_Fopen64(* Fopen64)(Args_Fopen64)
Retv_Telldir(* Telldir)(Args_Telldir)
Retv_Fseeko64(* Fseeko64)(Args_Fseeko64)
Retv_Readv(* Readv)(Args_Readv)
Retv_Pread64(* Pread64)(Args_Pread64)
Retv_Readdir64_r(* Readdir64_r)(Args_Readdir64_r)
Retv_Fcntl64(* Fcntl64)(Args_Fcntl64)
Retv_Seekdir(* Seekdir)(Args_Seekdir)
Retv_Chdir(* Chdir)(Args_Chdir)
Retv_Getxattr(* Getxattr)(Args_Getxattr)
Retv_Access(* Access)(Args_Access)
Retv_Closedir(* Closedir)(Args_Closedir)
Retv_Pathconf(* Pathconf)(Args_Pathconf)
Retv_Write(* Write)(Args_Write)
Retv_Readdir_r(* Readdir_r)(Args_Readdir_r)
Retv_Rmdir(* Rmdir)(Args_Rmdir)
Retv_Fgetxattr(* Fgetxattr)(Args_Fgetxattr)
Retv_Unlink(* Unlink)(Args_Unlink)
Retv_Pwrite64(* Pwrite64)(Args_Pwrite64)
Retv_Ftello64(* Ftello64)(Args_Ftello64)
char * URL(const char *path, char *buff, int blen)
void CWD(const char *path)
POSIX interface to XRootD with some extensions, as noted.
static ssize_t Readv(int fildes, const struct iovec *iov, int iovcnt)
Readv() conforms to POSIX.1-2001 readv()
static ssize_t Pread(int fildes, void *buf, size_t nbyte, off_t offset)
Pread() conforms to POSIX.1-2001 pread()
static int Closedir(DIR *dirp)
Closedir() conforms to POSIX.1-2001 closedir()
static void Seekdir(DIR *dirp, long loc)
Seekdir() conforms to POSIX.1-2001 seekdir()
static const int isStream
static int Stat(const char *path, struct stat *buf)
Stat() conforms to POSIX.1-2001 stat()
static int Mkdir(const char *path, mode_t mode)
Mkdir() conforms to POSIX.1-2001 mkdir()
static int Unlink(const char *path)
Unlink() conforms to POSIX.1-2001 unlink()
static int Rmdir(const char *path)
Rmdir() conforms to POSIX.1-2001 rmdir()
static void Rewinddir(DIR *dirp)
Rewinddir() conforms to POSIX.1-2001 rewinddir()
static int Rename(const char *oldpath, const char *newpath)
Rename() conforms to POSIX.1-2001 rename()
static int Close(int fildes)
Close() conforms to POSIX.1-2001 close()
static int Statvfs(const char *path, struct statvfs *buf)
Statvfs() conforms to POSIX.1-2001 statvfs()
static ssize_t Write(int fildes, const void *buf, size_t nbyte)
Write() conforms to POSIX.1-2001 write()
static struct dirent * Readdir(DIR *dirp)
static int Readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
static ssize_t Writev(int fildes, const struct iovec *iov, int iovcnt)
Writev() conforms to POSIX.1-2001 writev()
static struct dirent64 * Readdir64(DIR *dirp)
static bool myFD(int fd)
static int Ftruncate(int fildes, off_t offset)
Ftruncate() conforms to POSIX.1-2001 ftruncate()
static long Telldir(DIR *dirp)
Telldir() conforms to POSIX.1-2001 telldir()
static bool isXrootdDir(DIR *dirp)
static int Access(const char *path, int amode)
Access() conforms to POSIX.1-2001 access()
static DIR * Opendir(const char *path)
Opendir() conforms to POSIX.1-2001 opendir()
static int Fsync(int fildes)
Fsync() conforms to POSIX.1-2001 fsync()
static long long Getxattr(const char *path, const char *name, void *value, unsigned long long size)
static int Statfs(const char *path, struct statfs *buf)
static int Readdir64_r(DIR *dirp, struct dirent64 *entry, struct dirent64 **result)
static ssize_t Read(int fildes, void *buf, size_t nbyte)
Read() conforms to POSIX.1-2001 read()
static int Fstat(int fildes, struct stat *buf)
Fstat() conforms to POSIX.1-2001 fstat()
static off_t Lseek(int fildes, off_t offset, int whence)
Lseek() conforms to POSIX.1-2001 lseek()
static int Open(const char *path, int oflag, mode_t mode=0, XrdPosixCallBack *cbP=0)
static ssize_t Pwrite(int fildes, const void *buf, size_t nbyte, off_t offset)
Pwrite() conforms to POSIX.1-2001 pwrite()
static int Truncate(const char *path, off_t offset)
Telldir() conforms to POSIX.1-2001 telldir()
static void Stat2Statx(const struct stat &stat, XrdSysStatx &statx)
Definition: XrdSysStatx.hh:109