XRootD
Loading...
Searching...
No Matches
XrdOssSIgpfsT.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d O s s S I g p f s T . c c */
4/* */
5/* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */
6/* All Rights Reserved */
7/* Produced by Andrew Hanushevsky for Stanford University under contract */
8/* DE-AC02-76-SFO0515 with the Department of Energy */
9/* */
10/* This file is part of the XRootD software suite. */
11/* */
12/* XRootD is free software: you can redistribute it and/or modify it under */
13/* the terms of the GNU Lesser General Public License as published by the */
14/* Free Software Foundation, either version 3 of the License, or (at your */
15/* option) any later version. */
16/* */
17/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20/* License for more details. */
21/* */
22/* You should have received a copy of the GNU Lesser General Public License */
23/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25/* */
26/* The copyright holder's institutional names and contributor's names may not */
27/* be used to endorse or promote products derived from this software without */
28/* specific prior written permission of the institution or contributor. */
29/******************************************************************************/
30
31#include <sys/types.h>
32#include <sys/stat.h>
33#include <unistd.h>
34#include <strings.h>
35#include <cstring>
36#include <cstdlib>
37
38#include "XrdVersion.hh"
39#include "XrdOss/XrdOss.hh"
41#include "XrdOuc/XrdOucEnv.hh"
42#include "XrdSys/XrdSysError.hh"
43
44//------------------------------------------------------------------------------
63//------------------------------------------------------------------------------
64
65extern "C"
66{
67/******************************************************************************/
68/* X r d O s s S t a t I n f o R e s O n l y */
69/******************************************************************************/
70
71//------------------------------------------------------------------------------
76//------------------------------------------------------------------------------
77
79
80/******************************************************************************/
81/* X r d O s s S t a t I n f o */
82/******************************************************************************/
83
84int XrdOssStatInfo(const char *path, struct stat *buff,
85 int opts, XrdOucEnv *envP)
86{
87
88// Do a regular stat and if it fails return immediately
89//
90 if (stat(path, buff)) return -1;
91
92// Check if this is an online file, return success
93//
94 if (buff->st_size == 0 || buff->st_blocks) return 0;
95
96// If caller only wants resident files, then return ENOENT. If we are
97// restricting the caller to residdent only files, return the proper errno.
98// Otherwise, we indicate the file actually exists.
99//
100 if (opts & XRDOSS_resonly) errno = ENOENT;
101 else errno = XrdOssStatInfoResOnly;
102 return (errno ? -1 : 0);
103}
104
105/******************************************************************************/
106/* X r d O s s S t a t I n f o P a r m */
107/******************************************************************************/
108
109int XrdOssStatInfoParm(XrdSysError &eDest, const char *var, const char *val)
110{
111 if (!strcmp(val, "all")) return 0;
112 else if (!strcmp(val, "online")) return ENOENT;
113 else if (!strcmp(val, "online:eperm")) return EPERM;
114
115 eDest.Say("Config", " Invalid statlib parameter, '",var,"=",val,"'.");
116 return -1;
117}
118
119/******************************************************************************/
120/* X r d O s s S t a t I n f o I n i t */
121/******************************************************************************/
122
123//------------------------------------------------------------------------------
130//------------------------------------------------------------------------------
131
134 const char *config_fn,
135 const char *parms)
136{
137 const char *myProg = getenv("XRDPROG");
138 const char *myRole = getenv("XRDROLE");
139 const char *xWhat = " only online ";
141 XrdOucEnv myEnv(parms);
142 char zRole[16], vChk[512], *val;
143 int offLine = 0;
144
145// Readjust the role to be backwards compatible
146//
147 if (myRole)
148 { if (!strncmp("proxy", myRole, 5))
149 {strcpy(zRole, "proxy"); myRole = zRole;}
150 else if (!strncmp("meta", myRole, 4))
151 {strcpy(zRole, "manager"); myRole = zRole;}
152 }
153
154// Check for global parms first
155//
156 strcpy(vChk, "stat");
157 if ((val = myEnv.Get(vChk))
158 && (offLine = XrdOssStatInfoParm(Say, vChk, val)) < 0) return 0;
159
160// Check for program specific variable
161//
162 if (myProg)
163 {strcat(vChk, "."); strcat(vChk, myProg);
164 if ((val = myEnv.Get(vChk))
165 && (offLine = XrdOssStatInfoParm(Say, vChk, val)) < 0) return 0;
166 }
167
168// Check for role specific variable
169//
170 if (myProg && myRole)
171 {strcat(vChk, "."); strcat(vChk, myRole);
172 if ((val = myEnv.Get(vChk))
173 && (offLine = XrdOssStatInfoParm(Say, vChk, val)) < 0) return 0;
174 }
175
176// Now set the global variable indicate whether we will only allow online
177// files or all files (i.e. online and offline).
178//
179 XrdOssStatInfoResOnly = offLine;
180
181// Record in the log what stat will stat
182//
183 if (myProg) strncpy(vChk, " for ", 6);
184 else *vChk = 0;
185 if (!XrdOssStatInfoResOnly) xWhat = " all ";
186 Say.Say("Config", " stat() allows", xWhat, "files", vChk);
187
188// Return the stat function
189//
191}
192};
193
194/******************************************************************************/
195/* V e r s i o n I n f o r m a t i o n */
196/******************************************************************************/
197
struct stat Stat
Definition XrdCks.cc:49
XrdOucPup XrdCmsParser::Pup & Say
static XrdSysLogger Logger
static XrdSysError eDest(0,"crypto_")
int XrdOssStatInfoParm(XrdSysError &eDest, const char *var, const char *val)
int XrdOssStatInfoResOnly
int XrdOssStatInfo(const char *path, struct stat *buff, int opts, XrdOucEnv *envP)
XrdOssStatInfo_t XrdOssStatInfoInit(XrdOss *native_oss, XrdSysLogger *Logger, const char *config_fn, const char *parms)
XrdVERSIONINFO(XrdOssStatInfoInit, Stat-GPFS+TAPE)
int(* XrdOssStatInfo_t)(const char *path, struct stat *buff, int opts, XrdOucEnv *envP)
#define XRDOSS_resonly
Definition XrdOss.hh:486
#define stat(a, b)
Definition XrdPosix.hh:101
struct myOpts opts
char * Get(const char *varname)
Definition XrdOucEnv.hh:69