xrootd
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 & X r d O s s D F */
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 <errno.h>
35 #include <strings.h>
36 #include <sys/stat.h>
37 #include <sys/types.h>
38 #include <string.h>
39 
40 #include "XrdOuc/XrdOucIOVec.hh"
41 
42 class XrdOucEnv;
43 class XrdSysLogger;
44 class XrdSfsAio;
45 
46 #ifndef XrdOssOK
47 #define XrdOssOK 0
48 #endif
49 
50 /******************************************************************************/
51 /* X r d O s s D F */
52 /******************************************************************************/
53 
58 
59 class XrdOssDF
60 {
61 public:
62  // Directory oriented methods
63 virtual int Opendir(const char *, XrdOucEnv &) {return -ENOTDIR;}
64 virtual int Readdir(char *buff, int blen) {(void)buff; (void)blen; return -ENOTDIR;}
65 virtual int StatRet(struct stat *buff) {(void)buff; return -ENOTSUP;}
66 
67  // File oriented methods
68 virtual int Fchmod(mode_t mode) {(void)mode; return -EISDIR;}
69 virtual int Fstat(struct stat *) {return -EISDIR;}
70 virtual int Fsync() {return -EISDIR;}
71 virtual int Fsync(XrdSfsAio *aiop) {(void)aiop; return -EISDIR;}
72 virtual int Ftruncate(unsigned long long) {return -EISDIR;}
73 virtual int getFD() {return -1;}
74 virtual off_t getMmap(void **addr) {(void)addr; return 0;}
75 virtual int isCompressed(char *cxidp=0) {(void)cxidp; return -EISDIR;}
76 virtual int Open(const char *, int, mode_t, XrdOucEnv &) {return -EISDIR;}
77 virtual ssize_t Read(off_t, size_t) {return (ssize_t)-EISDIR;}
78 virtual ssize_t Read(void *, off_t, size_t) {return (ssize_t)-EISDIR;}
79 virtual int Read(XrdSfsAio *aoip) {(void)aoip; return (ssize_t)-EISDIR;}
80 virtual ssize_t ReadRaw( void *, off_t, size_t) {return (ssize_t)-EISDIR;}
81 virtual ssize_t Write(const void *, off_t, size_t) {return (ssize_t)-EISDIR;}
82 virtual int Write(XrdSfsAio *aiop) {(void)aiop; return (ssize_t)-EISDIR;}
83 
84 // Implemented in the header, as many folks will be happy with the default.
85 //
86 virtual ssize_t ReadV(XrdOucIOVec *readV, int n)
87  {ssize_t nbytes = 0, curCount = 0;
88  for (int i=0; i<n; i++)
89  {curCount = Read((void *)readV[i].data,
90  (off_t)readV[i].offset,
91  (size_t)readV[i].size);
92  if (curCount != readV[i].size)
93  {if (curCount < 0) return curCount;
94  return -ESPIPE;
95  }
96  nbytes += curCount;
97  }
98  return nbytes;
99  }
100 
101 // Implemented in the header, as many folks will be happy with the default.
102 //
103 virtual ssize_t WriteV(XrdOucIOVec *writeV, int n)
104  {ssize_t nbytes = 0, curCount = 0;
105  for (int i=0; i<n; i++)
106  {curCount =Write((void *)writeV[i].data,
107  (off_t)writeV[i].offset,
108  (size_t)writeV[i].size);
109  if (curCount != writeV[i].size)
110  {if (curCount < 0) return curCount;
111  return -ESPIPE;
112  }
113  nbytes += curCount;
114  }
115  return nbytes;
116  }
117 
118  // Methods common to both
119 virtual int Close(long long *retsz=0)=0;
120 inline int Handle() {return fd;}
121 virtual int Fctl(int cmd, int alen, const char *args, char **resp=0)
122 {
123  (void)cmd; (void)alen; (void)args; (void)resp;
124  return -ENOTSUP;
125 }
126 
127  XrdOssDF() {fd = -1;}
128 virtual ~XrdOssDF() {}
129 
130 protected:
131 
132 int fd; // The associated file descriptor.
133 };
134 
135 /******************************************************************************/
136 /* X r d O s s */
137 /******************************************************************************/
138 
139 // Options that can be passed to Create()
140 //
141 #define XRDOSS_mkpath 0x01
142 #define XRDOSS_new 0x02
143 #define XRDOSS_Online 0x04
144 #define XRDOSS_isPFN 0x10
145 #define XRDOSS_isMIG 0x20
146 #define XRDOSS_setnoxa 0x40
147 
148 // Options that can be passed to Stat()
149 //
150 #define XRDOSS_resonly 0x0001
151 #define XRDOSS_updtatm 0x0002
152 #define XRDOSS_preop 0x0004
153 
154 // Class passed to StatVS()
155 //
157 {
158 public:
159 long long Total; // Total bytes
160 long long Free; // Total bytes free
161 long long Large; // Total bytes in largest partition
162 long long LFree; // Max bytes free in contiguous chunk
163 long long Usage; // Used bytes (if usage enabled)
164 long long Quota; // Quota bytes (if quota enabled)
165 int Extents; // Number of partitions/extents
167 
168  XrdOssVSInfo() : Total(0),Free(0),Large(0),LFree(0),Usage(-1),
169  Quota(-1),Extents(0),Reserved(0) {}
171 };
172 
173 class XrdOss
174 {
175 public:
176 virtual XrdOssDF *newDir(const char *tident)=0;
177 virtual XrdOssDF *newFile(const char *tident)=0;
178 
179 virtual int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0)=0;
180 virtual int Create(const char *, const char *, mode_t, XrdOucEnv &,
181  int opts=0)=0;
182 virtual int Init(XrdSysLogger *, const char *)=0;
183 virtual int Mkdir(const char *, mode_t mode, int mkpath=0,
184  XrdOucEnv *eP=0)=0;
185 virtual int Reloc(const char *, const char *, const char *, const char *x=0)
186  {(void)x; return -ENOTSUP;}
187 virtual int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0)=0;
188 virtual int Rename(const char *, const char *,
189  XrdOucEnv *eP1=0, XrdOucEnv *eP2=0)=0;
190 virtual int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0)=0;
191 virtual int StatFS(const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
192 { (void)path; (void)buff; (void)blen; (void)eP; return -ENOTSUP;}
193 virtual int StatLS(XrdOucEnv &env, const char *cgrp, char *buff, int &blen)
194 { (void)env; (void)cgrp; (void)buff; (void)blen; return -ENOTSUP;}
195 virtual int StatPF(const char *, struct stat *)
196  {return -ENOTSUP;}
197 virtual int StatXA(const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
198 { (void)path; (void)buff; (void)blen; (void)eP; return -ENOTSUP;}
199 virtual int StatXP(const char *path, unsigned long long &attr,
200  XrdOucEnv *eP=0)
201 { (void)path; (void)attr; (void)eP; return -ENOTSUP;}
202 virtual int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0)=0;
203 virtual int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0)=0;
204 
205 virtual int Stats(char *bp, int bl) { (void)bp; (void)bl; return 0;}
206 
207 virtual int StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0)
208 { (void)sP; (void)sname; (void)updt; return -ENOTSUP;}
209 
210 virtual int Lfn2Pfn(const char *Path, char *buff, int blen)
211  {if ((int)strlen(Path) >= blen) return -ENAMETOOLONG;
212  strcpy(buff, Path); return 0;
213  }
214 virtual
215 const char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
216 { (void)buff; (void)blen; rc = 0; return Path;}
217 
218 virtual int FSctl(int cmd, int alen, const char *args, char **resp=0)
219 { (void)cmd; (void)alen; (void)args; (void)resp; return -ENOTSUP;}
220 
221 virtual void EnvInfo(XrdOucEnv *envP) {(void)envP;}
222 
223  XrdOss() {}
224 virtual ~XrdOss() {}
225 };
226 
227 /******************************************************************************/
228 /* 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 */
229 /******************************************************************************/
230 
231 //------------------------------------------------------------------------------
252 //------------------------------------------------------------------------------
260 //------------------------------------------------------------------------------
266 //------------------------------------------------------------------------------
267 
273 #endif
int Extents
Definition: XrdOss.hh:165
XrdOssDF()
Definition: XrdOss.hh:127
long long Quota
Definition: XrdOss.hh:164
virtual int StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0)
Definition: XrdOss.hh:207
virtual int Stats(char *bp, int bl)
Definition: XrdOss.hh:205
virtual int Fctl(int cmd, int alen, const char *args, char **resp=0)
Definition: XrdOss.hh:121
virtual int Readdir(char *buff, int blen)
Definition: XrdOss.hh:64
virtual XrdOssDF * newFile(const char *tident)=0
virtual int StatFS(const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
Definition: XrdOss.hh:191
virtual ssize_t ReadRaw(void *, off_t, size_t)
Definition: XrdOss.hh:80
virtual int Fsync(XrdSfsAio *aiop)
Definition: XrdOss.hh:71
virtual int Fstat(struct stat *)
Definition: XrdOss.hh:69
long long LFree
Definition: XrdOss.hh:162
virtual int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0)=0
virtual int StatXA(const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
Definition: XrdOss.hh:197
virtual ssize_t Read(void *, off_t, size_t)
Definition: XrdOss.hh:78
virtual int Create(const char *, const char *, mode_t, XrdOucEnv &, int opts=0)=0
virtual ssize_t ReadV(XrdOucIOVec *readV, int n)
Definition: XrdOss.hh:86
virtual XrdOssDF * newDir(const char *tident)=0
XrdOssVSInfo()
Definition: XrdOss.hh:168
virtual int isCompressed(char *cxidp=0)
Definition: XrdOss.hh:75
Definition: XrdOss.hh:156
virtual int Fchmod(mode_t mode)
Definition: XrdOss.hh:68
long long Total
Definition: XrdOss.hh:159
int fd
Definition: XrdOss.hh:132
virtual ~XrdOssDF()
Definition: XrdOss.hh:128
virtual ssize_t Read(off_t, size_t)
Definition: XrdOss.hh:77
virtual int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0)=0
virtual int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0)=0
Definition: XrdOucEnv.hh:41
Definition: XrdOucIOVec.hh:40
virtual const char * Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
Definition: XrdOss.hh:215
~XrdOssVSInfo()
Definition: XrdOss.hh:170
virtual ssize_t Write(const void *, off_t, size_t)
Definition: XrdOss.hh:81
virtual int Mkdir(const char *, mode_t mode, int mkpath=0, XrdOucEnv *eP=0)=0
virtual int StatPF(const char *, struct stat *)
Definition: XrdOss.hh:195
long long Usage
Definition: XrdOss.hh:163
virtual int Reloc(const char *, const char *, const char *, const char *x=0)
Definition: XrdOss.hh:185
virtual int Fsync()
Definition: XrdOss.hh:70
virtual int Close(long long *retsz=0)=0
virtual int Open(const char *, int, mode_t, XrdOucEnv &)
Definition: XrdOss.hh:76
virtual int FSctl(int cmd, int alen, const char *args, char **resp=0)
Definition: XrdOss.hh:218
Definition: XrdSysLogger.hh:52
virtual int Opendir(const char *, XrdOucEnv &)
Definition: XrdOss.hh:63
virtual int Rename(const char *, const char *, XrdOucEnv *eP1=0, XrdOucEnv *eP2=0)=0
virtual int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0)=0
Definition: XrdOss.hh:173
virtual void EnvInfo(XrdOucEnv *envP)
Definition: XrdOss.hh:221
Definition: XrdOss.hh:59
virtual int StatXP(const char *path, unsigned long long &attr, XrdOucEnv *eP=0)
Definition: XrdOss.hh:199
virtual int StatLS(XrdOucEnv &env, const char *cgrp, char *buff, int &blen)
Definition: XrdOss.hh:193
int Handle()
Definition: XrdOss.hh:120
long long Large
Definition: XrdOss.hh:161
long long Free
Definition: XrdOss.hh:160
virtual int Lfn2Pfn(const char *Path, char *buff, int blen)
Definition: XrdOss.hh:210
virtual ~XrdOss()
Definition: XrdOss.hh:224
virtual int Init(XrdSysLogger *, const char *)=0
int Reserved
Definition: XrdOss.hh:166
Definition: XrdSfsAio.hh:57
XrdOss()
Definition: XrdOss.hh:223
virtual off_t getMmap(void **addr)
Definition: XrdOss.hh:74
virtual ssize_t WriteV(XrdOucIOVec *writeV, int n)
Definition: XrdOss.hh:103
virtual int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0)=0
virtual int getFD()
Definition: XrdOss.hh:73
virtual int Write(XrdSfsAio *aiop)
Definition: XrdOss.hh:82
virtual int Read(XrdSfsAio *aoip)
Definition: XrdOss.hh:79
virtual int StatRet(struct stat *buff)
Definition: XrdOss.hh:65
virtual int Ftruncate(unsigned long long)
Definition: XrdOss.hh:72