XRootD
Loading...
Searching...
No Matches
XrdSsiStat.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d S s i S t a t . c c */
4/* */
5/* (c) 2014 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 <cstdlib>
35
36#include "XrdVersion.hh"
37#include "XrdOss/XrdOss.hh"
39#include "XrdOuc/XrdOucEnv.hh"
40#include "XrdOuc/XrdOucPList.hh"
44#include "XrdSys/XrdSysError.hh"
45
46//------------------------------------------------------------------------------
49//------------------------------------------------------------------------------
50
51
52/******************************************************************************/
53/* E x t e r n s */
54/******************************************************************************/
55
56namespace XrdSsi
57{
58extern XrdSsiProvider *Provider;
59
60extern XrdOucPListAnchor FSPath;
61
62extern bool fsChk;
63
64extern XrdSysError Log;
65};
66
67using namespace XrdSsi;
68
69/******************************************************************************/
70/* X r d S s i S t a t I n f o */
71/******************************************************************************/
72
73extern "C"
74{
75int XrdSsiStatInfo(const char *path, struct stat *buff,
76 int opts, XrdOucEnv *envP, const char *lfn)
77{
78 static const int regFile = S_IFREG | S_IRUSR | S_IWUSR;
80
81// Check for stat changes
82//
83 if (!buff)
84 {if (!Provider || (fsChk && FSPath.Find(lfn))) return 0;
86 Provider->ResourceRemoved(lfn);
87 else Provider->ResourceAdded(lfn);
88 return 0;
89 }
90
91// Check if this should be issued to the file system
92//
93 if (fsChk && FSPath.Find(lfn)) return stat(path, buff);
94
95// Check resource availability
96//
97 if (Provider && (rStat = Provider->QueryResource(path)))
98 {memset(buff, 0, sizeof(struct stat));
99 buff->st_mode = regFile;
100 if (rStat == XrdSsiProvider::isPresent) return 0;
101 if (!(opts & XRDOSS_resonly)) {buff->st_mode |= S_IFBLK; return 0;}
102 }
103
104// Resource is not available
105//
106 errno = ENOENT;
107 return -1;
108}
109
110/******************************************************************************/
111/* X r d O s s S t a t I n f o I n i t */
112/******************************************************************************/
113
114//------------------------------------------------------------------------------
117//------------------------------------------------------------------------------
118
121 const char *config_fn,
122 const char *parms,
123 XrdOucEnv *envP)
124{
125 XrdSsiSfsConfig Config(true);
126
127// Setup the logger
128//
129 Log.logger(Logger);
130
131// Process the configuration file so that we get the service provider object
132//
133 if (!Config.Configure(config_fn, envP)) return 0;
134
135// Return the stat function
136//
138}
139};
140
141/******************************************************************************/
142/* V e r s i o n I n f o r m a t i o n */
143/******************************************************************************/
144
static XrdSysLogger Logger
XrdOssStatInfo_t XrdOssStatInfoInit(XrdOss *native_oss, XrdSysLogger *Logger, const char *config_fn, const char *parms)
int(* XrdOssStatInfo2_t)(const char *path, struct stat *buff, int opts, XrdOucEnv *envP, const char *lfn)
#define XRDOSS_resonly
Definition XrdOss.hh:486
#define stat(a, b)
Definition XrdPosix.hh:96
struct myOpts opts
int XrdSsiStatInfo(const char *path, struct stat *buff, int opts, XrdOucEnv *envP, const char *lfn)
Definition XrdSsiStat.cc:75
XrdOssStatInfo2_t XrdOssStatInfoInit2(XrdOss *native_oss, XrdSysLogger *Logger, const char *config_fn, const char *parms, XrdOucEnv *envP)
XrdVERSIONINFO(XrdOssStatInfoInit, XrdSsiStat)
static const int FileRemoved
Path has been removed.
bool fsChk
Definition XrdSsiFile.cc:56
XrdSsiProvider * Provider
XrdSysError Log
XrdOucPListAnchor FSPath
Definition XrdSsiFile.cc:55