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 class XrdOucEnv;
41 class XrdSysLogger;
42 class XrdSfsAio;
43 
44 #ifndef XrdOssOK
45 #define XrdOssOK 0
46 #endif
47 
48 /******************************************************************************/
49 /* X r d O s s D F */
50 /******************************************************************************/
51 
56 
57 class XrdOssDF
58 {
59 public:
60  // Directory oriented methods
61 virtual int Opendir(const char *, XrdOucEnv &) {return -ENOTDIR;}
62 virtual int Readdir(char *buff, int blen) {return -ENOTDIR;}
63 
64  // File oriented methods
65 virtual int Fchmod(mode_t mode) {return -EISDIR;}
66 virtual int Fstat(struct stat *) {return -EISDIR;}
67 virtual int Fsync() {return -EISDIR;}
68 virtual int Fsync(XrdSfsAio *aiop) {return -EISDIR;}
69 virtual int Ftruncate(unsigned long long) {return -EISDIR;}
70 virtual int getFD() {return -1;}
71 virtual off_t getMmap(void **addr) {return 0;}
72 virtual int isCompressed(char *cxidp=0) {return -EISDIR;}
73 virtual int Open(const char *, int, mode_t, XrdOucEnv &) {return -EISDIR;}
74 virtual ssize_t Read(off_t, size_t) {return (ssize_t)-EISDIR;}
75 virtual ssize_t Read(void *, off_t, size_t) {return (ssize_t)-EISDIR;}
76 virtual int Read(XrdSfsAio *aoip) {return (ssize_t)-EISDIR;}
77 virtual ssize_t ReadRaw( void *, off_t, size_t) {return (ssize_t)-EISDIR;}
78 virtual ssize_t Write(const void *, off_t, size_t) {return (ssize_t)-EISDIR;}
79 virtual int Write(XrdSfsAio *aiop) {return (ssize_t)-EISDIR;}
80 
81  // Methods common to both
82 virtual int Close(long long *retsz=0)=0;
83 inline int Handle() {return fd;}
84 
85  XrdOssDF() {fd = -1;}
86 virtual ~XrdOssDF() {}
87 
88 protected:
89 
90 int fd; // The associated file descriptor.
91 };
92 
93 /******************************************************************************/
94 /* X r d O s s */
95 /******************************************************************************/
96 
97 // Options that can be passed to Create()
98 //
99 #define XRDOSS_mkpath 0x01
100 #define XRDOSS_new 0x02
101 #define XRDOSS_Online 0x04
102 #define XRDOSS_isPFN 0x10
103 #define XRDOSS_isMIG 0x20
104 #define XRDOSS_setnoxa 0x40
105 
106 // Options that can be passed to Stat()
107 //
108 #define XRDOSS_resonly 0x01
109 #define XRDOSS_updtatm 0x02
110 
111 // Class passed to StatVS()
112 //
114 {
115 public:
116 long long Total; // Total bytes
117 long long Free; // Total bytes free
118 long long Large; // Total bytes in largest partition
119 long long LFree; // Max bytes free in contiguous chunk
120 long long Usage; // Used bytes (if usage enabled)
121 long long Quota; // Quota bytes (if quota enabled)
122 int Extents; // Number of partitions/extents
124 
125  XrdOssVSInfo() : Total(0),Free(0),Large(0),LFree(0),Usage(-1),
126  Quota(-1),Extents(0),Reserved(0) {}
128 };
129 
130 class XrdOss
131 {
132 public:
133 virtual XrdOssDF *newDir(const char *tident)=0;
134 virtual XrdOssDF *newFile(const char *tident)=0;
135 
136 virtual int Chmod(const char *, mode_t mode, XrdOucEnv *eP=0)=0;
137 virtual int Create(const char *, const char *, mode_t, XrdOucEnv &,
138  int opts=0)=0;
139 virtual int Init(XrdSysLogger *, const char *)=0;
140 virtual int Mkdir(const char *, mode_t mode, int mkpath=0,
141  XrdOucEnv *eP=0)=0;
142 virtual int Reloc(const char *, const char *, const char *, const char *x=0)
143  {return -ENOTSUP;}
144 virtual int Remdir(const char *, int Opts=0, XrdOucEnv *eP=0)=0;
145 virtual int Rename(const char *, const char *,
146  XrdOucEnv *eP1=0, XrdOucEnv *eP2=0)=0;
147 virtual int Stat(const char *, struct stat *, int opts=0, XrdOucEnv *eP=0)=0;
148 virtual int StatFS(const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
149  {return -ENOTSUP;}
150 virtual int StatLS(XrdOucEnv &env, const char *cgrp, char *buff, int &blen)
151  {return -ENOTSUP;}
152 virtual int StatXA(const char *path, char *buff, int &blen, XrdOucEnv *eP=0)
153  {return -ENOTSUP;}
154 virtual int StatXP(const char *path, unsigned long long &attr,
155  XrdOucEnv *eP=0) {return -ENOTSUP;}
156 virtual int Truncate(const char *, unsigned long long, XrdOucEnv *eP=0)=0;
157 virtual int Unlink(const char *, int Opts=0, XrdOucEnv *eP=0)=0;
158 
159 virtual int Stats(char *bp, int bl) {return 0;}
160 
161 virtual int StatVS(XrdOssVSInfo *sP, const char *sname=0, int updt=0)
162  {return -ENOTSUP;}
163 
164 virtual int Lfn2Pfn(const char *Path, char *buff, int blen)
165  {if ((int)strlen(Path) >= blen) return -ENAMETOOLONG;
166  strcpy(buff, Path); return 0;
167  }
168 virtual
169 const char *Lfn2Pfn(const char *Path, char *buff, int blen, int &rc)
170  {rc = 0; return Path;}
171 
172  XrdOss() {}
173 virtual ~XrdOss() {}
174 };
175 
176 /******************************************************************************/
177 /* 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 */
178 /******************************************************************************/
179 
180 //------------------------------------------------------------------------------
201 //------------------------------------------------------------------------------
209 //------------------------------------------------------------------------------
215 //------------------------------------------------------------------------------
216 
222 #endif