xrootd
Loading...
Searching...
No Matches
XrdOss.hh
Go to the documentation of this file.
1#ifndef _XRDOSS_H
2#define _XRDOSS_H
3/******************************************************************************/
4/* */
5/* X r d O s s . h h */
6/* */
7/* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* All Rights Reserved */
9/* Produced by Andrew Hanushevsky for Stanford University under contract */
10/* DE-AC02-76-SFO0515 with the Department of Energy */
11/* */
12/* This file is part of the XRootD software suite. */
13/* */
14/* XRootD is free software: you can redistribute it and/or modify it under */
15/* the terms of the GNU Lesser General Public License as published by the */
16/* Free Software Foundation, either version 3 of the License, or (at your */
17/* option) any later version. */
18/* */
19/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22/* License for more details. */
23/* */
24/* You should have received a copy of the GNU Lesser General Public License */
25/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27/* */
28/* The copyright holder's institutional names and contributor's names may not */
29/* be used to endorse or promote products derived from this software without */
30/* specific prior written permission of the institution or contributor. */
31/******************************************************************************/
32
33#include <dirent.h>
34#include <cerrno>
35#include <cstdint>
36#include <strings.h>
37#include <sys/stat.h>
38#include <sys/time.h>
39#include <sys/types.h>
40#include <cstring>
41
42#include "XrdOss/XrdOssVS.hh"
43#include "XrdOuc/XrdOucIOVec.hh"
44
45class XrdOucEnv;
46class XrdSysLogger;
47class XrdSfsAio;
48
49#ifndef XrdOssOK
50#define XrdOssOK 0
51#endif
52
53/******************************************************************************/
54/* C l a s s X r d O s s D F */
55/******************************************************************************/
56
61
63{
64public:
65
66/******************************************************************************/
67/* D i r e c t o r y O r i e n t e d M e t h o d s */
68/******************************************************************************/
69
70//-----------------------------------------------------------------------------
77//-----------------------------------------------------------------------------
78
79virtual int Opendir(const char *path, XrdOucEnv &env) {return -ENOTDIR;}
80
81//-----------------------------------------------------------------------------
90//-----------------------------------------------------------------------------
91
92virtual int Readdir(char *buff, int blen) {return -ENOTDIR;}
93
94//-----------------------------------------------------------------------------
105//-----------------------------------------------------------------------------
106
107virtual int StatRet(struct stat *buff) {return -ENOTSUP;}
108
109/******************************************************************************/
110/* F i l e O r i e n t e d M e t h o d s */
111/******************************************************************************/
112//-----------------------------------------------------------------------------
118//-----------------------------------------------------------------------------
119
120virtual int Fchmod(mode_t mode) {return -EISDIR;}
121
122//-----------------------------------------------------------------------------
124//-----------------------------------------------------------------------------
125
126virtual void Flush() {}
127
128//-----------------------------------------------------------------------------
134//-----------------------------------------------------------------------------
135
136virtual int Fstat(struct stat *buf) {return -EISDIR;}
137
138//-----------------------------------------------------------------------------
142//-----------------------------------------------------------------------------
143
144virtual int Fsync() {return -EISDIR;}
145
146//-----------------------------------------------------------------------------
152//-----------------------------------------------------------------------------
153
154virtual int Fsync(XrdSfsAio *aiop) {return -EISDIR;}
155
156//-----------------------------------------------------------------------------
162//-----------------------------------------------------------------------------
163
164virtual int Ftruncate(unsigned long long flen) {return -EISDIR;}
165
166//-----------------------------------------------------------------------------
174//-----------------------------------------------------------------------------
175
176virtual off_t getMmap(void **addr) {*addr = 0; return 0;}
177
178//-----------------------------------------------------------------------------
185//-----------------------------------------------------------------------------
186
187virtual int isCompressed(char *cxidp=0) {(void)cxidp; return 0;}
188
189//-----------------------------------------------------------------------------
198//-----------------------------------------------------------------------------
199
200virtual int Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &env)
201 {return -EISDIR;}
202
203//-----------------------------------------------------------------------------
218//-----------------------------------------------------------------------------
219
220// pgRead and pgWrite options as noted.
221//
222static const uint64_t
223Verify = 0x8000000000000000ULL;
224static const uint64_t
225doCalc = 0x4000000000000000ULL;
226
227virtual ssize_t pgRead (void* buffer, off_t offset, size_t rdlen,
228 uint32_t* csvec, uint64_t opts);
229
230//-----------------------------------------------------------------------------
238//-----------------------------------------------------------------------------
239
240virtual int pgRead (XrdSfsAio* aioparm, uint64_t opts);
241
242//-----------------------------------------------------------------------------
255//-----------------------------------------------------------------------------
256
257virtual ssize_t pgWrite(void* buffer, off_t offset, size_t wrlen,
258 uint32_t* csvec, uint64_t opts);
259
260//-----------------------------------------------------------------------------
268//-----------------------------------------------------------------------------
269
270virtual int pgWrite(XrdSfsAio* aioparm, uint64_t opts);
271
272//-----------------------------------------------------------------------------
279//-----------------------------------------------------------------------------
280
281virtual ssize_t Read(off_t offset, size_t size) {return (ssize_t)-EISDIR;}
282
283//-----------------------------------------------------------------------------
292//-----------------------------------------------------------------------------
293
294virtual ssize_t Read(void *buffer, off_t offset, size_t size)
295 {return (ssize_t)-EISDIR;}
296
297//-----------------------------------------------------------------------------
304//-----------------------------------------------------------------------------
305
306virtual int Read(XrdSfsAio *aiop) {(void)aiop; return (ssize_t)-EISDIR;}
307
308//-----------------------------------------------------------------------------
317//-----------------------------------------------------------------------------
318
319virtual ssize_t ReadRaw(void *buffer, off_t offset, size_t size)
320 {return (ssize_t)-EISDIR;}
321
322//-----------------------------------------------------------------------------
330//-----------------------------------------------------------------------------
331
332virtual ssize_t ReadV(XrdOucIOVec *readV, int rdvcnt);
333
334//-----------------------------------------------------------------------------
343//-----------------------------------------------------------------------------
344
345virtual ssize_t Write(const void *buffer, off_t offset, size_t size)
346 {return (ssize_t)-EISDIR;}
347
348//-----------------------------------------------------------------------------
355//-----------------------------------------------------------------------------
356
357virtual int Write(XrdSfsAio *aiop) {(void)aiop; return (ssize_t)-EISDIR;}
358
359//-----------------------------------------------------------------------------
367//-----------------------------------------------------------------------------
368
369virtual ssize_t WriteV(XrdOucIOVec *writeV, int wrvcnt);
370
371/******************************************************************************/
372/* C o m m o n D i r e c t o r y a n d F i l e M e t h o d s */
373/******************************************************************************/
374//-----------------------------------------------------------------------------
380//-----------------------------------------------------------------------------
381
382virtual int Close(long long *retsz=0)=0;
383
384//-----------------------------------------------------------------------------
388//-----------------------------------------------------------------------------
389
390// Returned value will have one or more bits set as below.
391//
392static const uint16_t DF_isDir = 0x0001;
393static const uint16_t DF_isFile = 0x0002;
394static const uint16_t DF_isProxy = 0x0010;
395
396uint16_t DFType() {return dfType;}
397
398//-----------------------------------------------------------------------------
413//-----------------------------------------------------------------------------
414
415static const int Fctl_ckpObj = 0;
416static const int Fctl_utimes = 1;
417
418virtual int Fctl(int cmd, int alen, const char *args, char **resp=0);
419
420//-----------------------------------------------------------------------------
424//-----------------------------------------------------------------------------
425
426virtual int getFD() {return -1;} // Must override to support sendfile()
427
428//-----------------------------------------------------------------------------
432//-----------------------------------------------------------------------------
433virtual
434const char *getTID() {return tident;}
435
436//-----------------------------------------------------------------------------
442//-----------------------------------------------------------------------------
443
444 XrdOssDF(const char *tid="", uint16_t dftype=0, int fdnum=-1)
445 : tident(tid), pgwEOF(0), fd(fdnum), dfType(dftype),
446 rsvd(0) {}
447
448virtual ~XrdOssDF() {}
449
450
451protected:
452
453const char *tident; // Trace identifier
454off_t pgwEOF; // Highest short offset on pgWrite (0 means none yet)
455int fd; // The associated file descriptor.
456uint16_t dfType; // Type of this object
457short rsvd; // Reserved
458};
459
460/******************************************************************************/
461/* X r d O s s O p t i o n s */
462/******************************************************************************/
463
464// Options that can be passed to Create()
465//
466#define XRDOSS_mkpath 0x01
467#define XRDOSS_new 0x02
468#define XRDOSS_Online 0x04
469#define XRDOSS_isPFN 0x10
470#define XRDOSS_isMIG 0x20
471#define XRDOSS_setnoxa 0x40
472
473// Values returned by Features()
474//
475#define XRDOSS_HASPGRW 0x0000000000000001ULL
476#define XRDOSS_HASFSCS 0x0000000000000002ULL
477#define XRDOSS_HASPRXY 0x0000000000000004ULL
478#define XRDOSS_HASNOSF 0x0000000000000008ULL
479#define XRDOSS_HASCACH 0x0000000000000010ULL
480#define XRDOSS_HASNAIO 0x0000000000000020ULL
481#define XRDOSS_HASRPXY 0x0000000000000040ULL
482
483// Options that can be passed to Stat()
484//
485#define XRDOSS_resonly 0x0001
486#define XRDOSS_updtatm 0x0002
487#define XRDOSS_preop 0x0004
488
489// Commands that can be passed to FSctl
490//
491#define XRDOSS_FSCTLFA 0x0001
492
493/******************************************************************************/
494/* C l a s s X r d O s s */
495/******************************************************************************/
496
498{
499public:
500
501//-----------------------------------------------------------------------------
508//-----------------------------------------------------------------------------
509
510virtual XrdOssDF *newDir(const char *tident)=0;
511
512//-----------------------------------------------------------------------------
519//-----------------------------------------------------------------------------
520
521virtual XrdOssDF *newFile(const char *tident)=0;
522
523//-----------------------------------------------------------------------------
531//-----------------------------------------------------------------------------
532
533virtual int Chmod(const char * path, mode_t mode, XrdOucEnv *envP=0)=0;
534
535//-----------------------------------------------------------------------------
539//-----------------------------------------------------------------------------
540
541virtual void Connect(XrdOucEnv &env);
542
543//-----------------------------------------------------------------------------
556//-----------------------------------------------------------------------------
557
558virtual int Create(const char *tid, const char *path,
559 mode_t mode, XrdOucEnv &env,
560 int opts=0)=0;
561
562//-----------------------------------------------------------------------------
566//-----------------------------------------------------------------------------
567
568virtual void Disc(XrdOucEnv &env);
569
570//-----------------------------------------------------------------------------
574//-----------------------------------------------------------------------------
575
576virtual void EnvInfo(XrdOucEnv *envP);
577
578//-----------------------------------------------------------------------------
582//-----------------------------------------------------------------------------
583
584virtual uint64_t Features();
585
586//-----------------------------------------------------------------------------
596//-----------------------------------------------------------------------------
597
598virtual int FSctl(int cmd, int alen, const char *args, char **resp=0);
599
600//-----------------------------------------------------------------------------
607//-----------------------------------------------------------------------------
608
609virtual int Init(XrdSysLogger *lp, const char *cfn)=0;
610
611//-----------------------------------------------------------------------------
619//-----------------------------------------------------------------------------
620
621virtual int Init(XrdSysLogger *lp, const char *cfn, XrdOucEnv *envP)
622 {return Init(lp, cfn);}
623
624//-----------------------------------------------------------------------------
633//-----------------------------------------------------------------------------
634
635virtual int Mkdir(const char *path, mode_t mode, int mkpath=0,
636 XrdOucEnv *envP=0)=0;
637
638//-----------------------------------------------------------------------------
647//-----------------------------------------------------------------------------
648
649virtual int Reloc(const char *tident, const char *path,
650 const char *cgName, const char *anchor=0);
651
652//-----------------------------------------------------------------------------
662//-----------------------------------------------------------------------------
663
664virtual int Remdir(const char *path, int Opts=0, XrdOucEnv *envP=0)=0;
665
666//-----------------------------------------------------------------------------
675//-----------------------------------------------------------------------------
676
677virtual int Rename(const char *oPath, const char *nPath,
678 XrdOucEnv *oEnvP=0, XrdOucEnv *nEnvP=0)=0;
679
680//-----------------------------------------------------------------------------
692//-----------------------------------------------------------------------------
693
694virtual int Stat(const char *path, struct stat *buff,
695 int opts=0, XrdOucEnv *envP=0)=0;
696
697//-----------------------------------------------------------------------------
704//-----------------------------------------------------------------------------
705
706virtual int Stats(char *buff, int blen) {(void)buff; (void)blen; return 0;}
707
708//-----------------------------------------------------------------------------
723//-----------------------------------------------------------------------------
724
725virtual int StatFS(const char *path, char *buff, int &blen,
726 XrdOucEnv *envP=0);
727
728//-----------------------------------------------------------------------------
744//-----------------------------------------------------------------------------
745
746virtual int StatLS(XrdOucEnv &env, const char *path,
747 char *buff, int &blen);
748
749//-----------------------------------------------------------------------------
767//-----------------------------------------------------------------------------
768
769static const int PF_dInfo = 0x00000001;
770static const int PF_dNums = 0x00000002;
771static const int PF_isLFN = 0x00000004;
772static const int PF_dStat = 0x00000008;
773
774// Bits returned in st_rdev when PF_dStat specified in opts. Absence of either
775// PF_csVer and PF_csVun flags means that the file has no checksums present.
776//
777static const int PF_csVer = 0x00000001;
778static const int PF_csVun = 0x00000002;
779
780virtual int StatPF(const char *path, struct stat *buff, int opts);
781
782virtual int StatPF(const char *path, struct stat *buff)
783 {return StatPF(path, buff, 0);} // Backward compat
784
785//-----------------------------------------------------------------------------
797//-----------------------------------------------------------------------------
798
799virtual int StatVS(XrdOssVSInfo *vsP, const char *sname=0, int updt=0);
800
801//-----------------------------------------------------------------------------
814//-----------------------------------------------------------------------------
815
816virtual int StatXA(const char *path, char *buff, int &blen,
817 XrdOucEnv *envP=0);
818
819//-----------------------------------------------------------------------------
827//-----------------------------------------------------------------------------
828
829virtual int StatXP(const char *path, unsigned long long &attr,
830 XrdOucEnv *envP=0);
831
832//-----------------------------------------------------------------------------
840//-----------------------------------------------------------------------------
841
842virtual int Truncate(const char *path, unsigned long long fsize,
843 XrdOucEnv *envP=0)=0;
844
845//-----------------------------------------------------------------------------
856//-----------------------------------------------------------------------------
857
858virtual int Unlink(const char *path, int Opts=0, XrdOucEnv *envP=0)=0;
859
860 // Default Name-to-Name Methods
861
862//-----------------------------------------------------------------------------
870//-----------------------------------------------------------------------------
871
872virtual int Lfn2Pfn(const char *Path, char *buff, int blen)
873 {if ((int)strlen(Path) >= blen) return -ENAMETOOLONG;
874 strcpy(buff, Path); return 0;
875 }
876
877//-----------------------------------------------------------------------------
887//-----------------------------------------------------------------------------
888virtual
889const char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
890 { (void)buff; (void)blen; rc = 0; return Path;}
891
892//-----------------------------------------------------------------------------
894//-----------------------------------------------------------------------------
895
897virtual ~XrdOss() {}
898};
899
900/******************************************************************************/
901/* 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 */
902/******************************************************************************/
903
904//------------------------------------------------------------------------------
927//------------------------------------------------------------------------------
928
929//------------------------------------------------------------------------------
931//------------------------------------------------------------------------------
932
933typedef XrdOss *(*XrdOssGetStorageSystem_t) (XrdOss *native_oss,
934 XrdSysLogger *Logger,
935 const char *config_fn,
936 const char *parms);
937
938typedef XrdOss *(*XrdOssGetStorageSystem2_t)(XrdOss *native_oss,
939 XrdSysLogger *Logger,
940 const char *config_fn,
941 const char *parms,
942 XrdOucEnv *envP);
943
945
977//------------------------------------------------------------------------------
983//------------------------------------------------------------------------------
984
990#endif
XrdOssGetStorageSystem2_t XrdOssAddStorageSystem2_t
Definition XrdOss.hh:944
XrdOss *(* XrdOssGetStorageSystem2_t)(XrdOss *native_oss, XrdSysLogger *Logger, const char *config_fn, const char *parms, XrdOucEnv *envP)
Definition XrdOss.hh:938
#define stat(a, b)
Definition XrdPosix.hh:96
Definition XrdOss.hh:63
virtual int Read(XrdSfsAio *aiop)
Definition XrdOss.hh:306
uint16_t dfType
Definition XrdOss.hh:456
virtual int Fsync()
Definition XrdOss.hh:144
static const uint16_t DF_isFile
Object is for a file.
Definition XrdOss.hh:393
static const uint64_t doCalc
pgw: Calculate checksums
Definition XrdOss.hh:225
const char * tident
Definition XrdOss.hh:453
virtual int StatRet(struct stat *buff)
Definition XrdOss.hh:107
virtual int isCompressed(char *cxidp=0)
Definition XrdOss.hh:187
virtual int Opendir(const char *path, XrdOucEnv &env)
Definition XrdOss.hh:79
virtual const char * getTID()
Definition XrdOss.hh:434
virtual int pgWrite(XrdSfsAio *aioparm, uint64_t opts)
virtual int Write(XrdSfsAio *aiop)
Definition XrdOss.hh:357
virtual int Ftruncate(unsigned long long flen)
Definition XrdOss.hh:164
XrdOssDF(const char *tid="", uint16_t dftype=0, int fdnum=-1)
Definition XrdOss.hh:444
int fd
Definition XrdOss.hh:455
static const int Fctl_utimes
Definition XrdOss.hh:416
virtual int Readdir(char *buff, int blen)
Definition XrdOss.hh:92
virtual int Fstat(struct stat *buf)
Definition XrdOss.hh:136
off_t pgwEOF
Definition XrdOss.hh:454
virtual ssize_t ReadV(XrdOucIOVec *readV, int rdvcnt)
static const uint64_t Verify
all: Verify checksums
Definition XrdOss.hh:223
virtual ssize_t ReadRaw(void *buffer, off_t offset, size_t size)
Definition XrdOss.hh:319
virtual ssize_t WriteV(XrdOucIOVec *writeV, int wrvcnt)
virtual int Close(long long *retsz=0)=0
virtual int getFD()
Definition XrdOss.hh:426
static const uint16_t DF_isDir
Object is for a directory.
Definition XrdOss.hh:392
virtual int Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &env)
Definition XrdOss.hh:200
virtual ~XrdOssDF()
Definition XrdOss.hh:448
virtual ssize_t Read(off_t offset, size_t size)
Definition XrdOss.hh:281
virtual ssize_t pgWrite(void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
virtual ssize_t Read(void *buffer, off_t offset, size_t size)
Definition XrdOss.hh:294
short rsvd
Definition XrdOss.hh:457
virtual int Fchmod(mode_t mode)
Definition XrdOss.hh:120
virtual int Fsync(XrdSfsAio *aiop)
Definition XrdOss.hh:154
static const int Fctl_ckpObj
Definition XrdOss.hh:415
virtual int Fctl(int cmd, int alen, const char *args, char **resp=0)
virtual ssize_t pgRead(void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
virtual int pgRead(XrdSfsAio *aioparm, uint64_t opts)
static const uint16_t DF_isProxy
Object is a proxy object.
Definition XrdOss.hh:394
virtual void Flush()
Flush filesystem cached pages for this file (used for checksums).
Definition XrdOss.hh:126
virtual off_t getMmap(void **addr)
Definition XrdOss.hh:176
uint16_t DFType()
Definition XrdOss.hh:396
virtual ssize_t Write(const void *buffer, off_t offset, size_t size)
Definition XrdOss.hh:345
Definition XrdOssVS.hh:88
Definition XrdOss.hh:498
virtual int Reloc(const char *tident, const char *path, const char *cgName, const char *anchor=0)
virtual int Mkdir(const char *path, mode_t mode, int mkpath=0, XrdOucEnv *envP=0)=0
virtual int StatPF(const char *path, struct stat *buff, int opts)
static const int PF_dStat
Definition XrdOss.hh:772
virtual int StatVS(XrdOssVSInfo *vsP, const char *sname=0, int updt=0)
static const int PF_dNums
Definition XrdOss.hh:770
static const int PF_csVer
verified file checksums present
Definition XrdOss.hh:777
virtual int Create(const char *tid, const char *path, mode_t mode, XrdOucEnv &env, int opts=0)=0
virtual void Connect(XrdOucEnv &env)
virtual int StatXP(const char *path, unsigned long long &attr, XrdOucEnv *envP=0)
virtual XrdOssDF * newFile(const char *tident)=0
virtual void Disc(XrdOucEnv &env)
virtual int StatFS(const char *path, char *buff, int &blen, XrdOucEnv *envP=0)
virtual int Chmod(const char *path, mode_t mode, XrdOucEnv *envP=0)=0
static const int PF_csVun
unverified file checksums present
Definition XrdOss.hh:778
virtual int Lfn2Pfn(const char *Path, char *buff, int blen)
Definition XrdOss.hh:872
virtual int Remdir(const char *path, int Opts=0, XrdOucEnv *envP=0)=0
virtual int Init(XrdSysLogger *lp, const char *cfn)=0
virtual const char * Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
Definition XrdOss.hh:889
virtual int Init(XrdSysLogger *lp, const char *cfn, XrdOucEnv *envP)
Definition XrdOss.hh:621
static const int PF_dInfo
Definition XrdOss.hh:769
virtual int StatXA(const char *path, char *buff, int &blen, XrdOucEnv *envP=0)
virtual int Rename(const char *oPath, const char *nPath, XrdOucEnv *oEnvP=0, XrdOucEnv *nEnvP=0)=0
virtual void EnvInfo(XrdOucEnv *envP)
XrdOss()
Constructor and Destructor.
Definition XrdOss.hh:896
virtual int StatLS(XrdOucEnv &env, const char *path, char *buff, int &blen)
virtual int Truncate(const char *path, unsigned long long fsize, XrdOucEnv *envP=0)=0
virtual int Stats(char *buff, int blen)
Definition XrdOss.hh:706
virtual int FSctl(int cmd, int alen, const char *args, char **resp=0)
virtual XrdOssDF * newDir(const char *tident)=0
virtual int Stat(const char *path, struct stat *buff, int opts=0, XrdOucEnv *envP=0)=0
virtual int Unlink(const char *path, int Opts=0, XrdOucEnv *envP=0)=0
virtual ~XrdOss()
Definition XrdOss.hh:897
virtual int StatPF(const char *path, struct stat *buff)
Definition XrdOss.hh:782
static const int PF_isLFN
Definition XrdOss.hh:771
virtual uint64_t Features()
Definition XrdOucEnv.hh:42
Definition XrdSfsAio.hh:59
Definition XrdSysLogger.hh:53
Definition XrdOucIOVec.hh:41