00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 const char *XrdOucExportCVSID = "$Id: XrdOucExport.cc 34000 2010-06-21 06:49:56Z ganis $";
00014
00015 #include "XrdOuc/XrdOucExport.hh"
00016 #include "XrdSys/XrdSysPlatform.hh"
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 unsigned long long XrdOucExport::ParseDefs(XrdOucStream &Config,
00044 XrdSysError &Eroute,
00045 unsigned long long Flags)
00046 {
00047 static struct rpathopts
00048 {const char *opname;
00049 unsigned long long oprem;
00050 unsigned long long opadd;
00051 unsigned long long opset;} rpopts[] =
00052 {
00053 {"compchk", 0, XRDEXP_COMPCHK, 0},
00054 {"r/o", 0, XRDEXP_READONLY,XRDEXP_ROW_X},
00055 {"readonly", 0, XRDEXP_READONLY,XRDEXP_ROW_X},
00056 {"forcero", 0, XRDEXP_FORCERO, XRDEXP_ROW_X},
00057 {"notwritable", 0, XRDEXP_READONLY,XRDEXP_ROW_X},
00058 {"writable", XRDEXP_NOTRW, 0, XRDEXP_ROW_X},
00059 {"r/w", XRDEXP_NOTRW, 0, XRDEXP_ROW_X},
00060 {"inplace", 0, XRDEXP_INPLACE, XRDEXP_INPLACE_X},
00061 {"outplace", XRDEXP_INPLACE, 0, XRDEXP_INPLACE_X},
00062 {"nofilter", XRDEXP_FILTER, 0, XRDEXP_MKEEP_X},
00063 {"filter", 0, XRDEXP_FILTER, XRDEXP_FILTER_X},
00064 {"nomig", XRDEXP_MIG, 0, XRDEXP_MIG_X},
00065 {"mig", 0, XRDEXP_MIG, XRDEXP_MIG_X},
00066 {"notmigratable", XRDEXP_MIG, 0, XRDEXP_MIG_X},
00067 {"migratable", 0, XRDEXP_MIG, XRDEXP_MIG_X},
00068 {"nomkeep", XRDEXP_MKEEP, 0, XRDEXP_MKEEP_X},
00069 {"mkeep", 0, XRDEXP_MKEEP, XRDEXP_MKEEP_X},
00070 {"nomlock", XRDEXP_MLOK, 0, XRDEXP_MLOK_X},
00071 {"mlock", 0, XRDEXP_MLOK, XRDEXP_MLOK_X},
00072 {"nommap", XRDEXP_MMAP, 0, XRDEXP_MMAP_X},
00073 {"mmap", 0, XRDEXP_MMAP, XRDEXP_MMAP_X},
00074 {"nopurge", XRDEXP_PURGE, 0, XRDEXP_PURGE_X},
00075 {"purge", 0, XRDEXP_PURGE, XRDEXP_PURGE_X},
00076 {"nostage", XRDEXP_STAGE, 0, XRDEXP_STAGE_X},
00077 {"stage", 0, XRDEXP_STAGE, XRDEXP_STAGE_X},
00078 {"dread", XRDEXP_NODREAD, 0, XRDEXP_DREAD_X},
00079 {"nodread", 0, XRDEXP_NODREAD, XRDEXP_DREAD_X},
00080 {"check", XRDEXP_NOCHECK, 0, XRDEXP_CHECK_X},
00081 {"nocheck", 0, XRDEXP_NOCHECK, XRDEXP_CHECK_X},
00082 {"rcreate", 0, XRDEXP_RCREATE, XRDEXP_RCREATE_X},
00083 {"norcreate", XRDEXP_RCREATE, 0, XRDEXP_RCREATE_X},
00084 {"nossdec", 0, XRDEXP_NOSSDEC, XRDEXP_NOSSDEC_X},
00085 {"ssdec", XRDEXP_NOSSDEC, 0, XRDEXP_NOSSDEC_X},
00086 {"local", XRDEXP_GLBLRO, XRDEXP_LOCAL, XRDEXP_LOCAL_X},
00087 {"global", XRDEXP_LOCAL, 0, XRDEXP_LOCAL_X},
00088 {"globalro", XRDEXP_LOCAL, XRDEXP_GLBLRO, XRDEXP_GLBLRO_X},
00089 {"lock", XRDEXP_NOLK, 0, XRDEXP_NOLK_X},
00090 {"nolock", 0, XRDEXP_NOLK, XRDEXP_NOLK_X}
00091 };
00092 int i, numopts = sizeof(rpopts)/sizeof(struct rpathopts);
00093 char *val;
00094
00095
00096
00097 val = Config.GetWord();
00098 while (val)
00099 {for (i = 0; i < numopts; i++)
00100 {if (!strcmp(val, rpopts[i].opname))
00101 {Flags = (Flags & ~rpopts[i].oprem)
00102 | rpopts[i].opadd
00103 | rpopts[i].opset;
00104 break;
00105 }
00106 }
00107 if (i >= numopts)
00108 Eroute.Emsg("Export", "warning, invalid path option", val);
00109 val = Config.GetWord();
00110 }
00111
00112
00113
00114 return Flags;
00115 }
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 XrdOucPList *XrdOucExport::ParsePath(XrdOucStream &Config, XrdSysError &Eroute,
00150 unsigned long long Defopts)
00151 {
00152 char *path, pbuff[1024];
00153 unsigned long long rpval;
00154
00155
00156
00157 path = Config.GetWord();
00158 if (!path || !path[0])
00159 {Eroute.Emsg("Export", "path not specified"); return 0;}
00160 strlcpy(pbuff, path, sizeof(pbuff));
00161
00162
00163
00164 rpval = ParseDefs(Config, Eroute, 0);
00165
00166
00167
00168 if ((rpval & XRDEXP_MEMAP) && !(rpval & XRDEXP_NOTRW))
00169 {Eroute.Emsg("config", "warning, file memory mapping forced path", path,
00170 "to be readonly");
00171 rpval |= XRDEXP_FORCERO;
00172 }
00173 if (rpval & (XRDEXP_MLOK | XRDEXP_MKEEP)) rpval |= XRDEXP_MMAP;
00174
00175
00176
00177 return new XrdOucPList(pbuff, rpval);
00178 }