XRootD
XrdPss.cc
Go to the documentation of this file.
1 /******************************************************************************/
2 /* */
3 /* X r d P s s . c c */
4 /* */
5 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University */
6 /* Produced by Andrew Hanushevsky for Stanford University under contract */
7 /* DE-AC02-76-SFO0515 with the Deprtment of Energy */
8 /* */
9 /* This file is part of the XRootD software suite. */
10 /* */
11 /* XRootD is free software: you can redistribute it and/or modify it under */
12 /* the terms of the GNU Lesser General Public License as published by the */
13 /* Free Software Foundation, either version 3 of the License, or (at your */
14 /* option) any later version. */
15 /* */
16 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19 /* License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24 /* */
25 /* The copyright holder's institutional names and contributor's names may not */
26 /* be used to endorse or promote products derived from this software without */
27 /* specific prior written permission of the institution or contributor. */
28 /******************************************************************************/
29 
30 /******************************************************************************/
31 /* I n c l u d e s */
32 /******************************************************************************/
33 
34 #include <unistd.h>
35 #include <cerrno>
36 #include <fcntl.h>
37 #include <signal.h>
38 #include <cstdint>
39 #include <strings.h>
40 #include <cstdio>
41 #include <sys/file.h>
42 #include <sys/param.h>
43 #include <sys/stat.h>
44 #include <sys/types.h>
45 #ifdef __solaris__
46 #include <sys/vnode.h>
47 #endif
48 #include <vector>
49 
50 #include "XrdVersion.hh"
51 
52 #include "XrdNet/XrdNetSecurity.hh"
53 #include "XrdPss/XrdPss.hh"
54 #include "XrdPss/XrdPssTrace.hh"
55 #include "XrdPss/XrdPssUrlInfo.hh"
56 #include "XrdPss/XrdPssUtils.hh"
59 #include "XrdPosix/XrdPosixInfo.hh"
61 #include "XrdOfs/XrdOfsFSctl_PI.hh"
62 
63 #include "XrdOss/XrdOssError.hh"
64 #include "XrdOuc/XrdOucEnv.hh"
65 #include "XrdOuc/XrdOucExport.hh"
68 #include "XrdSec/XrdSecEntity.hh"
69 #include "XrdSecsss/XrdSecsssID.hh"
71 #include "XrdSys/XrdSysError.hh"
72 #include "XrdSys/XrdSysHeaders.hh"
73 #include "XrdSys/XrdSysPlatform.hh"
74 
75 #ifndef O_DIRECT
76 #define O_DIRECT 0
77 #endif
78 
79 #ifndef ENOATTR
80 #define ENOATTR ENODATA
81 #endif
82 
83 /******************************************************************************/
84 /* D e f i n e s */
85 /******************************************************************************/
86 
87 #define isNOSTAGE(_x_) !(XRDEXP_STAGE & XrdPssSys::XPList.Find(_x_))
88 
89 #define isREADONLY(_x_) (XRDEXP_NOTRW & XrdPssSys::XPList.Find(_x_))
90 
91 /******************************************************************************/
92 /* G l o b a l s */
93 /******************************************************************************/
94 
95 class XrdScheduler;
96 
97 namespace XrdProxy
98 {
99 thread_local XrdOucECMsg ecMsg("[pss]");
100 
102 
103  XrdSysError eDest(0, "pss_");
104 
106 
108 
110 
112 
113  XrdSecsssID *idMapper = 0; // -> Auth ID mapper
114 
115 static const char *ofslclCGI = "ofs.lcl=1";
116 
117 static const char *osslclCGI = "oss.lcl=1";
118 
119 static const int PBsz = 4096;
120 
121  int rpFD = -1;
122 
123  bool idMapAll = false;
124 
125  bool outProxy = false; // True means outgoing proxy
126 
127  bool xrdProxy = false; // True means dest using xroot protocol
128 
129  XrdSysTrace SysTrace("Pss",0);
130 }
131 using namespace XrdProxy;
132 
133 /******************************************************************************/
134 /* XrdOssGetSS (a.k.a. XrdOssGetStorageSystem) */
135 /******************************************************************************/
136 
138 
139 // This function is called by the OFS layer to retrieve the Storage System
140 // object. We return our proxy storage system object if configuration succeeded.
141 //
142 extern "C"
143 {
146  const char *cFN,
147  const char *parms,
148  XrdOucEnv *envp)
149 {
150 
151 // Ignore the parms (we accept none for now) and call the init routine
152 //
153  envP = envp;
154  return (XrdProxySS.Init(Logger, cFN, envP) ? 0 : (XrdOss *)&XrdProxySS);
155 }
156 }
157 
158 /******************************************************************************/
159 /* o o s s _ S y s M e t h o d s */
160 /******************************************************************************/
161 /******************************************************************************/
162 /* C o n s t r u c t o r */
163 /******************************************************************************/
164 
165 XrdPssSys::XrdPssSys() : HostArena(0), LocalRoot(0), theN2N(0), DirFlags(0),
166  myVersion(&XrdVERSIONINFOVAR(XrdOssGetStorageSystem2)),
168  {}
169 
170 /******************************************************************************/
171 /* i n i t */
172 /******************************************************************************/
173 
174 /*
175  Function: Initialize proxy subsystem
176 
177  Input: None
178 
179  Output: Returns zero upon success otherwise (-errno).
180 */
181 int XrdPssSys::Init(XrdSysLogger *lp, const char *cFN, XrdOucEnv *envP)
182 {
183  int NoGo;
184  const char *tmp;
185 
186 // Do the herald thing
187 //
188  SysTrace.SetLogger(lp);
189  eDest.logger(lp);
190  eDest.Say("Copr. 2019, Stanford University, Pss Version " XrdVSTRING);
191 
192 // Initialize the subsystems
193 //
194  tmp = ((NoGo = Configure(cFN, envP)) ? "failed." : "completed.");
195  eDest.Say("------ Proxy storage system initialization ", tmp);
196 
197 // Extract Pfc control, if it is there.
198 //
199  if (!NoGo)
200  cacheFSctl = (XrdOfsFSctl_PI*)envP->GetPtr("XrdFSCtl_PC*");
201 
202 
203 // All done.
204 //
205  return NoGo;
206 }
207 
208 /******************************************************************************/
209 /* C h m o d */
210 /******************************************************************************/
211 /*
212  Function: Change file mode.
213 
214  Input: path - Is the fully qualified name of the target file.
215  mode - The new mode that the file is to have.
216  envP - Environmental information.
217 
218  Output: Returns XrdOssOK upon success and -errno upon failure.
219 
220  Notes: This function is currently unsupported.
221 */
222 
223 int XrdPssSys::Chmod(const char *path, mode_t mode, XrdOucEnv *eP)
224 {
225 // We currently do not support chmod()
226 //
227  return -ENOTSUP;
228 }
229 
230 /******************************************************************************/
231 /* C o n n e c t */
232 /******************************************************************************/
233 
235 {
236  EPNAME("Connect");
237  const XrdSecEntity *client = theEnv.secEnv();
238 
239 // If we need to personify the client, set it up
240 //
241  if (idMapper && client)
242  {const char *fmt = (client->ueid & 0xf0000000 ? "%x" : "U%x");
243  char uName[32];
244  snprintf(uName, sizeof(uName), fmt, client->ueid);
245  DEBUG(client->tident,"Registering as ID "<<uName);
246  idMapper->Register(uName, client, deferID);
247  }
248 }
249 
250 /******************************************************************************/
251 /* c r e a t e */
252 /******************************************************************************/
253 
254 /*
255  Function: Create a file named `path' with 'file_mode' access mode bits set.
256 
257  Input: path - The fully qualified name of the file to create.
258  access_mode - The Posix access mode bits to be assigned to the file.
259  These bits correspond to the standard Unix permission
260  bits (e.g., 744 == "rwxr--r--").
261  env - Environmental information.
262  opts - Set as follows:
263  XRDOSS_mkpath - create dir path if it does not exist.
264  XRDOSS_new - the file must not already exist.
265  x00000000 - x are standard open flags (<<8)
266 
267  Output: Returns XrdOssOK upon success; (-errno) otherwise.
268 
269  Notes: We always return ENOTSUP as we really want the create options to be
270  promoted to the subsequent open().
271 */
272 int XrdPssSys::Create(const char *tident, const char *path, mode_t Mode,
273  XrdOucEnv &env, int Opts)
274 {
275 
276  return -ENOTSUP;
277 }
278 
279 /******************************************************************************/
280 /* D i s c */
281 /******************************************************************************/
282 
284 {
285  EPNAME("Disc");
286  const XrdSecEntity *client = theEnv.secEnv();
287 
288 // If we personified a client, remove that persona.
289 //
290  if (idMapper && client)
291  {const char *fmt = (client->ueid & 0xf0000000 ? "%x" : "U%x");
292  char uName[32];
293  snprintf(uName, sizeof(uName), fmt, client->ueid);
294  DEBUG(client->tident,"Unregistering as ID "<<uName);
295  idMapper->Register(uName, 0);
296  }
297 }
298 
299 /******************************************************************************/
300 /* E n v I n f o */
301 /******************************************************************************/
302 
304 {
305 // We only need to extract the scheduler pointer from the environment. Propogate
306 // the information to the POSIX layer.
307 //
308  if (envP)
309  {schedP = (XrdScheduler *)envP->GetPtr("XrdScheduler*");
311  }
312 }
313 
314 /******************************************************************************/
315 /* L f n 2 P f n */
316 /******************************************************************************/
317 
318 int XrdPssSys::Lfn2Pfn(const char *oldp, char *newp, int blen)
319 {
320  if (theN2N) return -(theN2N->lfn2pfn(oldp, newp, blen));
321  if ((int)strlen(oldp) >= blen) return -ENAMETOOLONG;
322  strcpy(newp, oldp);
323  return 0;
324 }
325 
326 const char *XrdPssSys::Lfn2Pfn(const char *oldp, char *newp, int blen, int &rc)
327 {
328  if (!theN2N) {rc = 0; return oldp;}
329  if ((rc = -(theN2N->lfn2pfn(oldp, newp, blen)))) return 0;
330  return newp;
331 }
332 
333 /******************************************************************************/
334 /* M k d i r */
335 /******************************************************************************/
336 /*
337  Function: Create a directory
338 
339  Input: path - Is the fully qualified name of the new directory.
340  mode - The new mode that the directory is to have.
341  mkpath - If true, makes the full path.
342  envP - Environmental information.
343 
344  Output: Returns XrdOssOK upon success and -errno upon failure.
345 
346  Notes: Directories are only created in the local disk cache.
347  Currently, we do not propogate the mkpath option.
348 */
349 
350 int XrdPssSys::Mkdir(const char *path, mode_t mode, int mkpath, XrdOucEnv *eP)
351 {
352  EPNAME("Mkdir");
353  XrdPssUrlInfo uInfo(eP, path);
354  int rc;
355  char pbuff[PBsz];
356 
357 // Verify we can write here
358 //
359  if (isREADONLY(path)) return -EROFS;
360 
361 // Convert path to URL
362 //
363  if ((rc = P2URL(pbuff, PBsz, uInfo, xLfn2Pfn))) return rc;
364 
365 // Some tracing
366 //
367  if(DEBUGON) {
368  auto urlObf = obfuscateAuth(pbuff);
369  DEBUG(uInfo.Tident(),"url="<<urlObf);
370  }
371 
372 // Simply return the proxied result here
373 //
374  return (XrdPosixXrootd::Mkdir(pbuff, mode) ? Info(errno) : XrdOssOK);
375 }
376 
377 /******************************************************************************/
378 /* R e m d i r */
379 /******************************************************************************/
380 
381 /*
382  Function: Removes the directory 'path'
383 
384  Input: path - Is the fully qualified name of the directory to remove.
385  envP - Environmental information.
386 
387  Output: Returns XrdOssOK upon success and -errno upon failure.
388 */
389 int XrdPssSys::Remdir(const char *path, int Opts, XrdOucEnv *eP)
390 {
391  EPNAME("Remdir");
392  const char *Cgi = "";
393  int rc;
394  char pbuff[PBsz];
395 
396 // Verify we can write here
397 //
398  if (isREADONLY(path)) return -EROFS;
399 
400 // Setup any required cgi information
401 //
402  if (*path == '/' && !outProxy && (Opts & XRDOSS_Online)) Cgi = ofslclCGI;
403 
404 // Setup url information
405 //
406  XrdPssUrlInfo uInfo(eP, path, Cgi);
407 
408 // Convert path to URL
409 //
410  if ((rc = P2URL(pbuff, PBsz, uInfo, xLfn2Pfn))) return rc;
411 
412 // Do some tracing
413 //
414  if(DEBUGON) {
415  auto urlObf = obfuscateAuth(pbuff);
416  DEBUG(uInfo.Tident(),"url="<<urlObf);
417  }
418 // Issue unlink and return result
419 //
420  return (XrdPosixXrootd::Rmdir(pbuff) ? -errno : XrdOssOK);
421 }
422 
423 /******************************************************************************/
424 /* R e n a m e */
425 /******************************************************************************/
426 
427 /*
428  Function: Renames a file with name 'old_name' to 'new_name'.
429 
430  Input: old_name - Is the fully qualified name of the file to be renamed.
431  new_name - Is the fully qualified name that the file is to have.
432  old_envP - Environmental information for old_name.
433  new_envP - Environmental information for new_name.
434 
435  Output: Returns XrdOssOK upon success and -errno upon failure.
436 */
437 int XrdPssSys::Rename(const char *oldname, const char *newname,
438  XrdOucEnv *oldenvP, XrdOucEnv *newenvP)
439 {
440  EPNAME("Rename");
441  int rc;
442  char oldName[PBsz], newName[PBsz];
443 
444 // Verify we can write in the source and target
445 //
446  if (isREADONLY(oldname) || isREADONLY(newname)) return -EROFS;
447 
448 // Setup url info
449 //
450  XrdPssUrlInfo uInfoOld(oldenvP, oldname);
451  XrdPssUrlInfo uInfoNew(newenvP, newname, "", true, false);
452 
453 // Convert path to URL
454 //
455  if ((rc = P2URL(oldName, PBsz, uInfoOld, xLfn2Pfn))
456  || (rc = P2URL(newName, PBsz, uInfoNew, xLfn2Pfn))) return rc;
457 
458 // Do some tracing
459 //
460  if(DEBUGON) {
461  auto oldNameObf = obfuscateAuth(oldName);
462  auto newNameObf = obfuscateAuth(newName);
463  DEBUG(uInfoOld.Tident(),"old url="<<oldNameObf <<" new url=" <<newNameObf);
464  }
465 
466 
467 // Execute the rename and return result
468 //
469  return (XrdPosixXrootd::Rename(oldName, newName) ? -errno : XrdOssOK);
470 }
471 
472 /******************************************************************************/
473 /* s t a t */
474 /******************************************************************************/
475 
476 /*
477  Function: Determine if file 'path' actually exists.
478 
479  Input: path - Is the fully qualified name of the file to be tested.
480  buff - pointer to a 'stat' structure to hold the attributes
481  of the file.
482  Opts - stat() options.
483  envP - Environmental information.
484 
485  Output: Returns XrdOssOK upon success and -errno upon failure.
486 
487  Notes: The XRDOSS_resonly flag in Opts is not supported.
488 */
489 
490 int XrdPssSys::Stat(const char *path, struct stat *buff, int Opts, XrdOucEnv *eP)
491 {
492  EPNAME("Stat");
493  const char *Cgi = "";
494  int rc;
495  char pbuff[PBsz];
496 
497 // Setup any required special cgi information
498 //
499  if (*path == '/' && !outProxy && ((Opts & XRDOSS_resonly)||isNOSTAGE(path)))
500  Cgi = osslclCGI;
501 
502 // We can now establish the url information to be used
503 //
504  XrdPssUrlInfo uInfo(eP, path, Cgi);
505 
506 // Generate an ID if we need to. We can use the server's identity unless that
507 // has been prohibited because client ID mapping is taking place.
508 //
509  if (idMapAll) uInfo.setID();
510  else if (sidP) uInfo.setID(sidP);
511 
512 // Convert path to URL
513 //
514  if ((rc = P2URL(pbuff, PBsz, uInfo, xLfn2Pfn))) return rc;
515 
516 // Do some tracing
517 //
518  if(DEBUGON) {
519  auto urlObf = obfuscateAuth(pbuff);
520  DEBUG(uInfo.Tident(),"url="<<urlObf);
521  }
522 
523 // Return proxied stat
524 //
525  return (XrdPosixXrootd::Stat(pbuff, buff) ? -errno : XrdOssOK);
526 }
527 
528 /******************************************************************************/
529 /* S t a t s */
530 /******************************************************************************/
531 
532 /* Function: Return statistics.
533 
534  Input: buff - Pointer to buffer for statistics data.
535  blen - The length of the buffer.
536 
537  Output: When blen is not zero, null terminated statistics are placed
538  in buff and the length is returned. When blen is zero, the
539  maximum length needed is returned.
540 */
541 int XrdPssSys::Stats(char *bp, int bl)
542 {
543  return XrdPosixConfig::Stats("pss", bp, bl);
544 }
545 
546 /******************************************************************************/
547 /* T r u n c a t e */
548 /******************************************************************************/
549 /*
550  Function: Truncate a file.
551 
552  Input: path - Is the fully qualified name of the target file.
553  flen - The new size that the file is to have.
554  envP - Environmental information.
555 
556  Output: Returns XrdOssOK upon success and -errno upon failure.
557 */
558 
559 int XrdPssSys::Truncate(const char *path, unsigned long long flen,
560  XrdOucEnv *envP)
561 {
562  EPNAME("Trunc");
563  XrdPssUrlInfo uInfo(envP, path);
564  int rc;
565  char pbuff[PBsz];
566 
567 // Make sure we can write here
568 //
569  if (isREADONLY(path)) return -EROFS;
570 
571 // Convert path to URL
572 //
573  if ((rc = P2URL(pbuff, PBsz, uInfo, xLfn2Pfn))) return rc;
574 
575 // Do some tracing
576 //
577  if(DEBUGON) {
578  auto urlObf = obfuscateAuth(pbuff);
579  DEBUG(uInfo.Tident(),"url="<<urlObf);
580  }
581 
582 // Return proxied truncate. We only do this on a single machine because the
583 // redirector will forbid the trunc() if multiple copies exist.
584 //
585  return (XrdPosixXrootd::Truncate(pbuff, flen) ? -errno : XrdOssOK);
586 }
587 
588 /******************************************************************************/
589 /* U n l i n k */
590 /******************************************************************************/
591 
592 /*
593  Function: Delete a file from the namespace and release it's data storage.
594 
595  Input: path - Is the fully qualified name of the file to be removed.
596  envP - Environmental information.
597 
598  Output: Returns XrdOssOK upon success and -errno upon failure.
599 */
600 int XrdPssSys::Unlink(const char *path, int Opts, XrdOucEnv *envP)
601 {
602  EPNAME("Unlink");
603  const char *Cgi = "";
604  int rc;
605  char pbuff[PBsz];
606 
607 // Make sure we can write here
608 //
609  if (isREADONLY(path)) return -EROFS;
610 
611 // Setup any required cgi information
612 //
613  if (*path == '/' && !outProxy && (Opts & XRDOSS_Online)) Cgi = ofslclCGI;
614 
615 // Setup url info
616 //
617  XrdPssUrlInfo uInfo(envP, path, Cgi);
618 
619 // Convert path to URL
620 //
621  if ((rc = P2URL(pbuff, PBsz, uInfo, xLfn2Pfn))) return rc;
622 
623 // Do some tracing
624 //
625  if(DEBUGON) {
626  auto urlObf = obfuscateAuth(pbuff);
627  DEBUG(uInfo.Tident(),"url="<<urlObf);
628  }
629 
630 // Unlink the file and return result.
631 //
632  return (XrdPosixXrootd::Unlink(pbuff) ? -errno : XrdOssOK);
633 }
634 
635 /******************************************************************************/
636 /* P s s D i r M e t h o d s */
637 /******************************************************************************/
638 /******************************************************************************/
639 /* o p e n d i r */
640 /******************************************************************************/
641 
642 /*
643  Function: Open the directory `path' and prepare for reading.
644 
645  Input: path - The fully qualified name of the directory to open.
646  envP - Environmental information.
647 
648  Output: Returns XrdOssOK upon success; (-errno) otherwise.
649 */
650 int XrdPssDir::Opendir(const char *dir_path, XrdOucEnv &Env)
651 {
652  EPNAME("Opendir");
653  int rc;
654  char pbuff[PBsz];
655 
656 // Return an error if this object is already open
657 //
658  if (myDir) return -XRDOSS_E8001;
659 
660 // Open directories are not supported for object id's
661 //
662  if (*dir_path != '/') return -ENOTSUP;
663 
664 // Setup url info
665 //
666  XrdPssUrlInfo uInfo(&Env, dir_path);
667  uInfo.setID();
668 
669 // Convert path to URL
670 //
671  if ((rc = XrdPssSys::P2URL(pbuff, PBsz, uInfo, XrdPssSys::xLfn2Pfn)))
672  return rc;
673 
674 // Do some tracing
675 //
676  if(DEBUGON) {
677  auto urlObf = obfuscateAuth(pbuff);
678  DEBUG(uInfo.Tident(),"url="<<urlObf);
679  }
680 
681 // Open the directory
682 //
683  myDir = XrdPosixXrootd::Opendir(pbuff);
684  if (!myDir) return -errno;
685  return XrdOssOK;
686 }
687 
688 /******************************************************************************/
689 /* r e a d d i r */
690 /******************************************************************************/
691 
692 /*
693  Function: Read the next entry if directory associated with this object.
694 
695  Input: buff - Is the address of the buffer that is to hold the next
696  directory name.
697  blen - Size of the buffer.
698 
699  Output: Upon success, places the contents of the next directory entry
700  in buff. When the end of the directory is encountered buff
701  will be set to the null string.
702 
703  Upon failure, returns a (-errno).
704 
705  Warning: The caller must provide proper serialization.
706 */
707 int XrdPssDir::Readdir(char *buff, int blen)
708 {
709 // Check if we are directly reading the directory
710 //
711  if (myDir)
712  {dirent *entP, myEnt;
713  int rc = XrdPosixXrootd::Readdir_r(myDir, &myEnt, &entP);
714  if (rc) return -rc;
715  if (!entP) *buff = 0;
716  else strlcpy(buff, myEnt.d_name, blen);
717  return XrdOssOK;
718  }
719 
720 // The directory is not open
721 //
722  return -XRDOSS_E8002;
723 }
724 
725 /******************************************************************************/
726 /* C l o s e */
727 /******************************************************************************/
728 
729 /*
730  Function: Close the directory associated with this object.
731 
732  Input: None.
733 
734  Output: Returns XrdOssOK upon success and (errno) upon failure.
735 */
736 int XrdPssDir::Close(long long *retsz)
737 {
738  DIR *theDir;
739 
740 // Close the directory proper if it exists. POSIX specified that directory
741 // stream is no longer available after closedir() regardless if return value.
742 //
743  if ((theDir = myDir))
744  {myDir = 0;
745  if (XrdPosixXrootd::Closedir(theDir)) return -errno;
746  return XrdOssOK;
747  }
748 
749 // Directory is not open
750 //
751  return -XRDOSS_E8002;
752 }
753 
754 /******************************************************************************/
755 /* o o s s _ F i l e M e t h o d s */
756 /******************************************************************************/
757 /******************************************************************************/
758 /* o p e n */
759 /******************************************************************************/
760 
761 /*
762  Function: Open the file `path' in the mode indicated by `Mode'.
763 
764  Input: path - The fully qualified name of the file to open.
765  Oflag - Standard open flags.
766  Mode - Create mode (i.e., rwx).
767  env - Environmental information.
768 
769  Output: XrdOssOK upon success; -errno otherwise.
770 */
771 int XrdPssFile::Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &Env)
772 {
773  EPNAME("Open");
774  unsigned long long popts = XrdPssSys::XPList.Find(path);
775  const char *Cgi = "";
776  char pbuff[PBsz];
777  int rc;
778  bool tpcMode = (Oflag & O_NOFOLLOW) != 0;
779  bool rwMode = (Oflag & (O_WRONLY | O_RDWR | O_APPEND)) != 0;
780  bool ucgiOK = true;
781  bool ioCache = (Oflag & O_DIRECT);
782 
783 // Record the security environment
784 //
785  entity = Env.secEnv();
786 
787 // Turn off direct flag if set (we record it separately
788 //
789  if (ioCache) Oflag &= ~O_DIRECT;
790 
791 // Return an error if the object is already open
792 //
793  if (fd >= 0 || tpcPath) return -XRDOSS_E8003;
794 
795 // If we are opening this in r/w mode make sure we actually can
796 //
797  if (rwMode)
798  {if (XrdPssSys::fileOrgn) return -EROFS;
799  if (popts & XRDEXP_NOTRW)
800  {if (popts & XRDEXP_FORCERO && !tpcMode) Oflag = O_RDONLY;
801  else return -EROFS;
802  }
803  }
804 
805  // check CGI cache-control paramters
806  if (cacheFSctl)
807  {
808  int elen;
809  char *envcgi = (char *)Env.Env(elen);
810 
811  if (envcgi && strstr(envcgi, "only-if-cached"))
812  {
813  XrdOucErrInfo einfo;
814  XrdSfsFSctl myData;
815  myData.Arg1 = "cached";
816  myData.Arg1Len = 1;
817  myData.Arg2Len = 1;
818  const char *myArgs[1];
819  myArgs[0] = path;
820  myData.ArgP = myArgs;
821  int fsctlRes = cacheFSctl->FSctl(SFS_FSCTL_PLUGXC, myData, einfo);
822  if (fsctlRes == SFS_ERROR)
823  return -einfo.getErrInfo();
824  }
825  }
826 
827 // If this is a third party copy open, then strange rules apply. If this is an
828 // outgoing proxy we let everything pass through as this may be a TPC request
829 // elsewhere. Otherwise, if it's an open for reading, we open the file but
830 // strip off all CGI (technically, we should only remove the "tpc" tokens)
831 // because the source might not support direct TPC mode. If we are opening for
832 // writing, then we skip the open and mark this as a TPC handle which can only
833 // be used for fstat() and close(). Any other actions return an error.
834 //
835  if (tpcMode)
836  {Oflag &= ~O_NOFOLLOW;
837  if (!XrdProxy::outProxy || !IS_FWDPATH(path))
838  {if (rwMode)
839  {tpcPath = strdup(path);
840  if (XrdPssSys::reProxy)
841  {const char *rPath = Env.Get("tpc.reproxy");
842  if (!rPath || *rPath != '/') return -ENOATTR;
843  if (!(rPath = rindex(rPath, '/')) || *(rPath+1) == 0)
844  return -EFAULT;
845  rpInfo = new tprInfo(rPath+1);
846  }
847  return XrdOssOK;
848  }
849  ucgiOK = false;
850  }
851  }
852 
853 // Setup any required cgi information. Don't mess with it if it's an objectid
854 // or if the we are an outgoing proxy server.
855 //
856  if (!XrdProxy::outProxy && *path == '/' && !(XRDEXP_STAGE & popts))
857  Cgi = osslclCGI;
858 
859 // Construct the url info
860 //
861  XrdPssUrlInfo uInfo(&Env, path, Cgi, ucgiOK);
862  uInfo.setID();
863 
864 // Convert path to URL
865 //
866  if ((rc = XrdPssSys::P2URL(pbuff, PBsz, uInfo, XrdPssSys::xLfn2Pfn)))
867  return rc;
868 
869 // Do some tracing
870 //
871  if(DEBUGON) {
872  auto urlObf = obfuscateAuth(pbuff);
873  DEBUG(uInfo.Tident(),"url="<<urlObf);
874  }
875 
876 // Try to open and if we failed, return an error
877 //
878  if (!XrdPssSys::dcaCheck || !ioCache)
879  {if ((fd = XrdPosixXrootd::Open(pbuff,Oflag,Mode)) < 0) return -errno;
880  } else {
882  Info.ffReady = XrdPssSys::dcaWorld;
883  if (XrdPosixConfig::OpenFC(pbuff,Oflag,Mode,Info))
884  {Env.Put("FileURL", Info.cacheURL);
885  return -EDESTADDRREQ;
886  }
887  fd = Info.fileFD;
888  if (fd < 0) return -errno;
889  }
890 
891 // All done
892 //
893  return XrdOssOK;
894 }
895 
896 /******************************************************************************/
897 /* c l o s e */
898 /******************************************************************************/
899 
900 /*
901  Function: Close the file associated with this object.
902 
903  Input: None.
904 
905  Output: Returns XrdOssOK upon success aud -errno upon failure.
906 */
907 int XrdPssFile::Close(long long *retsz)
908 { int rc;
909 
910 // We don't support returning the size (we really should fix this)
911 //
912  if (retsz) *retsz = 0;
913 
914 // If the file is not open, then this may be OK if it is a 3rd party copy
915 //
916  if (fd < 0)
917  {if (!tpcPath) return -XRDOSS_E8004;
918  free(tpcPath);
919  tpcPath = 0;
920  return XrdOssOK;
921  }
922 
923 // Close the file
924 //
926  fd = -1;
927  return (rc == 0 ? XrdOssOK : -errno);
928 }
929 
930 /******************************************************************************/
931 /* p g R e a d */
932 /******************************************************************************/
933 
934 /*
935  Function: Read file pages into a buffer and return corresponding checksums.
936 
937  Input: buffer - pointer to buffer where the bytes are to be placed.
938  offset - The offset where the read is to start.
939  rdlen - The number of bytes to read.
940  csvec - A vector to be filled with the corresponding CRC32C
941  checksums for each page or page segment, if available.
942  opts - Options as noted (see inherited class).
943 
944  Output: returns Number of bytes that placed in buffer upon success and
945  -errno upon failure.
946 */
947 
948 ssize_t XrdPssFile::pgRead(void *buffer,
949  off_t offset,
950  size_t rdlen,
951  uint32_t *csvec,
952  uint64_t opts)
953 {
954  std::vector<uint32_t> vecCS;
955  uint64_t psxOpts;
956  ssize_t bytes;
957 
958 // Make sure file is open
959 //
960  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
961 
962 // Set options as needed
963 //
964  psxOpts = (csvec ? XrdPosixExtra::forceCS : 0);
965 
966 // Issue the pgread
967 //
968  if ((bytes = XrdPosixExtra::pgRead(fd,buffer,offset,rdlen,vecCS,psxOpts)) < 0)
969  return (ssize_t)-errno;
970 
971 // Copy out the checksum vector
972 //
973  if (vecCS.size() && csvec)
974  memcpy(csvec, vecCS.data(), vecCS.size()*sizeof(uint32_t));
975 
976 // All done
977 //
978  return bytes;
979 }
980 
981 /******************************************************************************/
982 /* p g W r i t e */
983 /******************************************************************************/
984 /*
985  Function: Write file pages into a file with corresponding checksums.
986 
987  Input: buffer - pointer to buffer containing the bytes to write.
988  offset - The offset where the write is to start.
989  wrlen - The number of bytes to write.
990  be the last write to the file at or above the offset.
991  csvec - A vector which contains the corresponding CRC32 checksum
992  for each page or page segment. If size is 0, then
993  checksums are calculated. If not zero, the size must
994  equal the required number of checksums for offset/wrlen.
995  opts - Options as noted.
996 
997  Output: Returns the number of bytes written upon success and -errno
998  upon failure.
999 */
1000 
1001 ssize_t XrdPssFile::pgWrite(void *buffer,
1002  off_t offset,
1003  size_t wrlen,
1004  uint32_t *csvec,
1005  uint64_t opts)
1006 {
1007  std::vector<uint32_t> vecCS;
1008  ssize_t bytes;
1009 
1010 // Make sure we have an open file
1011 //
1012  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1013 
1014 // Check if caller wants to verify the checksums before writing
1015 //
1016  if (csvec && (opts & XrdOssDF::Verify))
1017  {XrdOucPgrwUtils::dataInfo dInfo((const char*)buffer,csvec,offset,wrlen);
1018  off_t bado;
1019  int badc;
1020  if (!XrdOucPgrwUtils::csVer(dInfo, bado, badc)) return -EDOM;
1021  }
1022 
1023 // Check if caller want checksum generated and possibly returned
1024 //
1025  if ((opts & XrdOssDF::doCalc) || csvec == 0)
1026  {XrdOucPgrwUtils::csCalc((const char *)buffer, offset, wrlen, vecCS);
1027  if (csvec) memcpy(csvec, vecCS.data(), vecCS.size()*sizeof(uint32_t));
1028  } else {
1029  int n = XrdOucPgrwUtils::csNum(offset, wrlen);
1030  vecCS.resize(n);
1031  vecCS.assign(n, 0);
1032  memcpy(vecCS.data(), csvec, n*sizeof(uint32_t));
1033  }
1034 
1035 // Issue the pgwrite
1036 //
1037  bytes = XrdPosixExtra::pgWrite(fd, buffer, offset, wrlen, vecCS);
1038 
1039 // Return result
1040 //
1041  return (bytes < 0 ? (ssize_t)-errno : bytes);
1042 }
1043 
1044 /******************************************************************************/
1045 /* r e a d */
1046 /******************************************************************************/
1047 
1048 /*
1049  Function: Preread `blen' bytes from the associated file.
1050 
1051  Input: offset - The absolute 64-bit byte offset at which to read.
1052  blen - The size to preread.
1053 
1054  Output: Returns zero read upon success and -errno upon failure.
1055 */
1056 
1057 ssize_t XrdPssFile::Read(off_t offset, size_t blen)
1058 {
1059  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1060 
1061  return 0; // We haven't implemented this yet!
1062 }
1063 
1064 
1065 /******************************************************************************/
1066 /* r e a d */
1067 /******************************************************************************/
1068 
1069 /*
1070  Function: Read `blen' bytes from the associated file, placing in 'buff'
1071  the data and returning the actual number of bytes read.
1072 
1073  Input: buff - Address of the buffer in which to place the data.
1074  offset - The absolute 64-bit byte offset at which to read.
1075  blen - The size of the buffer. This is the maximum number
1076  of bytes that will be read.
1077 
1078  Output: Returns the number bytes read upon success and -errno upon failure.
1079 */
1080 
1081 ssize_t XrdPssFile::Read(void *buff, off_t offset, size_t blen)
1082 {
1083  ssize_t retval;
1084 
1085  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1086 
1087  return (retval = XrdPosixXrootd::Pread(fd, buff, blen, offset)) < 0
1088  ? (ssize_t)-errno : retval;
1089 }
1090 
1091 /******************************************************************************/
1092 /* r e a d v */
1093 /******************************************************************************/
1094 
1095 ssize_t XrdPssFile::ReadV(XrdOucIOVec *readV, // In
1096  int readCount) // In
1097 /*
1098  Function: Perform all the reads specified in the readV vector.
1099 
1100  Input: readV - A description of the reads to perform; includes the
1101  absolute offset, the size of the read, and the buffer
1102  to place the data into.
1103  readCount - The size of the readV vector.
1104 
1105  Output: Returns the number of bytes read upon success and -errno upon failure.
1106  If the number of bytes read is less than requested, it is considered
1107  an error.
1108 */
1109 {
1110  ssize_t retval;
1111 
1112  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1113 
1114  return (retval = XrdPosixXrootd::VRead(fd, readV, readCount)) < 0 ? (ssize_t)-errno : retval;;
1115 }
1116 
1117 /******************************************************************************/
1118 /* R e a d R a w */
1119 /******************************************************************************/
1120 
1121 /*
1122  Function: Read `blen' bytes from the associated file, placing in 'buff'
1123  the data and returning the actual number of bytes read.
1124 
1125  Input: buff - Address of the buffer in which to place the data.
1126  offset - The absolute 64-bit byte offset at which to read.
1127  blen - The size of the buffer. This is the maximum number
1128  of bytes that will be read.
1129 
1130  Output: Returns the number bytes read upon success and -errno upon failure.
1131 */
1132 
1133 ssize_t XrdPssFile::ReadRaw(void *buff, off_t offset, size_t blen)
1134 {
1135  return Read(buff, offset, blen);
1136 }
1137 
1138 /******************************************************************************/
1139 /* w r i t e */
1140 /******************************************************************************/
1141 
1142 /*
1143  Function: Write `blen' bytes to the associated file, from 'buff'
1144  and return the actual number of bytes written.
1145 
1146  Input: buff - Address of the buffer from which to get the data.
1147  offset - The absolute 64-bit byte offset at which to write.
1148  blen - The number of bytes to write from the buffer.
1149 
1150  Output: Returns the number of bytes written upon success and -errno o/w.
1151 */
1152 
1153 ssize_t XrdPssFile::Write(const void *buff, off_t offset, size_t blen)
1154 {
1155  ssize_t retval;
1156 
1157  if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1158 
1159  return (retval = XrdPosixXrootd::Pwrite(fd, buff, blen, offset)) < 0
1160  ? (ssize_t)-errno : retval;
1161 }
1162 
1163 /******************************************************************************/
1164 /* f s t a t */
1165 /******************************************************************************/
1166 
1167 /*
1168  Function: Return file status for the associated file.
1169 
1170  Input: buff - Pointer to buffer to hold file status.
1171 
1172  Output: Returns XrdOssOK upon success and -errno upon failure.
1173 */
1174 
1175 int XrdPssFile::Fstat(struct stat *buff)
1176 {
1177  EPNAME("fstat");
1178 
1179 // If we have a file descriptor then return a stat for it
1180 //
1181  if (fd >= 0) return (XrdPosixXrootd::Fstat(fd, buff) ? -errno : XrdOssOK);
1182 
1183 // Otherwise, if this is not a tpc of any kind, return an error
1184 //
1185  if (!tpcPath) return -XRDOSS_E8004;
1186 
1187 // If this is a normal tpc then simply issue the stat against the origin
1188 //
1189  if (!rpInfo)
1190  {XrdOucEnv fstatEnv(0, 0, entity);
1191  return XrdProxySS.Stat(tpcPath, buff, 0, &fstatEnv);
1192  }
1193 
1194 // This is a reproxy tpc, if we have not yet dertermined the true dest, do so.
1195 //
1196  struct stat Stat;
1197 
1198  if (rpInfo->dstURL == 0
1199  || !fstatat(rpFD, rpInfo->tprPath, &Stat, AT_SYMLINK_NOFOLLOW))
1200  {char lnkbuff[2048]; int lnklen;
1201  lnklen = readlinkat(rpFD, rpInfo->tprPath, lnkbuff, sizeof(lnkbuff)-1);
1202  if (lnklen <= 0)
1203  {int rc = 0;
1204  if (lnklen < 0) {if (errno != ENOENT) rc = -errno;}
1205  else rc = -EFAULT;
1206  if (rc)
1207  {unlinkat(rpFD, rpInfo->tprPath, 0);
1208  return rc;
1209  }
1210  } else {
1211  unlinkat(rpFD, rpInfo->tprPath, 0);
1212  lnkbuff[lnklen] = 0;
1213  if (rpInfo->dstURL) free(rpInfo->dstURL);
1214  rpInfo->dstURL = strdup(lnkbuff);
1215  rpInfo->fSize = 1;
1216  DEBUG(tident,rpInfo->tprPath<<" maps "<<tpcPath<<" -> "<<lnkbuff);
1217  }
1218  }
1219 
1220 // At this point we may or may not have the final endpoint. An error here could
1221 // be due to write error recovery, so make allowance for that.
1222 //
1223  if (rpInfo->dstURL)
1224  {if (!XrdPosixXrootd::Stat(rpInfo->dstURL, buff))
1225  {if (!(rpInfo->fSize = buff->st_size)) rpInfo->fSize = 1;
1226  return XrdOssOK;
1227  }
1228  free(rpInfo->dstURL);
1229  rpInfo->dstURL = 0;
1230  }
1231 
1232 // We don't have the final endpoint. If we ever had it before, then punt.
1233 //
1234  if (rpInfo->fSize)
1235  {memset(buff, 0, sizeof(struct stat));
1236  buff->st_size = rpInfo->fSize;
1237  return XrdOssOK;
1238  }
1239 
1240 // If we are here then maybe the reproxy option was the wrong config setting.
1241 // Give stat a try on the origin we'll retry resolution on the next stat.
1242 //
1243  XrdOucEnv fstatEnv(0, 0, entity);
1244 
1245  if (XrdProxySS.Stat(tpcPath, buff, 0, &fstatEnv))
1246  memset(buff, 0, sizeof(struct stat));
1247  return XrdOssOK;
1248 }
1249 
1250 /******************************************************************************/
1251 /* f s y n c */
1252 /******************************************************************************/
1253 
1254 /*
1255  Function: Synchronize associated file.
1256 
1257  Input: None.
1258 
1259  Output: Returns XrdOssOK upon success and -errno upon failure.
1260 */
1262 {
1263  if (fd < 0) return -XRDOSS_E8004;
1264 
1265  return (XrdPosixXrootd::Fsync(fd) ? -errno : XrdOssOK);
1266 }
1267 
1268 /******************************************************************************/
1269 /* f t r u n c a t e */
1270 /******************************************************************************/
1271 
1272 /*
1273  Function: Set the length of associated file to 'flen'.
1274 
1275  Input: flen - The new size of the file.
1276 
1277  Output: Returns XrdOssOK upon success and -errno upon failure.
1278 
1279  Notes: If 'flen' is smaller than the current size of the file, the file
1280  is made smaller and the data past 'flen' is discarded. If 'flen'
1281  is larger than the current size of the file, a hole is created
1282  (i.e., the file is logically extended by filling the extra bytes
1283  with zeroes).
1284 
1285  If compiled w/o large file support, only lower 32 bits are used.
1286  used.
1287 
1288  Currently not supported for proxies.
1289 */
1290 int XrdPssFile::Ftruncate(unsigned long long flen)
1291 {
1292  if (fd < 0) return -XRDOSS_E8004;
1293 
1294  return (XrdPosixXrootd::Ftruncate(fd, flen) ? -errno : XrdOssOK);
1295 }
1296 
1297 /******************************************************************************/
1298 /* I n t e r n a l M e t h o d s */
1299 /******************************************************************************/
1300 
1301 int XrdPssSys::Info(int rc)
1302 {
1304  return -rc;
1305 }
1306 
1307 /******************************************************************************/
1308 /* P 2 D S T */
1309 /******************************************************************************/
1310 
1311 int XrdPssSys::P2DST(int &retc, char *hBuff, int hBlen, XrdPssSys::PolAct pEnt,
1312  const char *path)
1313 {
1314  const char *Slash;
1315  int n;
1316 
1317 // Extract out the destination
1318 //
1319  Slash = index(path, '/');
1320  if (!Slash || (n = (Slash - path)) == 0) {retc = -EINVAL; return 0;}
1321  if (n >= hBlen) {retc = -ENAMETOOLONG; return 0;}
1322  strncpy(hBuff, path, n); hBuff[n] = 0;
1323 
1324 // Check if we need to authorize the outgoing connection
1325 //
1326  if (Police[pEnt] && !Police[pEnt]->Authorize(hBuff))
1327  {retc = -EACCES; return 0;}
1328 
1329 // All is well
1330 //
1331  return n;
1332 }
1333 
1334 /******************************************************************************/
1335 /* P 2 O U T */
1336 /******************************************************************************/
1337 
1338 int XrdPssSys::P2OUT(char *pbuff, int pblen, XrdPssUrlInfo &uInfo)
1339 { const char *theID = uInfo.getID();
1340  const char *pname, *path, *thePath;
1341  char hBuff[288];
1342  int retc, n;
1343 
1344 // Setup the path
1345 //
1346  thePath = path = uInfo.thePath();
1347 
1348 // Make sure the path is valid for an outgoing proxy
1349 //
1350  if (*path == '/') path++;
1351  if ((pname = XrdPssUtils::valProt(path, n, 1))) path += n;
1352  else {if (!hdrLen) return -ENOTSUP;
1353  n = snprintf(pbuff, pblen, hdrData, theID, thePath);
1354  if (n >= pblen || !uInfo.addCGI(pbuff, pbuff+n, pblen-n))
1355  return -ENAMETOOLONG;
1356  return 0;
1357  }
1358 
1359 // Objectid must be handled differently as they have not been refalgomized
1360 //
1361  if (*thePath != '/')
1362  {if (*path == '/')
1363  {path++;
1364  if (*path == '/') theID = "";
1365  }
1366  if (Police[PolObj] && !P2DST(retc, hBuff, sizeof(hBuff), PolObj,
1367  path+(*path == '/' ? 1:0))) return 0;
1368  n = snprintf(pbuff, pblen, "%s%s%s", pname, theID, path);
1369  if (n >= pblen || !uInfo.addCGI(pbuff, pbuff+n, pblen-n))
1370  return -ENAMETOOLONG;
1371  return 0;
1372  }
1373 
1374 // Extract out the destination. We need to do this because the front end
1375 // will have extracted out double slashes and we need to add them back. We
1376 // also authorize the outgoing connection if we need to in the process.
1377 //
1378  if (!(n = P2DST(retc, hBuff, sizeof(hBuff), PolPath, path))) return 0;
1379  path += n;
1380 
1381 // Create the new path. If the url already contains a userid then use it
1382 // instead or our internally generated one. We may need an option for this
1383 // as it may result in unintended side-effects but for now we do that.
1384 //
1385  if (index(hBuff, '@')) theID= "";
1386  n = snprintf(pbuff,pblen,"%s%s%s/%s",pname,theID,hBuff,path);
1387 
1388 // Make sure the path will fit
1389 //
1390  if (n >= pblen || !uInfo.addCGI(pbuff, pbuff+n, pblen-n))
1391  return -ENAMETOOLONG;
1392 
1393 // All done
1394 //
1395  return 0;
1396 }
1397 
1398 /******************************************************************************/
1399 /* P 2 U R L */
1400 /******************************************************************************/
1401 
1402 int XrdPssSys::P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo, bool doN2N)
1403 {
1404 
1405 // If this is an outgoing proxy then we need to do someother work
1406 //
1407  if (outProxy) return P2OUT(pbuff, pblen, uInfo);
1408 
1409 // Do url generation for actual known origin
1410 //
1411  const char *path = uInfo.thePath();
1412  int retc, pfxLen;
1413  char Apath[MAXPATHLEN+1];
1414 
1415 // Setup to process url generation
1416 //
1417  path = uInfo.thePath();
1418 
1419 // First, apply the N2N mapping if necessary. If N2N fails then the whole
1420 // mapping fails and ENAMETOOLONG will be returned.
1421 //
1422  if (doN2N && XrdProxySS.theN2N)
1423  {if ((retc = XrdProxySS.theN2N->lfn2pfn(path, Apath, sizeof(Apath))))
1424  {if (retc > 0) return -retc;}
1425  path = Apath;
1426  }
1427 
1428 // Format the header into the buffer and check if we overflowed. Note that we
1429 // defer substitution of the path as we need to know where the path is.
1430 //
1431  if (fileOrgn) pfxLen = snprintf(pbuff, pblen, hdrData, path);
1432  else pfxLen = snprintf(pbuff, pblen, hdrData, uInfo.getID(), path);
1433  if (pfxLen >= pblen) return -ENAMETOOLONG;
1434 
1435 // Add any cgi information
1436 //
1437  if (!fileOrgn && uInfo.hasCGI())
1438  {if (!uInfo.addCGI(pbuff, pbuff+pfxLen, pblen-pfxLen))
1439  return -ENAMETOOLONG;
1440  }
1441 
1442 // All done
1443 //
1444  return 0;
1445 }
XrdAccAuthorize * Authorize
Definition: XrdAccTest.cc:61
#define tident
#define DEBUG(x)
Definition: XrdBwmTrace.hh:54
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
struct stat Stat
Definition: XrdCks.cc:49
#define XRDOSS_E8002
Definition: XrdOssError.hh:36
#define XRDOSS_E8003
Definition: XrdOssError.hh:37
#define XRDOSS_E8004
Definition: XrdOssError.hh:38
#define XRDOSS_E8001
Definition: XrdOssError.hh:35
@ Info
#define XRDOSS_HASPRXY
Definition: XrdOss.hh:477
#define XRDOSS_Online
Definition: XrdOss.hh:468
#define XrdOssOK
Definition: XrdOss.hh:50
#define XRDOSS_HASNOSF
Definition: XrdOss.hh:478
#define XRDOSS_HASPGRW
Definition: XrdOss.hh:475
#define XRDOSS_resonly
Definition: XrdOss.hh:486
#define XRDEXP_NOTRW
Definition: XrdOucExport.hh:45
#define XRDEXP_FORCERO
Definition: XrdOucExport.hh:43
#define XRDEXP_STAGE
Definition: XrdOucExport.hh:52
std::string obfuscateAuth(const std::string &input)
int stat(const char *path, struct stat *buf)
#define DEBUGON
#define IS_FWDPATH(x)
Definition: XrdPssUtils.hh:64
#define ENOATTR
Definition: XrdPss.cc:80
XrdVERSIONINFO(XrdOssGetStorageSystem2, XrdPss)
#define isNOSTAGE(_x_)
Definition: XrdPss.cc:87
XrdOss * XrdOssGetStorageSystem2(XrdOss *native_oss, XrdSysLogger *Logger, const char *cFN, const char *parms, XrdOucEnv *envp)
Definition: XrdPss.cc:144
#define O_DIRECT
Definition: XrdPss.cc:76
#define isREADONLY(_x_)
Definition: XrdPss.cc:89
int Mode
struct myOpts opts
const char * Arg1
PLUGINO, PLUGION, PLUGXC.
int Arg2Len
Length or -count of args in extension.
#define SFS_ERROR
int Arg1Len
Length.
#define SFS_FSCTL_PLUGXC
< SFS_FSCTL_PLUGIN/PLUGIO/PLUGXC parms
size_t strlcpy(char *dst, const char *src, size_t sz)
virtual int FSctl(const int cmd, int alen, const char *args, XrdSfsFile &file, XrdOucErrInfo &eInfo, const XrdSecEntity *client=0)=0
static const uint64_t doCalc
pgw: Calculate checksums
Definition: XrdOss.hh:225
const char * tident
Definition: XrdOss.hh:453
int fd
Definition: XrdOss.hh:455
static const uint64_t Verify
all: Verify checksums
Definition: XrdOss.hh:223
void * GetPtr(const char *varname)
Definition: XrdOucEnv.cc:281
char * Get(const char *varname)
Definition: XrdOucEnv.hh:69
const XrdSecEntity * secEnv() const
Definition: XrdOucEnv.hh:107
char * Env(int &envlen)
Definition: XrdOucEnv.hh:48
void Put(const char *varname, const char *value)
Definition: XrdOucEnv.hh:85
virtual int lfn2pfn(const char *lfn, char *buff, int blen)=0
unsigned long long Find(const char *pathname)
Definition: XrdOucPList.hh:112
static void csCalc(const char *data, off_t offs, size_t count, uint32_t *csval)
static bool csVer(dataInfo &dInfo, off_t &bado, int &badc)
static int csNum(off_t offs, int count)
Compute the required size of a checksum vector based on offset & length.
static bool OpenFC(const char *path, int oflag, mode_t mode, XrdPosixInfo &Info)
static int Stats(const char *theID, char *buff, int blen)
static void EnvInfo(XrdOucEnv &theEnv)
static ssize_t pgWrite(int fildes, void *buffer, off_t offset, size_t wrlen, std::vector< uint32_t > &csvec, uint64_t opts=0, XrdPosixCallBackIO *cbp=0)
static const uint64_t forceCS
static ssize_t pgRead(int fildes, void *buffer, off_t offset, size_t rdlen, std::vector< uint32_t > &csvec, uint64_t opts=0, XrdPosixCallBackIO *cbp=0)
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 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 VRead(int fildes, const XrdOucIOVec *readV, int n, XrdPosixCallBackIO *cbp)
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 Readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
static int QueryError(std::string &emsg, int fd=-1, bool reset=true)
static int Ftruncate(int fildes, off_t offset)
Ftruncate() conforms to POSIX.1-2001 ftruncate()
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 int Fstat(int fildes, struct stat *buf)
Fstat() conforms to POSIX.1-2001 fstat()
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()
int Close(long long *retsz=0)
Definition: XrdPss.cc:736
int Opendir(const char *, XrdOucEnv &)
Definition: XrdPss.cc:650
int Readdir(char *buff, int blen)
Definition: XrdPss.cc:707
ssize_t ReadRaw(void *, off_t, size_t)
Definition: XrdPss.cc:1133
int Fsync()
Definition: XrdPss.cc:1261
virtual int Close(long long *retsz=0)
Definition: XrdPss.cc:907
virtual int Open(const char *, int, mode_t, XrdOucEnv &)
Definition: XrdPss.cc:771
ssize_t Read(off_t, size_t)
Definition: XrdPss.cc:1057
int Fstat(struct stat *)
Definition: XrdPss.cc:1175
ssize_t Write(const void *, off_t, size_t)
Definition: XrdPss.cc:1153
ssize_t ReadV(XrdOucIOVec *readV, int n)
Definition: XrdPss.cc:1095
ssize_t pgRead(void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
Definition: XrdPss.cc:948
int Ftruncate(unsigned long long)
Definition: XrdPss.cc:1290
ssize_t pgWrite(void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
Definition: XrdPss.cc:1001
int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0) override
Definition: XrdPss.cc:350
static int P2OUT(char *pbuff, int pblen, XrdPssUrlInfo &uInfo)
Definition: XrdPss.cc:1338
int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0) override
Definition: XrdPss.cc:600
XrdPssSys()
Definition: XrdPss.cc:165
virtual void Connect(XrdOucEnv &) override
Definition: XrdPss.cc:234
int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0) override
Definition: XrdPss.cc:559
int Stats(char *bp, int bl) override
Definition: XrdPss.cc:541
static int Info(int rc)
Definition: XrdPss.cc:1301
static bool deferID
Definition: XrdPss.hh:207
static int hdrLen
Definition: XrdPss.hh:198
static const char * hdrData
Definition: XrdPss.hh:197
int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0) override
Definition: XrdPss.cc:490
int Init(XrdSysLogger *, const char *) override
Definition: XrdPss.hh:163
static char * fileOrgn
Definition: XrdPss.hh:195
static int P2DST(int &retc, char *hBuff, int hBlen, PolAct pType, const char *path)
Definition: XrdPss.cc:1311
static bool dcaCheck
Definition: XrdPss.hh:205
static bool reProxy
Definition: XrdPss.hh:208
int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0) override
Definition: XrdPss.cc:223
@ PolObj
Definition: XrdPss.hh:178
@ PolPath
Definition: XrdPss.hh:178
void EnvInfo(XrdOucEnv *envP) override
Definition: XrdPss.cc:303
static XrdNetSecurity * Police[PolNum]
Definition: XrdPss.hh:193
static XrdOucPListAnchor XPList
Definition: XrdPss.hh:191
static int P2URL(char *pbuff, int pblen, XrdPssUrlInfo &uInfo, bool doN2N=true)
Definition: XrdPss.cc:1402
int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0) override
Definition: XrdPss.cc:389
int Lfn2Pfn(const char *Path, char *buff, int blen) override
Definition: XrdPss.cc:318
static bool xLfn2Pfn
Definition: XrdPss.hh:204
virtual int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0) override
Definition: XrdPss.cc:272
virtual void Disc(XrdOucEnv &) override
Definition: XrdPss.cc:283
int Rename(const char *, const char *, XrdOucEnv *eP1=0, XrdOucEnv *eP2=0) override
Definition: XrdPss.cc:437
static bool dcaWorld
Definition: XrdPss.hh:206
const char * thePath()
const char * Tident()
void setID(const char *tid=0)
const char * getID()
bool addCGI(const char *prot, char *buff, int blen)
static const char * valProt(const char *pname, int &plen, int adj=0)
Definition: XrdPssUtils.cc:82
const char * tident
Trace identifier always preset.
Definition: XrdSecEntity.hh:81
unsigned int ueid
Unique ID of entity instance.
Definition: XrdSecEntity.hh:79
bool Register(const char *lgnid, const XrdSecEntity *Ident, bool doReplace=false, bool defer=false)
Definition: XrdSecsssID.cc:224
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
Definition: XrdSysError.cc:141
XrdSysLogger * logger(XrdSysLogger *lp=0)
Definition: XrdSysError.hh:141
void SetLogger(XrdSysLogger *logp)
Definition: XrdSysTrace.cc:65
XrdVersionInfo myVersion
XrdOucEnv theEnv
XrdSysLogger Logger
Definition: XrdGlobals.cc:47
int Opts
Definition: XrdMpxStats.cc:58
XrdOucName2Name * theN2N
Definition: XrdPosixFile.cc:62
XrdSecsssID * idMapper
Definition: XrdPss.cc:113
XrdOfsFSctl_PI * cacheFSctl
Definition: XrdPss.cc:111
XrdSysTrace SysTrace("Pss", 0)
Definition: XrdPssCks.cc:55
XrdScheduler * schedP
Definition: XrdPss.cc:105
bool xrdProxy
Definition: XrdPss.cc:127
XrdOucSid * sidP
Definition: XrdPss.cc:107
static const int PBsz
Definition: XrdPss.cc:119
XrdSysError eDest(0, "pss_")
static const char * osslclCGI
Definition: XrdPss.cc:117
bool outProxy
Definition: XrdPss.cc:125
bool idMapAll
Definition: XrdPss.cc:123
thread_local XrdOucECMsg ecMsg("[pss]")
int rpFD
Definition: XrdPss.cc:121
static XrdPssSys XrdProxySS
Definition: XrdPss.cc:101
static const char * ofslclCGI
Definition: XrdPss.cc:115
XrdOucEnv * envP
Definition: XrdPss.cc:109