XRootD
Loading...
Searching...
No Matches
XrdOucExport.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d O u c E x p o r t . c c */
4/* */
5/* (c) 2007 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
32#include "XrdOuc/XrdOucPList.hh"
34
35/******************************************************************************/
36/* P a r s e D e f s */
37/******************************************************************************/
38
39/* Function: ParseDefs
40
41 Purpose: Parse: defaults [[no]cache] [[no]check] [[no]dread]
42
43 [[no]filter] [forcero]
44
45 [inplace] [local] [global] [globalro]
46
47 [[no]mig] [[not]migratable] [[no]mkeep]
48
49 [[no]mlock] [[no]mmap] [outplace] [readonly]
50
51 [[no]stage] [stage+] [[no]rcreate]
52
53 [[not]writable] [[no]xattrs]
54
55 Notes: See the oss configuration manual for the meaning of each option.
56
57 Output: Returns updated flags passed as input
58*/
59
60unsigned long long XrdOucExport::ParseDefs(XrdOucStream &Config,
61 XrdSysError &Eroute,
62 unsigned long long Flags)
63{
64 static struct rpathopts
65 {const char *opname;
66 unsigned long long oprem;
67 unsigned long long opadd;
68 unsigned long long opset;} rpopts[] =
69 {
70 {"r/o", 0, XRDEXP_READONLY,XRDEXP_ROW_X},
71 {"readonly", 0, XRDEXP_READONLY,XRDEXP_ROW_X},
72 {"forcero", 0, XRDEXP_FORCERO, XRDEXP_ROW_X},
73 {"notwritable", 0, XRDEXP_READONLY,XRDEXP_ROW_X},
74 {"writable", XRDEXP_NOTRW, 0, XRDEXP_ROW_X},
75 {"r/w", XRDEXP_NOTRW, 0, XRDEXP_ROW_X},
76 {"inplace", 0, XRDEXP_INPLACE, XRDEXP_INPLACE_X},
77 {"outplace", XRDEXP_INPLACE, 0, XRDEXP_INPLACE_X},
78// {"nocache", XRDEXP_PFCACHE, 0, XRDEXP_PFCACHE_X},
79 {"cache", 0, XRDEXP_PFCACHE, XRDEXP_PFCACHE_X},
80 {"nomig", XRDEXP_MIG, 0, XRDEXP_MIG_X},
81 {"mig", 0, XRDEXP_MIG, XRDEXP_MIG_X},
82 {"notmigratable", XRDEXP_MIG, 0, XRDEXP_MIG_X},
83 {"migratable", 0, XRDEXP_MIG, XRDEXP_MIG_X},
84 {"nomkeep", XRDEXP_MKEEP, 0, XRDEXP_MKEEP_X},
85 {"mkeep", 0, XRDEXP_MKEEP, XRDEXP_MKEEP_X},
86 {"nomlock", XRDEXP_MLOK, 0, XRDEXP_MLOK_X},
87 {"mlock", 0, XRDEXP_MLOK, XRDEXP_MLOK_X},
88 {"nommap", XRDEXP_MMAP, 0, XRDEXP_MMAP_X},
89 {"mmap", 0, XRDEXP_MMAP, XRDEXP_MMAP_X},
90 {"mwfiles", 0, XRDEXP_MWMODE, XRDEXP_MWMODE_X},
91 {"nopurge", XRDEXP_PURGE, 0, XRDEXP_PURGE_X},
92 {"purge", 0, XRDEXP_PURGE, XRDEXP_PURGE_X},
93 {"nostage", XRDEXP_STAGE, 0, XRDEXP_STAGE_X},
94 {"stage", 0, XRDEXP_STAGE, XRDEXP_STAGE_X},
95 {"stage+", 0, XRDEXP_STAGEMM, XRDEXP_STAGE_X},
96 {"dread", XRDEXP_NODREAD, 0, XRDEXP_DREAD_X},
97 {"nodread", 0, XRDEXP_NODREAD, XRDEXP_DREAD_X},
98 {"check", XRDEXP_NOCHECK, 0, XRDEXP_CHECK_X},
99 {"nocheck", 0, XRDEXP_NOCHECK, XRDEXP_CHECK_X},
100 {"rcreate", 0, XRDEXP_RCREATE, XRDEXP_RCREATE_X},
101 {"norcreate", XRDEXP_RCREATE, 0, XRDEXP_RCREATE_X},
103 {"global", XRDEXP_LOCAL, 0, XRDEXP_LOCAL_X},
105 {"lock", XRDEXP_NOLK, 0, XRDEXP_NOLK_X},
106 {"nolock", 0, XRDEXP_NOLK, XRDEXP_NOLK_X},
107 {"xattrs", XRDEXP_NOXATTR, 0, XRDEXP_NOXATTR_X},
108 {"noxattrs", 0, XRDEXP_NOXATTR, XRDEXP_NOXATTR_X}
109 };
110 int i, numopts = sizeof(rpopts)/sizeof(struct rpathopts);
111 char *val;
112
113// Process options
114//
115 val = Config.GetWord();
116 while (val)
117 {for (i = 0; i < numopts; i++)
118 {if (!strcmp(val, rpopts[i].opname))
119 {Flags = (Flags & ~rpopts[i].oprem)
120 | rpopts[i].opadd
121 | rpopts[i].opset;
122 break;
123 }
124 }
125 if (i >= numopts)
126 Eroute.Emsg("Export", "warning, invalid path option", val);
127 val = Config.GetWord();
128 }
129
130// All done
131//
132 return Flags;
133}
134
135/******************************************************************************/
136/* P a r s e P a t h */
137/******************************************************************************/
138
139/* Function: ParsePath
140
141 Purpose: To parse the directive args: <path> [<options>]
142
143 <path> the path prefix that applies
144 <options> a blank separated list of options:
145 [no]cache - is [not] file caching
146 [no]check - [don't] check if new file exists in MSS
147 [no]dread - [don't] read actual directory contents
148 forcero - force r/w opens to r/o opens
149 inplace - do not use extended cache for creation
150 outplace - use extended cache for creation
151 local - do not export via olbd
152 global - do export via olbd
153 globalro - do export via olbd as r/o path
154 [no]mig - this is [not] a migratable name space
155 [no]mkeep - this is [not] a memory keepable name space
156 [no]mlock - this is [not] a memory lockable name space
157 [no]mmap - this is [not] a memory mappable name space
158 [no]rcreate - [don't] create file in MSS as well
159 r/o - do not allow modifications (read/only)
160 r/w - path is writable/modifiable
161 [no]stage - [don't] stage in files.
162
163 Output: XrdOucPList object upon success or 0 upon failure.
164*/
165
167 XrdOucPListAnchor &Export,
168 unsigned long long Defopts)
169{
170 XrdOucPList *plp;
171 char *path, pbuff[1024];
172 unsigned long long rpval;
173
174// Get the path
175//
176 path = Config.GetWord();
177 if (!path || !path[0])
178 {Eroute.Emsg("Export", "path not specified"); return 0;}
179 strlcpy(pbuff, path, sizeof(pbuff));
180
181// Handle object ID specification
182//
183 if (*pbuff == '*') pbuff[1] = 0;
184
185// Process path options and apply defaults to any unspecified otions
186//
187 rpval = ParseDefs(Config, Eroute, 0);
188 rpval = rpval | (Defopts & (~(rpval >> XRDEXP_MASKSHIFT)))
189 | (Defopts & (~(rpval & ~XRDEXP_SETTINGS)));
190
191// Make sure that we have no conflicting options
192//
193 if ((rpval & XRDEXP_MEMAP) && !(rpval & XRDEXP_NOTRW))
194 {Eroute.Emsg("config", "warning, file memory mapping forced path", path,
195 "to be readonly");
196 rpval |= XRDEXP_FORCERO;
197 }
198
199// noxattr conflicts with mig or purge
200//
201 if ((rpval & XRDEXP_NOXATTR) && (rpval & XRDEXP_MIGPRG))
202 {Eroute.Emsg("config", "noxattrs attribute is incompatible with "
203 "mig and purge attributes.");
204 return 0;
205 }
206
207
208// Update the export list. If this path is being modified, turn off all bits
209// in the old path specified in the new path and then set the new bits.
210//
211 if ((plp = Export.Match(pbuff)))
212 {unsigned long long Opts = rpval >> XRDEXP_MASKSHIFT;
213 Opts = (plp->Flag() & ~Opts) | rpval;
214 plp->Set(Opts);
215 } else {
216 plp = new XrdOucPList(pbuff,rpval);
217 Export.Insert(plp);
218 }
219
220// Return the path specification
221//
222 return plp;
223}
#define XRDEXP_DREAD_X
#define XRDEXP_ROW_X
#define XRDEXP_NOTRW
#define XRDEXP_NOLK_X
#define XRDEXP_NODREAD
#define XRDEXP_INPLACE
#define XRDEXP_PURGE
#define XRDEXP_LOCAL_X
#define XRDEXP_MMAP
#define XRDEXP_MKEEP
#define XRDEXP_PFCACHE
#define XRDEXP_FORCERO
#define XRDEXP_MLOK
#define XRDEXP_STAGEMM
#define XRDEXP_MMAP_X
#define XRDEXP_RCREATE_X
#define XRDEXP_MWMODE
#define XRDEXP_MASKSHIFT
#define XRDEXP_CHECK_X
#define XRDEXP_GLBLRO
#define XRDEXP_PURGE_X
#define XRDEXP_NOCHECK
#define XRDEXP_NOXATTR_X
#define XRDEXP_MEMAP
#define XRDEXP_STAGE_X
#define XRDEXP_RCREATE
#define XRDEXP_SETTINGS
#define XRDEXP_MWMODE_X
#define XRDEXP_NOXATTR
#define XRDEXP_READONLY
#define XRDEXP_MIGPRG
#define XRDEXP_STAGE
#define XRDEXP_NOLK
#define XRDEXP_MLOK_X
#define XRDEXP_INPLACE_X
#define XRDEXP_MKEEP_X
#define XRDEXP_MIG
#define XRDEXP_GLBLRO_X
#define XRDEXP_PFCACHE_X
#define XRDEXP_LOCAL
#define XRDEXP_MIG_X
size_t strlcpy(char *dst, const char *src, size_t sz)
static unsigned long long ParseDefs(XrdOucStream &Config, XrdSysError &Eroute, unsigned long long Flags)
static XrdOucPList * ParsePath(XrdOucStream &Config, XrdSysError &Eroute, XrdOucPListAnchor &Export, unsigned long long Defopts)
XrdOucPList * Match(const char *pathname)
void Insert(XrdOucPList *newitem)
void Set(int aval)
unsigned long long Flag()
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)