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#define XRDOSS_HASXERT 0x0000000000000080ULL
483
484// Options that can be passed to Stat()
485//
486#define XRDOSS_resonly 0x0001
487#define XRDOSS_updtatm 0x0002
488#define XRDOSS_preop 0x0004
489
490// Commands that can be passed to FSctl
491//
492#define XRDOSS_FSCTLFA 0x0001
493
494/******************************************************************************/
495/* C l a s s X r d O s s */
496/******************************************************************************/
497
499{
500public:
501
502//-----------------------------------------------------------------------------
509//-----------------------------------------------------------------------------
510
511virtual XrdOssDF *newDir(const char *tident)=0;
512
513//-----------------------------------------------------------------------------
520//-----------------------------------------------------------------------------
521
522virtual XrdOssDF *newFile(const char *tident)=0;
523
524//-----------------------------------------------------------------------------
532//-----------------------------------------------------------------------------
533
534virtual int Chmod(const char * path, mode_t mode, XrdOucEnv *envP=0)=0;
535
536//-----------------------------------------------------------------------------
540//-----------------------------------------------------------------------------
541
542virtual void Connect(XrdOucEnv &env);
543
544//-----------------------------------------------------------------------------
557//-----------------------------------------------------------------------------
558
559virtual int Create(const char *tid, const char *path,
560 mode_t mode, XrdOucEnv &env,
561 int opts=0)=0;
562
563//-----------------------------------------------------------------------------
567//-----------------------------------------------------------------------------
568
569virtual void Disc(XrdOucEnv &env);
570
571//-----------------------------------------------------------------------------
575//-----------------------------------------------------------------------------
576
577virtual void EnvInfo(XrdOucEnv *envP);
578
579//-----------------------------------------------------------------------------
583//-----------------------------------------------------------------------------
584
585virtual uint64_t Features();
586
587//-----------------------------------------------------------------------------
597//-----------------------------------------------------------------------------
598
599virtual int FSctl(int cmd, int alen, const char *args, char **resp=0);
600
601//-----------------------------------------------------------------------------
608//-----------------------------------------------------------------------------
609
610virtual int Init(XrdSysLogger *lp, const char *cfn)=0;
611
612//-----------------------------------------------------------------------------
620//-----------------------------------------------------------------------------
621
622virtual int Init(XrdSysLogger *lp, const char *cfn, XrdOucEnv *envP)
623 {return Init(lp, cfn);}
624
625//-----------------------------------------------------------------------------
634//-----------------------------------------------------------------------------
635
636virtual int Mkdir(const char *path, mode_t mode, int mkpath=0,
637 XrdOucEnv *envP=0)=0;
638
639//-----------------------------------------------------------------------------
648//-----------------------------------------------------------------------------
649
650virtual int Reloc(const char *tident, const char *path,
651 const char *cgName, const char *anchor=0);
652
653//-----------------------------------------------------------------------------
663//-----------------------------------------------------------------------------
664
665virtual int Remdir(const char *path, int Opts=0, XrdOucEnv *envP=0)=0;
666
667//-----------------------------------------------------------------------------
676//-----------------------------------------------------------------------------
677
678virtual int Rename(const char *oPath, const char *nPath,
679 XrdOucEnv *oEnvP=0, XrdOucEnv *nEnvP=0)=0;
680
681//-----------------------------------------------------------------------------
693//-----------------------------------------------------------------------------
694
695virtual int Stat(const char *path, struct stat *buff,
696 int opts=0, XrdOucEnv *envP=0)=0;
697
698//-----------------------------------------------------------------------------
705//-----------------------------------------------------------------------------
706
707virtual int Stats(char *buff, int blen) {(void)buff; (void)blen; return 0;}
708
709//-----------------------------------------------------------------------------
724//-----------------------------------------------------------------------------
725
726virtual int StatFS(const char *path, char *buff, int &blen,
727 XrdOucEnv *envP=0);
728
729//-----------------------------------------------------------------------------
745//-----------------------------------------------------------------------------
746
747virtual int StatLS(XrdOucEnv &env, const char *path,
748 char *buff, int &blen);
749
750//-----------------------------------------------------------------------------
768//-----------------------------------------------------------------------------
769
770static const int PF_dInfo = 0x00000001;
771static const int PF_dNums = 0x00000002;
772static const int PF_isLFN = 0x00000004;
773static const int PF_dStat = 0x00000008;
774
775// Bits returned in st_rdev when PF_dStat specified in opts. Absence of either
776// PF_csVer and PF_csVun flags means that the file has no checksums present.
777//
778static const int PF_csVer = 0x00000001;
779static const int PF_csVun = 0x00000002;
780
781virtual int StatPF(const char *path, struct stat *buff, int opts);
782
783virtual int StatPF(const char *path, struct stat *buff)
784 {return StatPF(path, buff, 0);} // Backward compat
785
786//-----------------------------------------------------------------------------
798//-----------------------------------------------------------------------------
799
800virtual int StatVS(XrdOssVSInfo *vsP, const char *sname=0, int updt=0);
801
802//-----------------------------------------------------------------------------
815//-----------------------------------------------------------------------------
816
817virtual int StatXA(const char *path, char *buff, int &blen,
818 XrdOucEnv *envP=0);
819
820//-----------------------------------------------------------------------------
828//-----------------------------------------------------------------------------
829
830virtual int StatXP(const char *path, unsigned long long &attr,
831 XrdOucEnv *envP=0);
832
833//-----------------------------------------------------------------------------
841//-----------------------------------------------------------------------------
842
843virtual int Truncate(const char *path, unsigned long long fsize,
844 XrdOucEnv *envP=0)=0;
845
846//-----------------------------------------------------------------------------
857//-----------------------------------------------------------------------------
858
859virtual int Unlink(const char *path, int Opts=0, XrdOucEnv *envP=0)=0;
860
861 // Default Name-to-Name Methods
862
863//-----------------------------------------------------------------------------
871//-----------------------------------------------------------------------------
872
873virtual int Lfn2Pfn(const char *Path, char *buff, int blen)
874 {if ((int)strlen(Path) >= blen) return -ENAMETOOLONG;
875 strcpy(buff, Path); return 0;
876 }
877
878//-----------------------------------------------------------------------------
888//-----------------------------------------------------------------------------
889virtual
890const char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
891 { (void)buff; (void)blen; rc = 0; return Path;}
892
893//-----------------------------------------------------------------------------
895//-----------------------------------------------------------------------------
896
898virtual ~XrdOss() {}
899};
900
901/******************************************************************************/
902/* 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 */
903/******************************************************************************/
904
905//------------------------------------------------------------------------------
928//------------------------------------------------------------------------------
929
930//------------------------------------------------------------------------------
932//------------------------------------------------------------------------------
933
934typedef XrdOss *(*XrdOssGetStorageSystem_t) (XrdOss *native_oss,
936 const char *config_fn,
937 const char *parms);
938
939typedef XrdOss *(*XrdOssGetStorageSystem2_t)(XrdOss *native_oss,
941 const char *config_fn,
942 const char *parms,
943 XrdOucEnv *envP);
944
946
977
978//------------------------------------------------------------------------------
984//------------------------------------------------------------------------------
985
991#endif
#define tident
static XrdSysLogger Logger
XrdOssGetStorageSystem2_t XrdOssAddStorageSystem2_t
Definition XrdOss.hh:945
XrdOss *(* XrdOssGetStorageSystem2_t)(XrdOss *native_oss, XrdSysLogger *Logger, const char *config_fn, const char *parms, XrdOucEnv *envP)
Definition XrdOss.hh:939
#define stat(a, b)
Definition XrdPosix.hh:101
int Mode
XrdOucString Path
struct myOpts opts
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 ssize_t WriteV(XrdOucIOVec *writeV, int wrvcnt)
Definition XrdOss.cc:257
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 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
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 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 Read(void *buffer, off_t offset, size_t size)
Definition XrdOss.hh:294
short rsvd
Definition XrdOss.hh:457
virtual int Fctl(int cmd, int alen, const char *args, char **resp=0)
Definition XrdOss.cc:150
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 ssize_t pgWrite(void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts)
Definition XrdOss.cc:198
virtual ssize_t pgRead(void *buffer, off_t offset, size_t rdlen, uint32_t *csvec, uint64_t opts)
Definition XrdOss.cc:160
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
virtual ssize_t ReadV(XrdOucIOVec *readV, int rdvcnt)
Definition XrdOss.cc:236
uint16_t DFType()
Definition XrdOss.hh:396
virtual ssize_t Write(const void *buffer, off_t offset, size_t size)
Definition XrdOss.hh:345
virtual int Mkdir(const char *path, mode_t mode, int mkpath=0, XrdOucEnv *envP=0)=0
virtual int FSctl(int cmd, int alen, const char *args, char **resp=0)
Definition XrdOss.cc:66
static const int PF_dStat
Definition XrdOss.hh:773
virtual int StatLS(XrdOucEnv &env, const char *path, char *buff, int &blen)
Definition XrdOss.cc:97
static const int PF_dNums
Definition XrdOss.hh:771
virtual int StatXA(const char *path, char *buff, int &blen, XrdOucEnv *envP=0)
Definition XrdOss.cc:127
static const int PF_csVer
verified file checksums present
Definition XrdOss.hh:778
virtual int Create(const char *tid, const char *path, mode_t mode, XrdOucEnv &env, int opts=0)=0
virtual int StatXP(const char *path, unsigned long long &attr, XrdOucEnv *envP=0)
Definition XrdOss.cc:137
virtual XrdOssDF * newFile(const char *tident)=0
virtual void Connect(XrdOucEnv &env)
Definition XrdOss.cc:42
virtual int Reloc(const char *tident, const char *path, const char *cgName, const char *anchor=0)
Definition XrdOss.cc:76
virtual int Chmod(const char *path, mode_t mode, XrdOucEnv *envP=0)=0
virtual uint64_t Features()
Definition XrdOss.cc:60
virtual int StatPF(const char *path, struct stat *buff, int opts)
Definition XrdOss.cc:107
virtual void Disc(XrdOucEnv &env)
Definition XrdOss.cc:48
static const int PF_csVun
unverified file checksums present
Definition XrdOss.hh:779
virtual int Lfn2Pfn(const char *Path, char *buff, int blen)
Definition XrdOss.hh:873
virtual int Remdir(const char *path, int Opts=0, XrdOucEnv *envP=0)=0
virtual int Init(XrdSysLogger *lp, const char *cfn)=0
virtual int StatVS(XrdOssVSInfo *vsP, const char *sname=0, int updt=0)
Definition XrdOss.cc:117
virtual const char * Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
Definition XrdOss.hh:890
virtual int StatFS(const char *path, char *buff, int &blen, XrdOucEnv *envP=0)
Definition XrdOss.cc:87
virtual int Init(XrdSysLogger *lp, const char *cfn, XrdOucEnv *envP)
Definition XrdOss.hh:622
static const int PF_dInfo
Definition XrdOss.hh:770
virtual void EnvInfo(XrdOucEnv *envP)
Definition XrdOss.cc:54
virtual int Rename(const char *oPath, const char *nPath, XrdOucEnv *oEnvP=0, XrdOucEnv *nEnvP=0)=0
XrdOss()
Constructor and Destructor.
Definition XrdOss.hh:897
virtual int Truncate(const char *path, unsigned long long fsize, XrdOucEnv *envP=0)=0
virtual int Stats(char *buff, int blen)
Definition XrdOss.hh:707
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:898
virtual int StatPF(const char *path, struct stat *buff)
Definition XrdOss.hh:783
static const int PF_isLFN
Definition XrdOss.hh:772