XRootD
Loading...
Searching...
No Matches
XrdOssApi.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d O s s A p i . c c */
4/* */
5/* (c) 2006 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 <strings.h>
39#include <cstdio>
40#if defined(__linux__)
41#include <linux/fs.h>
42#endif
43#include <sys/file.h>
44#include <sys/ioctl.h>
45#include <sys/stat.h>
46#include <sys/types.h>
47#include <sys/param.h>
48#ifdef __solaris__
49#include <sys/vnode.h>
50#endif
51
52#include "XrdVersion.hh"
53
54#include "XrdFrc/XrdFrcXAttr.hh"
55#include "XrdOss/XrdOssApi.hh"
56#include "XrdOss/XrdOssCache.hh"
58#include "XrdOss/XrdOssError.hh"
59#include "XrdOss/XrdOssMio.hh"
60#include "XrdOss/XrdOssTrace.hh"
62#include "XrdOuc/XrdOucEnv.hh"
65#include "XrdOuc/XrdOucXAttr.hh"
66#include "XrdSfs/XrdSfsFlags.hh"
68#include "XrdSys/XrdSysError.hh"
69#include "XrdSys/XrdSysFD.hh"
73
74#ifdef XRDOSSCX
75#include "oocx_CXFile.h"
76#endif
77
78/******************************************************************************/
79/* E r r o r R o u t i n g O b j e c t */
80/******************************************************************************/
81
83
85
87
88/******************************************************************************/
89/* S t o r a g e S y s t e m I n s t a n t i a t o r */
90/******************************************************************************/
91
92char XrdOssSys::tryMmap = 0;
93char XrdOssSys::chkMmap = 0;
94
95/******************************************************************************/
96/* XrdOssGetSS (a.k.a. XrdOssGetStorageSystem) */
97/******************************************************************************/
98
99// This function is called by the OFS layer to retrieve the Storage System
100// object. If a plugin library has been specified, then this function will
101// return the object provided by XrdOssGetStorageSystem() within the library.
102//
103XrdOss *XrdOssGetSS(XrdSysLogger *Logger, const char *config_fn,
104 const char *OssLib, const char *OssParms,
105 XrdOucEnv *envP, XrdVersionInfo &urVer)
106{
107 static XrdOssSys myOssSys;
108 extern XrdSysError OssEroute;
109 XrdOucPinLoader *myLib;
110 XrdOss *ossP;
111
112// Verify that versions are compatible.
113//
114 if (urVer.vNum != myOssSys.myVersion->vNum
115 && !XrdSysPlugin::VerCmp(urVer, *(myOssSys.myVersion))) return 0;
116
117// Set logger for tracing and errors
118//
119 OssTrace.SetLogger(Logger);
120 OssEroute.logger(Logger);
121
122// If no library has been specified, return the default object
123//
124 if (!OssLib) {if (myOssSys.Init(Logger, config_fn, envP)) return 0;
125 else return (XrdOss *)&myOssSys;
126 }
127
128// Create a plugin object. Take into account the proxy library. Eventually,
129// we will need to support other core libraries. But, for now, this will do.
130//
131 if (!(myLib = new XrdOucPinLoader(&OssEroute, myOssSys.myVersion,
132 "osslib", OssLib))) return 0;
133// Declare the interface versions
134//
136 const char *epName1 = "XrdOssGetStorageSystem";
138 const char *epName2 ="?XrdOssGetStorageSystem2";
139
140// First try finding version 2 of the initializer. If that fails try version 1.
141// In the process, we will get an oss object if we succeed at all.
142//
143 getOSS2 = (XrdOssGetStorageSystem2_t)myLib->Resolve(epName2);
144 if (getOSS2) ossP = getOSS2((XrdOss *)&myOssSys, Logger, config_fn,
145 OssParms, envP);
146 else {getOSS1 = (XrdOssGetStorageSystem_t)myLib->Resolve(epName1);
147 if (!getOSS1) return 0;
148 ossP = getOSS1((XrdOss *)&myOssSys, Logger, config_fn, OssParms);
149 }
150
151// Call the legacy EnvInfo() method and set what library we are using if it
152// differs from what we wre passed.
153//
154 if (ossP && envP)
155 {ossP->EnvInfo(envP);
156 if (envP && strcmp(OssLib, myLib->Path()))
157 envP->Put("oss.lib", myLib->Path());
158 }
159
160// All done
161//
162 delete myLib;
163 return ossP;
164}
165
166/******************************************************************************/
167/* X r d O s s D e f a u l t S S */
168/******************************************************************************/
169
171 const char *cfg_fn,
172 XrdVersionInfo &urVer)
173{
174 return XrdOssGetSS(logger, cfg_fn, 0, 0, 0, urVer);
175}
176
177/******************************************************************************/
178/* o o s s _ S y s M e t h o d s */
179/******************************************************************************/
180/******************************************************************************/
181/* i n i t */
182/******************************************************************************/
183
184/*
185 Function: Initialize staging subsystem
186
187 Input: None
188
189 Output: Returns zero upon success otherwise (-errno).
190*/
191int XrdOssSys::Init(XrdSysLogger *lp, const char *configfn, XrdOucEnv *envP)
192{
193 int retc;
194
195// No need to do the herald thing as we are the default storage system
196//
197 OssEroute.logger(lp);
198
199// Initialize the subsystems
200//
201 XrdOssSS = this;
202 if ( (retc = Configure(configfn, OssEroute, envP)) ) return retc;
203
204// All done.
205//
206 return XrdOssOK;
207}
208
209/******************************************************************************/
210/* L f n 2 P f n */
211/******************************************************************************/
212
213int XrdOssSys::Lfn2Pfn(const char *oldp, char *newp, int blen)
214{
215 if (lcl_N2N) return -(lcl_N2N->lfn2pfn(oldp, newp, blen));
216 if ((int)strlen(oldp) >= blen) return -ENAMETOOLONG;
217 strcpy(newp, oldp);
218 return 0;
219}
220
221const char *XrdOssSys::Lfn2Pfn(const char *oldp, char *newp, int blen, int &rc)
222{
223 if (!lcl_N2N) {rc = 0; return oldp;}
224 if ((rc = -(lcl_N2N->lfn2pfn(oldp, newp, blen)))) return 0;
225 return newp;
226}
227
228/******************************************************************************/
229/* G e n L o c a l P a t h */
230/******************************************************************************/
231
232/* GenLocalPath() generates the path that a file will have in the local file
233 system. The decision is made based on the user-given path (typically what
234 the user thinks is the local file system path). The output buffer where the
235 new path is placed must be at least MAXPATHLEN bytes long.
236*/
237int XrdOssSys::GenLocalPath(const char *oldp, char *newp)
238{
239 if (lcl_N2N) return -(lcl_N2N->lfn2pfn(oldp, newp, MAXPATHLEN));
240 if (strlen(oldp) >= MAXPATHLEN) return -ENAMETOOLONG;
241 strcpy(newp, oldp);
242 return 0;
243}
244
245/******************************************************************************/
246/* G e n R e m o t e P a t h */
247/******************************************************************************/
248
249/* GenRemotePath() generates the path that a file will have in the remote file
250 system. The decision is made based on the user-given path (typically what
251 the user thinks is the local file system path). The output buffer where the
252 new path is placed must be at least MAXPATHLEN bytes long.
253*/
254int XrdOssSys::GenRemotePath(const char *oldp, char *newp)
255{
256 if (rmt_N2N) return -(rmt_N2N->lfn2rfn(oldp, newp, MAXPATHLEN));
257 if (strlen(oldp) >= MAXPATHLEN) return -ENAMETOOLONG;
258 strcpy(newp, oldp);
259 return 0;
260}
261
262/******************************************************************************/
263/* C l o n e */
264/******************************************************************************/
265/*
266 Function: Clone contents of a file from another file.
267
268 Input: srcFile - clone contents of this file.
269
270 Output: Returns XrdOssOK upon success and -errno or -osserr upon failure.
271*/
272
274{
275#if defined(FICLONE)
276 if (!canClone)
277 return -EPERM;
278
279 if (fd<0)
280 return -EBADF;
281 if (srcFile.getFD() < 0)
282 return -EBADF;
283
284 if (ioctl(fd, FICLONE, srcFile.getFD())==-1)
285 return -errno;
286
287 return XrdOssOK;
288#else
289 return -ENOTSUP;
290#endif
291}
292
293int XrdOssFile::Clone(const std::vector<XrdOucCloneSeg> &cVec)
294{
295#if defined(FICLONERANGE)
296 if (!canClone)
297 return -EPERM;
298
299 if (fd<0)
300 return -EBADF;
301
302 for(auto &seg: cVec)
303 {struct file_clone_range fr;
304 fr.src_fd = seg.srcFD;
305 fr.src_offset = seg.srcOffs;
306 fr.src_length = seg.srcLen;
307 fr.dest_offset = seg.dstOffs;
308 if (ioctl(fd, FICLONERANGE, &fr) == -1) return -errno;
309 }
310
311 return XrdOssOK;
312#else
313 return -ENOTSUP;
314#endif
315}
316
317/******************************************************************************/
318/* C h m o d */
319/******************************************************************************/
320/*
321 Function: Change file mode.
322
323 Input: path - Is the fully qualified name of the target file.
324 mode - The new mode that the file is to have.
325 envP - Environmental information.
326
327 Output: Returns XrdOssOK upon success and -errno upon failure.
328
329 Notes: Files are only changed in the local disk cache.
330*/
331
332int XrdOssSys::Chmod(const char *path, mode_t mode, XrdOucEnv *envP)
333{
334 char actual_path[MAXPATHLEN+1], *local_path;
335 int retc;
336
337// Generate local path
338//
339 if (lcl_N2N)
340 if ((retc = lcl_N2N->lfn2pfn(path, actual_path, sizeof(actual_path))))
341 return retc;
342 else local_path = actual_path;
343 else local_path = (char *)path;
344
345// Change the file only in the local filesystem.
346//
347 return (chmod(local_path, mode) ? -errno : XrdOssOK);
348}
349
350/******************************************************************************/
351/* M k d i r */
352/******************************************************************************/
353/*
354 Function: Create a directory
355
356 Input: path - Is the fully qualified name of the new directory.
357 mode - The new mode that the directory is to have.
358 mkpath - If true, makes the full path.
359 envP - Environmental information.
360
361 Output: Returns XrdOssOK upon success and -errno upon failure.
362
363 Notes: Directories are only created in the local disk cache.
364*/
365
366int XrdOssSys::Mkdir(const char *path, mode_t mode, int mkpath, XrdOucEnv *envP)
367{
368 char actual_path[MAXPATHLEN+1], *local_path;
369 int retc;
370
371// Make sure we can modify this path
372//
373 Check_RW(Mkdir, path, "create directory");
374
375// Generate local path
376//
377 if (lcl_N2N)
378 if ((retc = lcl_N2N->lfn2pfn(path, actual_path, sizeof(actual_path))))
379 return retc;
380 else local_path = actual_path;
381 else local_path = (char *)path;
382
383// Create the directory or full path only in the loal file system
384//
385 if (!mkdir(local_path, mode)) return XrdOssOK;
386 if (mkpath && errno == ENOENT){return Mkpath(local_path, mode);}
387 if (errno != EEXIST) return -errno;
388
389// Check if this is a duplicate request
390//
391 struct stat Stat;
392 static const mode_t accBits = (S_IRWXU|S_IRWXG|S_IRWXO);
393
394 if (!stat(local_path, &Stat) && S_ISDIR(Stat.st_mode)
395 && mode == (Stat.st_mode & accBits)) return XrdOssOK;
396 return -EEXIST;
397}
398
399/******************************************************************************/
400/* M k p a t h */
401/******************************************************************************/
402/*
403 Function: Create a directory path
404
405 Input: path - Is the fully qualified *local* name of the new path.
406 mode - The new mode that each new directory is to have.
407
408 Output: Returns XrdOssOK upon success and -errno upon failure.
409
410 Notes: Directories are only created in the local disk cache.
411*/
412
413int XrdOssSys::Mkpath(const char *path, mode_t mode)
414{
415 char local_path[MAXPATHLEN+1], *next_path;
416 int i = strlen(path);
417
418// Copy the path so we can modify it
419//
420 strcpy(local_path, path);
421
422// Trim off the trailing slashes so we can have predictable behaviour
423//
424 while(i && local_path[--i] == '/') local_path[i] = '\0';
425 if (!i) return -ENOENT;
426
427// Start creating directories starting with the root
428//
429 next_path = local_path;
430 while((next_path = index(next_path+1, int('/'))))
431 {*next_path = '\0';
432 if (mkdir(local_path, mode) && errno != EEXIST) return -errno;
433 *next_path = '/';
434 }
435
436// Create last component and return
437//
438 if (mkdir(local_path, mode) && errno != EEXIST) return -errno;
439 return XrdOssOK;
440}
441
442
443/******************************************************************************/
444/* S t a t s */
445/******************************************************************************/
446
447/*
448 Function: Return statistics.
449
450 Input: buff - Buffer where the statistics are to be placed.
451 blen - The length of the buffer.
452
453 Output: Returns number of bytes placed in the buffer less null byte.
454*/
455
456int XrdOssSys::Stats(char *buff, int blen)
457{
458 static const char statfmt1[] = "<stats id=\"oss\" v=\"2\">";
459 static const char statfmt2[] = "</stats>";
460 static const int statflen = sizeof(statfmt1) + sizeof(statfmt2);
461 char *bp = buff;
462 int n;
463
464// If only size wanted, return what size we need
465//
466 if (!buff) return statflen + getStats(0,0);
467
468// Make sure we have enough space
469//
470 if (blen < statflen) return 0;
471 strcpy(bp, statfmt1);
472 bp += sizeof(statfmt1)-1; blen -= sizeof(statfmt1)-1;
473
474// Generate space statistics
475//
476 n = getStats(bp, blen);
477 bp += n; blen -= n;
478
479// Add trailer
480//
481 if (blen >= (int)sizeof(statfmt2))
482 {strcpy(bp, statfmt2); bp += (sizeof(statfmt2)-1);}
483 return bp - buff;
484}
485
486/******************************************************************************/
487/* T r u n c a t e */
488/******************************************************************************/
489
490/*
491 Function: Truncate a file.
492
493 Input: path - Is the fully qualified name of the target file.
494 size - The new size that the file is to have.
495 envP - Environmental information.
496
497 Output: Returns XrdOssOK upon success and -errno upon failure.
498
499 Notes: Files are only changed in the local disk cache.
500*/
501
502int XrdOssSys::Truncate(const char *path, unsigned long long size,
503 XrdOucEnv *envP)
504{
505 struct stat statbuff;
506 char actual_path[MAXPATHLEN+1], *local_path;
507 long long oldsz;
508 int retc;
509
510// Make sure we can modify this path
511//
512 Check_RW(Truncate, path, "truncate");
513
514// Generate local path
515//
516 if (lcl_N2N)
517 if ((retc = lcl_N2N->lfn2pfn(path, actual_path, sizeof(actual_path))))
518 return retc;
519 else local_path = actual_path;
520 else local_path = (char *)path;
521
522// Get file info to do the correct adjustment
523//
524 if (lstat(local_path, &statbuff)) return -errno;
525 else if ((statbuff.st_mode & S_IFMT) == S_IFDIR) return -EISDIR;
526 else if ((statbuff.st_mode & S_IFMT) == S_IFLNK)
527 {struct stat buff;
528 if (stat(local_path, &buff)) return -errno;
529 oldsz = buff.st_size;
530 } else oldsz = statbuff.st_size;
531
532// Change the file only in the local filesystem and make space adjustemt
533//
534 if (truncate(local_path, size)) return -errno;
535 XrdOssCache::Adjust(local_path,static_cast<long long>(size)-oldsz,&statbuff);
536 return XrdOssOK;
537}
538
539/******************************************************************************/
540/* P r i v a t e M e t h o d s */
541/******************************************************************************/
542/******************************************************************************/
543/* o o s s _ D i r M e t h o d s */
544/******************************************************************************/
545/******************************************************************************/
546/* o p e n d i r */
547/******************************************************************************/
548
549/*
550 Function: Open the directory `path' and prepare for reading.
551
552 Input: path - The fully qualified name of the directory to open.
553 env - Environmental information.
554
555 Output: Returns XrdOssOK upon success; (-errno) otherwise.
556*/
557int XrdOssDir::Opendir(const char *dir_path, XrdOucEnv &Env)
558{
559 EPNAME("Opendir");
560 char actual_path[MAXPATHLEN+1], *local_path, *remote_path;
561 int retc;
562
563// Return an error if this object is already open
564//
565 if (isopen) return -XRDOSS_E8001;
566
567// Get the processing flags for this directory
568//
569 unsigned long long pflags = XrdOssSS->PathOpts(dir_path);
570 if (pflags & XRDEXP_STAGE) dOpts |= isStage;
571 if (pflags & XRDEXP_NODREAD) dOpts |= noDread;
572 if (pflags & XRDEXP_NOCHECK) dOpts |= noCheck;
573 ateof = false;
574
575// Generate local path
576//
577 if (XrdOssSS->lcl_N2N)
578 if ((retc = XrdOssSS->lcl_N2N->lfn2pfn(dir_path, actual_path, sizeof(actual_path))))
579 return retc;
580 else local_path = actual_path;
581 else local_path = (char *)dir_path;
582
583// If this is a local filesystem request, open locally. We also obtian the
584// underlying file descriptor.
585//
586 if (!(dOpts & isStage) || (dOpts & noDread))
587 {TRACE(Opendir, "lcl path " <<local_path <<" (" <<dir_path <<")");
588 if (!(lclfd = XrdSysFD_OpenDir(local_path))) return -errno;
589 fd = dirfd(lclfd);
590 isopen = true;
591 return XrdOssOK;
592 }
593
594// Generate remote path
595//
596 if (XrdOssSS->rmt_N2N)
597 if ((retc = XrdOssSS->rmt_N2N->lfn2rfn(dir_path, actual_path, sizeof(actual_path))))
598 return retc;
599 else remote_path = actual_path;
600 else remote_path = (char *)dir_path;
601
602 TRACE(Opendir, "rmt path " << remote_path <<" (" << dir_path <<")");
603
604// Originally, if MSS directories were not to be read, we ould simply check
605// if the path was a directory and return an error if not. That was superceeded
606// by making NODREAD mean to read the local directory only (which is not always
607// ideal). So, we keep the code below but comment it out for now.
608//
609// if ((dOpts & noDread) && !(dOpts & noCheck))
610// {struct stat fstat;
611// if ((retc = XrdOssSS->MSS_Stat(remote_path,&fstat))) return retc;
612// if (!(S_ISDIR(fstat.st_mode))) return -ENOTDIR;
613// isopen = true;
614// return XrdOssOK;
615// }
616
617// Open the directory at the remote location.
618//
619 if (!(mssfd = XrdOssSS->MSS_Opendir(remote_path, retc))) return retc;
620 isopen = true;
621 return XrdOssOK;
622}
623
624/******************************************************************************/
625/* r e a d d i r */
626/******************************************************************************/
627
628/*
629 Function: Read the next entry if directory associated with this object.
630
631 Input: buff - Is the address of the buffer that is to hold the next
632 directory name.
633 blen - Size of the buffer.
634
635 Output: Upon success, places the contents of the next directory entry
636 in buff. When the end of the directory is encountered buff
637 will be set to the null string.
638
639 Upon failure, returns a (-errno).
640
641 Warning: The caller must provide proper serialization.
642*/
643int XrdOssDir::Readdir(char *buff, int blen)
644{
645 struct dirent *rp;
646
647// Check if this object is actually open
648//
649 if (!isopen) return -XRDOSS_E8002;
650
651// Perform local reads if this is a local directory
652//
653 if (lclfd)
654 {errno = 0;
655 while((rp = readdir(lclfd)))
656 {strlcpy(buff, rp->d_name, blen);
657#ifdef HAVE_FSTATAT
658 if (Stat && fstatat(fd, rp->d_name, Stat, 0))
659 {if (errno != ENOENT) return -errno;
660 errno = 0;
661 continue;
662 }
663#endif
664 return XrdOssOK;
665 }
666 *buff = '\0'; ateof = true;
667 return -errno;
668 }
669
670// Simulate the read operation, if need be.
671//
672 if (dOpts & noDread)
673 {if (ateof) *buff = '\0';
674 else {*buff = '.'; ateof = true;}
675 return XrdOssOK;
676 }
677
678// Perform a remote read
679//
680 return XrdOssSS->MSS_Readdir(mssfd, buff, blen);
681}
682
683/******************************************************************************/
684/* S t a t R e t */
685/******************************************************************************/
686/*
687 Function: Set stat buffer pointerto automatically stat returned entries.
688
689 Input: buff - Pointer to the stat buffer.
690
691 Output: Upon success, return 0.
692
693 Upon failure, returns a (-errno).
694
695 Warning: The caller must provide proper serialization.
696*/
697int XrdOssDir::StatRet(struct stat *buff)
698{
699
700// Check if this object is actually open
701//
702 if (!isopen) return -XRDOSS_E8002;
703
704// We only support autostat for local directories
705//
706 if (!lclfd) return -ENOTSUP;
707
708// We do not support autostat unless we have the fstatat function
709//
710#ifndef HAVE_FSTATAT
711 return -ENOTSUP;
712#endif
713
714// All is well
715//
716 Stat = buff;
717 return 0;
718}
719
720/******************************************************************************/
721/* C l o s e */
722/******************************************************************************/
723
724/*
725 Function: Close the directory associated with this object.
726
727 Input: None.
728
729 Output: Returns XrdOssOK upon success and (errno) upon failure.
730*/
731int XrdOssDir::Close(long long *retsz)
732{
733 int retc;
734
735// We do not support returing a size
736//
737 if (retsz) *retsz = 0;
738
739// Make sure this object is open
740//
741 if (!isopen) return -XRDOSS_E8002;
742
743// Close whichever handle is open
744//
745 if (lclfd)
746 {if (!(retc = closedir(lclfd)))
747 {lclfd = 0;
748 isopen = false;
749 }
750 } else {
751 if (mssfd) { if (!(retc = XrdOssSS->MSS_Closedir(mssfd))) mssfd = 0;}
752 else retc = 0;
753 }
754
755// Indicate whether or not we really closed this object
756//
757 return retc;
758}
759
760/******************************************************************************/
761/* F c t l */
762/******************************************************************************/
763/*
764 Function: Perform control operations on a file.
765
766 Input: cmd - The command.
767 alen - length of arguments.
768 args - Pointer to arguments.
769 resp - Pointer to where response should be placed.
770
771 Output: Returns XrdOssOK upon success and -errno upon failure.
772*/
773
774int XrdOssDir::Fctl(int cmd, int alen, const char *args, char **resp)
775{
776
777 switch(cmd)
778 {case XrdOssDF::Fctl_utimes: break; // Unsupported
780 if (dfType != DF_isDir) return -ENOTBLK;
781 if (lclfd) return -EALREADY;
782 if (alen != (int)sizeof(int)) return -EINVAL;
783 int retc, newFD;
784 memcpy(&newFD, args, sizeof(int));
785 struct stat buf;
786 do {retc = fstat(newFD, &buf);} while(retc && errno == EINTR);
787 if (retc) return -errno;
788 fd = newFD;
789 if (!(lclfd = fdopendir(newFD))) return -errno;
790 isopen = true;
791 return XrdOssOK;
792 break;
793 default: break;
794 }
795 return -ENOTSUP;
796}
797
798/******************************************************************************/
799/* o o s s _ F i l e M e t h o d s */
800/******************************************************************************/
801
802/******************************************************************************/
803/* o p e n */
804/******************************************************************************/
805
806/*
807 Function: Open the file `path' in the mode indicated by `Mode'.
808
809 Input: path - The fully qualified name of the file to open.
810 Oflag - Standard open flags.
811 Mode - Create mode (i.e., rwx).
812 env - Environmental information.
813
814 Output: XrdOssOK upon success; -errno otherwise.
815*/
816int XrdOssFile::Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &Env)
817{
818 unsigned long long popts;
819 int retc, mopts;
820 char actual_path[MAXPATHLEN+1], *local_path;
821 struct stat buf;
822
823// Return an error if this object is already open
824//
825 if (fd >= 0) return -XRDOSS_E8003;
826 else cxobj = 0;
827
828// Construct the processing options for this path.
829//
830 popts = XrdOssSS->PathOpts(path);
831 if (popts & XRDEXP_STAGE && Env.Get("oss.lcl")) popts &= ~XRDEXP_STAGE;
832
833// Generate local path
834//
835 if (XrdOssSS->lcl_N2N)
836 if ((retc = XrdOssSS->lcl_N2N->lfn2pfn(path, actual_path, sizeof(actual_path))))
837 return retc;
838 else local_path = actual_path;
839 else local_path = (char *)path;
840
841// Check if this is a read/only filesystem
842//
843 if (((Oflag & O_ACCMODE) != O_RDONLY) && (popts & XRDEXP_NOTRW))
844 {if (popts & XRDEXP_FORCERO) Oflag = O_RDONLY;
845 else return OssEroute.Emsg("Open",-XRDOSS_E8005,"open r/w",path);
846 }
847
848// If we can open the local copy. If not found, try to stage it in if possible.
849// Note that stage will regenerate the right local and remote paths.
850//
851 if ( (fd = (int)Open_ufs(local_path, Oflag, Mode, popts)) == -ENOENT
852 && (popts & XRDEXP_REMOTE))
853 {if (!(popts & XRDEXP_STAGE))
854 return OssEroute.Emsg("Open",-XRDOSS_E8006,"open",path);
855 if ((retc = XrdOssSS->Stage(tident, path, Env, Oflag, Mode, popts)))
856 return retc;
857 fd = (int)Open_ufs(local_path, Oflag, Mode, popts & ~XRDEXP_REMOTE);
858 }
859
860// This interface supports only regular files. Complain if this is not one.
861//
862 if (fd >= 0)
863 {do {retc = fstat(fd, &buf);} while(retc && errno == EINTR);
864 if (!retc && !(buf.st_mode & S_IFREG))
865 {close(fd); fd = (buf.st_mode & S_IFDIR ? -EISDIR : -ENOTBLK);}
866 if ((Oflag & O_ACCMODE) != O_RDONLY)
867 {FSize = buf.st_size; cacheP = XrdOssCache::Find(local_path);}
868 else {if (buf.st_mode & XRDSFS_POSCPEND && fd >= 0)
869 {close(fd); fd=-ETXTBSY;}
870 FSize = -1; cacheP = 0;
871 }
872 } else if (fd == -EEXIST)
873 {do {retc = stat(local_path,&buf);} while(retc && errno==EINTR);
874 if (!retc && (buf.st_mode & S_IFDIR)) fd = -EISDIR;
875 }
876
877// See if should memory map this file. For now, extended attributes are only
878// needed when memory mapping is enabled and can apply only to specific files.
879// So, we read them here should we need them.
880//
881 if (fd >= 0 && XrdOssSS->tryMmap)
883 mopts = 0;
884 if (!(popts & XRDEXP_NOXATTR) && XrdOssSS->chkMmap)
885 Info.Get(local_path, fd);
886 if (popts & XRDEXP_MKEEP || Info.Attr.Flags & XrdFrcXAttrMem::memKeep)
887 mopts |= OSSMIO_MPRM;
888 if (popts & XRDEXP_MLOK || Info.Attr.Flags & XrdFrcXAttrMem::memLock)
889 mopts |= OSSMIO_MLOK;
890 if (popts & XRDEXP_MMAP || Info.Attr.Flags & XrdFrcXAttrMem::memMap)
891 mopts |= OSSMIO_MMAP;
892 if (mopts) mmFile = XrdOssMio::Map(local_path, fd, mopts);
893 } else mmFile = 0;
894
895 canClone = !(popts & XRDEXP_NOFICL);
896// Return the result of this open
897//
898 return (fd < 0 ? fd : XrdOssOK);
899}
900
901/******************************************************************************/
902/* c l o s e */
903/******************************************************************************/
904
905/*
906 Function: Close the file associated with this object.
907
908 Input: None.
909
910 Output: Returns XrdOssOK upon success and -1 upon failure.
911*/
912int XrdOssFile::Close(long long *retsz)
913{
914 if (fd < 0) return -XRDOSS_E8004;
915 if (retsz || cacheP)
916 {struct stat buf;
917 int retc;
918 do {retc = fstat(fd, &buf);} while(retc && errno == EINTR);
919 if (cacheP && FSize != buf.st_size)
920 XrdOssCache::Adjust(cacheP, buf.st_size - FSize);
921 if (retsz) *retsz = buf.st_size;
922 }
923 if (close(fd)) return -errno;
924 if (mmFile) {XrdOssMio::Recycle(mmFile); mmFile = 0;}
925#ifdef XRDOSSCX
926 if (cxobj) {delete cxobj; cxobj = 0;}
927#endif
928 fd = -1; FSize = -1; cacheP = 0;
929 return XrdOssOK;
930}
931
932/******************************************************************************/
933/* r e a d */
934/******************************************************************************/
935
936/*
937 Function: Preread `blen' bytes from the associated file.
938
939 Input: offset - The absolute 64-bit byte offset at which to read.
940 blen - The size to preread.
941
942 Output: Returns zero read upon success and -errno upon failure.
943*/
944
945ssize_t XrdOssFile::Read(off_t offset, size_t blen)
946{
947
948 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
949
950#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
951 posix_fadvise(fd, offset, blen, POSIX_FADV_WILLNEED);
952#endif
953
954 return 0; // We haven't implemented this yet!
955}
956
957
958/******************************************************************************/
959/* r e a d */
960/******************************************************************************/
961
962/*
963 Function: Read `blen' bytes from the associated file, placing in 'buff'
964 the data and returning the actual number of bytes read.
965
966 Input: buff - Address of the buffer in which to place the data.
967 offset - The absolute 64-bit byte offset at which to read.
968 blen - The size of the buffer. This is the maximum number
969 of bytes that will be read.
970
971 Output: Returns the number bytes read upon success and -errno upon failure.
972*/
973
974ssize_t XrdOssFile::Read(void *buff, off_t offset, size_t blen)
975{
976 ssize_t retval;
977
978 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
979
980#ifdef XRDOSSCX
981 if (cxobj)
982 if (XrdOssSS->DirFlags & XrdOssNOSSDEC) return (ssize_t)-XRDOSS_E8021;
983 else retval = cxobj->Read((char *)buff, blen, offset);
984 else
985#endif
986 do { retval = pread(fd, buff, blen, offset); }
987 while(retval < 0 && errno == EINTR);
988
989 return (retval >= 0 ? retval : (ssize_t)-errno);
990}
991
992/******************************************************************************/
993/* r e a d v */
994/******************************************************************************/
995
996/*
997 Function: Perform all the reads specified in the readV vector.
998
999 Input: readV - A description of the reads to perform; includes the
1000 absolute offset, the size of the read, and the buffer
1001 to place the data into.
1002 readCount - The size of the readV vector.
1003
1004 Output: Returns the number of bytes read upon success and SFS_ERROR o/w.
1005 If the number of bytes read is less than requested, it is considered
1006 an error.
1007*/
1008
1009ssize_t XrdOssFile::ReadV(XrdOucIOVec *readV, int n)
1010{
1011 ssize_t rdsz, totBytes = 0;
1012 int i;
1013
1014// For platforms that support fadvise, pre-advise what we will be reading
1015//
1016#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
1017 EPNAME("ReadV");
1018 long long begOff, endOff, begLst = -1, endLst = -1;
1019 int nPR = n;
1020
1021// Indicate we are in preread state and see if we have exceeded the limit
1022//
1023 if (XrdOssSS->prDepth
1024 && AtomicInc((XrdOssSS->prActive)) < XrdOssSS->prQSize && n > 2)
1025 {int faBytes = 0;
1026 for (nPR=0;nPR < XrdOssSS->prDepth && faBytes < XrdOssSS->prBytes;nPR++)
1027 if (readV[nPR].size > 0)
1028 {begOff = XrdOssSS->prPMask & readV[nPR].offset;
1029 endOff = XrdOssSS->prPBits | (readV[nPR].offset+readV[nPR].size);
1030 rdsz = endOff - begOff + 1;
1031 if ((begOff > endLst || endOff < begLst)
1032 && rdsz < XrdOssSS->prBytes)
1033 {posix_fadvise(fd, begOff, rdsz, POSIX_FADV_WILLNEED);
1034 TRACE(Debug,"fadvise(" <<fd <<',' <<begOff <<',' <<rdsz <<')');
1035 faBytes += rdsz;
1036 }
1037 begLst = begOff; endLst = endOff;
1038 }
1039 }
1040#endif
1041
1042// Read in the vector and do a pre-advise if we support that
1043//
1044 for (i = 0; i < n; i++)
1045 {do {rdsz = pread(fd, readV[i].data, readV[i].size, readV[i].offset);}
1046 while(rdsz < 0 && errno == EINTR);
1047 if (rdsz < 0 || rdsz != readV[i].size)
1048 {totBytes = (rdsz < 0 ? -errno : -ESPIPE); break;}
1049 totBytes += rdsz;
1050#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
1051 if (nPR < n && readV[nPR].size > 0)
1052 {begOff = XrdOssSS->prPMask & readV[nPR].offset;
1053 endOff = XrdOssSS->prPBits | (readV[nPR].offset+readV[nPR].size);
1054 rdsz = endOff - begOff + 1;
1055 if ((begOff > endLst || endOff < begLst)
1056 && rdsz <= XrdOssSS->prBytes)
1057 {posix_fadvise(fd, begOff, rdsz, POSIX_FADV_WILLNEED);
1058 TRACE(Debug,"fadvise(" <<fd <<',' <<begOff <<',' <<rdsz <<')');
1059 }
1060 begLst = begOff; endLst = endOff;
1061 }
1062 nPR++;
1063#endif
1064 }
1065
1066// All done, return bytes read.
1067//
1068#if (defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))) && defined(HAVE_ATOMICS)
1069 if (XrdOssSS->prDepth) AtomicDec((XrdOssSS->prActive));
1070#endif
1071 return totBytes;
1072}
1073
1074/******************************************************************************/
1075/* R e a d R a w */
1076/******************************************************************************/
1077
1078/*
1079 Function: Read `blen' bytes from the associated file, placing in 'buff'
1080 the data and returning the actual number of bytes read.
1081
1082 Input: buff - Address of the buffer in which to place the data.
1083 offset - The absolute 64-bit byte offset at which to read.
1084 blen - The size of the buffer. This is the maximum number
1085 of bytes that will be read.
1086
1087 Output: Returns the number bytes read upon success and -errno upon failure.
1088*/
1089
1090ssize_t XrdOssFile::ReadRaw(void *buff, off_t offset, size_t blen)
1091{
1092 ssize_t retval;
1093
1094 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1095
1096#ifdef XRDOSSCX
1097 if (cxobj) retval = cxobj->ReadRaw((char *)buff, blen, offset);
1098 else
1099#endif
1100 do { retval = pread(fd, buff, blen, offset); }
1101 while(retval < 0 && errno == EINTR);
1102
1103 return (retval >= 0 ? retval : (ssize_t)-errno);
1104}
1105
1106/******************************************************************************/
1107/* w r i t e */
1108/******************************************************************************/
1109
1110/*
1111 Function: Write `blen' bytes to the associated file, from 'buff'
1112 and return the actual number of bytes written.
1113
1114 Input: buff - Address of the buffer from which to get the data.
1115 offset - The absolute 64-bit byte offset at which to write.
1116 blen - The number of bytes to write from the buffer.
1117
1118 Output: Returns the number of bytes written upon success and -errno o/w.
1119*/
1120
1121ssize_t XrdOssFile::Write(const void *buff, off_t offset, size_t blen)
1122{
1123 ssize_t retval;
1124
1125 if (fd < 0) return (ssize_t)-XRDOSS_E8004;
1126
1127 if (XrdOssSS->MaxSize && (long long)(offset+blen) > XrdOssSS->MaxSize)
1128 return (ssize_t)-XRDOSS_E8007;
1129
1130 do { retval = pwrite(fd, buff, blen, offset); }
1131 while(retval < 0 && errno == EINTR);
1132
1133 if (retval < 0) retval = (retval == EBADF && cxobj ? -XRDOSS_E8022 : -errno);
1134 return retval;
1135}
1136
1137/******************************************************************************/
1138/* F c h m o d */
1139/******************************************************************************/
1140
1141/*
1142 Function: Sets mode bits for an open file.
1143
1144 Input: Mode - The mode to set.
1145
1146 Output: Returns XrdOssOK upon success and -errno upon failure.
1147*/
1148
1150{
1151 return (fchmod(fd, Mode) ? -errno : XrdOssOK);
1152}
1153
1154/******************************************************************************/
1155/* F c t l */
1156/******************************************************************************/
1157/*
1158 Function: Perform control operations on a file.
1159
1160 Input: cmd - The command.
1161 alen - length of arguments.
1162 args - Pointer to arguments.
1163 resp - Pointer to where response should be placed.
1164
1165 Output: Returns XrdOssOK upon success and -errno upon failure.
1166*/
1167
1168int XrdOssFile::Fctl(int cmd, int alen, const char *args, char **resp)
1169{
1170 const struct timeval *utArgs;
1171
1172 switch(cmd)
1174 if (alen != sizeof(struct timeval)*2 || !args) return -EINVAL;
1175 utArgs = (const struct timeval *)args;
1176 if (futimes(fd, utArgs)) return -errno;
1177 return XrdOssOK;
1178 break;
1180 if (dfType != DF_isFile) return -ENOTBLK;
1181 if (fd >= 0) return -EALREADY;
1182 if (alen != (int)sizeof(int)) return -EINVAL;
1183 int retc, newFD;
1184 memcpy(&newFD, args, sizeof(int));
1185 struct stat buf;
1186 do {retc = fstat(newFD, &buf);} while(retc && errno == EINTR);
1187 if (retc) return -errno;
1188 fd = newFD;
1189 FSize = buf.st_size;
1190 return XrdOssOK;
1191 break;
1192 default: break;
1193 }
1194 return -ENOTSUP;
1195}
1196
1197/******************************************************************************/
1198/* F l u s h */
1199/******************************************************************************/
1200
1201/*
1202 Function: Flush file pages from the filesyste cache.
1203
1204 Output: Returns XrdOssOK upon success and -errno upon failure.
1205*/
1206
1208{
1209// This actually only works in Linux so we punt otherwise
1210//
1211#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
1212 if (fd>= 0)
1213 {fdatasync(fd);
1214 posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
1215 }
1216#endif
1217}
1218
1219/******************************************************************************/
1220/* F s t a t */
1221/******************************************************************************/
1222
1223/*
1224 Function: Return file status for the associated file.
1225
1226 Input: buff - Pointer to buffer to hold file status.
1227
1228 Output: Returns XrdOssOK upon success and -errno upon failure.
1229*/
1230
1231int XrdOssFile::Fstat(struct stat *buff)
1232{
1233 return (fstat(fd, buff) ? -errno : XrdOssOK);
1234}
1235
1236/******************************************************************************/
1237/* F s y n c */
1238/******************************************************************************/
1239
1240/*
1241 Function: Synchronize associated file.
1242
1243 Input: None.
1244
1245 Output: Returns XrdOssOK upon success and -errno upon failure.
1246*/
1248{
1249 return (fsync(fd) ? -errno : XrdOssOK);
1250}
1251
1252/******************************************************************************/
1253/* g e t M m a p */
1254/******************************************************************************/
1255
1256/*
1257 Function: Indicate whether or not file is memory mapped.
1258
1259 Input: addr - Points to an address which will receive the location
1260 memory where the file is mapped. If the address is
1261 null, true is returned if a mapping exist.
1262
1263 Output: Returns the size of the file if it is memory mapped (see above).
1264 Otherwise, zero is returned and addr is set to zero.
1265*/
1266off_t XrdOssFile::getMmap(void **addr)
1267{
1268 if (mmFile) return (addr ? mmFile->Export(addr) : 1);
1269 if (addr) *addr = 0;
1270 return 0;
1271}
1272
1273/******************************************************************************/
1274/* i s C o m p r e s s e d */
1275/******************************************************************************/
1276
1277/*
1278 Function: Indicate whether or not file is compressed.
1279
1280 Input: cxidp - Points to a four byte buffer to hold the compression
1281 algorithm used if the file is compressed or null.
1282
1283 Output: Returns the regios size which is 0 if the file is not compressed.
1284 If cxidp is not null, the algorithm is returned only if the file
1285 is compressed.
1286*/
1288{
1289 if (cxpgsz)
1290 {cxidp[0] = cxid[0]; cxidp[1] = cxid[1];
1291 cxidp[2] = cxid[2]; cxidp[3] = cxid[3];
1292 }
1293 return cxpgsz;
1294}
1295
1296/******************************************************************************/
1297/* t r u n c a t e */
1298/******************************************************************************/
1299
1300/*
1301 Function: Set the length of associated file to 'flen'.
1302
1303 Input: flen - The new size of the file. Only 32-bit lengths
1304 are supported.
1305
1306 Output: Returns XrdOssOK upon success and -1 upon failure.
1307
1308 Notes: If 'flen' is smaller than the current size of the file, the file
1309 is made smaller and the data past 'flen' is discarded. If 'flen'
1310 is larger than the current size of the file, a hole is created
1311 (i.e., the file is logically extended by filling the extra bytes
1312 with zeroes).
1313
1314 If compiled w/o large file support, only lower 32 bits are used.
1315 used.
1316 in supporting it for any other system.
1317*/
1318int XrdOssFile::Ftruncate(unsigned long long flen) {
1319 off_t newlen = flen;
1320
1321 if (sizeof(newlen) < sizeof(flen) && (flen>>31)) return -XRDOSS_E8008;
1322
1323// Note that space adjustment will occur when the file is closed, not here
1324//
1325 return (ftruncate(fd, newlen) ? -errno : XrdOssOK);
1326 }
1327
1328/******************************************************************************/
1329/* P R I V A T E S E C T I O N */
1330/******************************************************************************/
1331/******************************************************************************/
1332/* o o s s _ O p e n _ u f s */
1333/******************************************************************************/
1334
1335int XrdOssFile::Open_ufs(const char *path, int Oflag, int Mode,
1336 unsigned long long popts)
1337{
1338 EPNAME("Open_ufs")
1339 int myfd, newfd;
1340#ifndef NODEBUG
1341 char *ftype = (char *)" path=";
1342#endif
1343#ifdef XRDOSSCX
1344 int attcx = 0;
1345#endif
1346
1347// If we need to do a stat() prior to the open, do so now
1348//
1349 if (XrdOssSS->STT_PreOp)
1350 {struct stat Stat;
1351 if ((*(XrdOssSS->STT_Func))(path, &Stat, XRDOSS_preop, 0)) return -errno;
1352 }
1353
1354// Now open the actual data file in the appropriate mode.
1355//
1356 do { myfd = XrdSysFD_Open(path, Oflag|O_LARGEFILE, Mode);}
1357 while( myfd < 0 && errno == EINTR);
1358
1359// If the file is marked purgeable or migratable and we may modify this file,
1360// then get a shared lock on the file to keep it from being migrated or purged
1361// while it is open. This is advisory so we can ignore any errors.
1362//
1363 if (myfd >= 0
1364 && (popts & XRDEXP_PURGE || (popts & XRDEXP_MIG && ((Oflag & O_ACCMODE) != O_RDONLY))))
1365 {FLOCK_t lock_args;
1366 bzero(&lock_args, sizeof(lock_args));
1367 lock_args.l_type = F_RDLCK;
1368 fcntl(myfd, F_SETLKW, &lock_args);
1369 }
1370
1371// Chck if file is compressed
1372//
1373 if (myfd < 0) myfd = -errno;
1374#ifdef XRDOSSCX
1375 else if ((popts & XRDEXP_COMPCHK)
1376 && oocx_CXFile::isCompressed(myfd, cxid, &cxpgsz))
1377 if (Oflag != O_RDONLY) {close(myfd); return -XRDOSS_E8022;}
1378 else attcx = 1;
1379#endif
1380
1381// Relocate the file descriptor if need be and make sure file is closed on exec
1382//
1383 if (myfd >= 0)
1384 {if (myfd < XrdOssSS->FDFence)
1385 {if ((newfd = XrdSysFD_Dup1(myfd, XrdOssSS->FDFence)) < 0)
1386 OssEroute.Emsg("Open_ufs",errno,"reloc FD",path);
1387 else {close(myfd); myfd = newfd;}
1388 }
1389#ifdef XRDOSSCX
1390 // If the file is compressed get a CXFile object and attach the FD to it
1391 //
1392 if (attcx) {cxobj = new oocx_CXFile;
1393 ftype = (char *)" CXpath=";
1394 if ((retc = cxobj->Attach(myfd, path)) < 0)
1395 {close(myfd); myfd = retc; delete cxobj; cxobj = 0;}
1396 }
1397#endif
1398 }
1399
1400// Trace the action.
1401//
1402 TRACE(Open, "fd=" <<myfd <<" flags=" <<Xrd::hex1 <<Oflag <<" mode="
1403 <<Xrd::oct1 <<Mode <<ftype <<path);
1404
1405// All done
1406//
1407 return myfd;
1408}
#define EPNAME(x)
struct stat Stat
Definition XrdCks.cc:49
static XrdSysLogger Logger
XrdSysTrace OssTrace
XrdSysError OssEroute
XrdSysError OssEroute(0, "oss_")
XrdSysTrace OssTrace("oss")
XrdOss * XrdOssGetSS(XrdSysLogger *Logger, const char *config_fn, const char *OssLib, const char *OssParms, XrdOucEnv *envP, XrdVersionInfo &urVer)
Definition XrdOssApi.cc:103
XrdOss * XrdOssDefaultSS(XrdSysLogger *logger, const char *cfg_fn, XrdVersionInfo &urVer)
Definition XrdOssApi.cc:170
XrdOssSys * XrdOssSS
Definition XrdOssApi.cc:82
#define Check_RW(act, path, opname)
Definition XrdOssApi.hh:399
#define XRDOSS_E8002
#define XRDOSS_E8006
#define XRDOSS_E8007
#define XRDOSS_E8003
#define XRDOSS_E8004
#define XRDOSS_E8022
#define XRDOSS_E8008
#define XRDOSS_E8021
#define XRDOSS_E8001
#define XRDOSS_E8005
#define OSSMIO_MMAP
Definition XrdOssMio.hh:41
#define OSSMIO_MLOK
Definition XrdOssMio.hh:40
#define OSSMIO_MPRM
Definition XrdOssMio.hh:42
XrdOss *(* XrdOssGetStorageSystem2_t)(XrdOss *native_oss, XrdSysLogger *Logger, const char *config_fn, const char *parms, XrdOucEnv *envP)
Definition XrdOss.hh:1020
#define XrdOssOK
Definition XrdOss.hh:54
XrdOss *(* XrdOssGetStorageSystem_t)(XrdOss *native_oss, XrdSysLogger *Logger, const char *config_fn, const char *parms)
The typedef that describes the XRdOssStatInfoInit external.
Definition XrdOss.hh:1015
#define XRDOSS_preop
Definition XrdOss.hh:550
#define XRDEXP_NOTRW
#define XRDEXP_NODREAD
#define XRDEXP_PURGE
#define XRDEXP_MMAP
#define XRDEXP_MKEEP
#define XRDEXP_FORCERO
#define XRDEXP_REMOTE
#define XRDEXP_MLOK
#define XRDEXP_NOFICL
#define XRDEXP_NOCHECK
#define XRDEXP_NOXATTR
#define XRDEXP_STAGE
#define XRDEXP_MIG
int fdatasync(int fildes)
#define close(a)
Definition XrdPosix.hh:48
#define fsync(a)
Definition XrdPosix.hh:64
#define fstat(a, b)
Definition XrdPosix.hh:62
#define mkdir(a, b)
Definition XrdPosix.hh:74
#define closedir(a)
Definition XrdPosix.hh:50
#define stat(a, b)
Definition XrdPosix.hh:101
#define readdir(a)
Definition XrdPosix.hh:86
#define ftruncate(a, b)
Definition XrdPosix.hh:70
#define truncate(a, b)
Definition XrdPosix.hh:111
#define pwrite(a, b, c, d)
Definition XrdPosix.hh:107
#define pread(a, b, c, d)
Definition XrdPosix.hh:80
int Mode
bool Debug
#define XRDSFS_POSCPEND
#define AtomicInc(x)
#define AtomicDec(x)
#define dirfd(x)
size_t strlcpy(char *dst, const char *src, size_t sz)
#define FLOCK_t
#define TRACE(act, x)
Definition XrdTrace.hh:63
static const char memKeep
static const char memLock
static const char memMap
static XrdOssCache_FS * Find(const char *Path, int lklen=0)
static void Adjust(dev_t devid, off_t size)
uint16_t dfType
Definition XrdOss.hh:516
static const uint16_t DF_isFile
Object is for a file.
Definition XrdOss.hh:433
const char * tident
Definition XrdOss.hh:513
XrdOssDF(const char *tid="", uint16_t dftype=0, int fdnum=-1)
Definition XrdOss.hh:504
int fd
Definition XrdOss.hh:515
static const int Fctl_utimes
Definition XrdOss.hh:459
virtual int getFD()
Definition XrdOss.hh:486
static const uint16_t DF_isDir
Object is for a directory.
Definition XrdOss.hh:432
static const int Fctl_setFD
Definition XrdOss.hh:460
int StatRet(struct stat *buff)
Definition XrdOssApi.cc:697
int Opendir(const char *, XrdOucEnv &)
Definition XrdOssApi.cc:557
int Readdir(char *buff, int blen)
Definition XrdOssApi.cc:643
int Close(long long *retsz=0)
Definition XrdOssApi.cc:731
int Fctl(int cmd, int alen, const char *args, char **resp=0)
Definition XrdOssApi.cc:774
virtual int Close(long long *retsz=0)
Definition XrdOssApi.cc:912
int Clone(XrdOssDF &srcFile)
Definition XrdOssApi.cc:273
int Fchmod(mode_t mode)
int isCompressed(char *cxidp=0)
ssize_t Read(off_t, size_t)
Definition XrdOssApi.cc:945
int Fctl(int cmd, int alen, const char *args, char **resp=0)
virtual int Open(const char *, int, mode_t, XrdOucEnv &)
Definition XrdOssApi.cc:816
off_t getMmap(void **addr)
int Fstat(struct stat *)
void Flush()
Flush filesystem cached pages for this file (used for checksums).
ssize_t ReadV(XrdOucIOVec *readV, int)
int Ftruncate(unsigned long long)
ssize_t Write(const void *, off_t, size_t)
ssize_t ReadRaw(void *, off_t, size_t)
static XrdOssMioFile * Map(char *path, int fd, int opts)
Definition XrdOssMio.cc:94
static void Recycle(XrdOssMioFile *mp)
Definition XrdOssMio.cc:294
int GenRemotePath(const char *, char *)
Definition XrdOssApi.cc:254
int Configure(const char *, XrdSysError &, XrdOucEnv *envP)
int Init(XrdSysLogger *, const char *, XrdOucEnv *envP)
Definition XrdOssApi.cc:191
int getStats(char *buff, int blen)
int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0)
Definition XrdOssApi.cc:366
static char chkMmap
Definition XrdOssApi.hh:211
int Mkpath(const char *, mode_t mode)
Definition XrdOssApi.cc:413
int GenLocalPath(const char *, char *)
Definition XrdOssApi.cc:237
XrdOucName2Name * lcl_N2N
Definition XrdOssApi.hh:261
static char tryMmap
Definition XrdOssApi.hh:210
int Lfn2Pfn(const char *Path, char *buff, int blen)
Definition XrdOssApi.cc:213
XrdVersionInfo * myVersion
Definition XrdOssApi.hh:289
int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *Env=0)
Definition XrdOssStat.cc:70
int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0)
Definition XrdOssApi.cc:332
int Stats(char *bp, int bl)
Definition XrdOssApi.cc:456
int Truncate(const char *, unsigned long long Size, XrdOucEnv *eP=0)
Definition XrdOssApi.cc:502
XrdOucName2Name * rmt_N2N
Definition XrdOssApi.hh:262
virtual void EnvInfo(XrdOucEnv *envP)
Definition XrdOss.cc:54
char * Get(const char *varname)
Definition XrdOucEnv.hh:69
void Put(const char *varname, const char *value)
Definition XrdOucEnv.hh:85
void * Resolve(const char *symbl, int mcnt=1)
const char * Path()
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
static bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false)
long long offset