XrdOucExport.cc

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /*                       X r d O u c E x p o r t . c c                        */
00004 /*                                                                            */
00005 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University  */
00006 /*                            All Rights Reserved                             */
00007 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00008 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00009 /******************************************************************************/
00010 
00011 //          $Id: XrdOucExport.cc 34000 2010-06-21 06:49:56Z ganis $
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 /*                             P a r s e D e f s                              */
00020 /******************************************************************************/
00021   
00022 /* Function: ParseDefs
00023 
00024    Purpose:  Parse: defaults [[no]check] [[no]compchk] [[no]dread]
00025 
00026                              [[no]filter] [forcero]
00027 
00028                              [inplace] [local] [global] [globalro]
00029                               
00030                              [[no]mig] [[not]migratable] [[no]mkeep]
00031 
00032                              [[no]mlock] [[no]mmap] [outplace] [readonly]
00033 
00034                              [[no]ssdec] [[no]stage]  [[no]rcreate] 
00035 
00036                              [[not]writable]
00037 
00038    Notes: See the oss configuration manual for the meaning of each option.
00039 
00040    Output: Returns updated flags passed as input
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 // Process options
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 // All done
00113 //
00114    return Flags;
00115 }
00116 
00117 /******************************************************************************/
00118 /*                             P a r s e P a t h                              */
00119 /******************************************************************************/
00120 
00121 /* Function: ParsePath
00122 
00123    Purpose:  To parse the directive args: <path> [<options>]
00124 
00125              <path>    the path prefix that applies
00126              <options> a blank separated list of options:
00127                        [no]check    - [don't] check if new file exists in MSS
00128                        [no]compchk  - [don't] check for compressed files
00129                        [no]dread    - [don't] read actual directory contents
00130                            forcero  - force r/w opens to r/o opens
00131                            inplace  - do not use extended cache for creation
00132                           outplace  -        use extended cache for creation
00133                            local    - do not export via olbd
00134                            global   - do     export via olbd
00135                            globalro - do     export via olbd as r/o path
00136                        [no]mig      - this is [not] a migratable name space
00137                        [no]mkeep    - this is [not] a memory keepable name space
00138                        [no]mlock    - this is [not] a memory lockable name space
00139                        [no]mmap     - this is [not] a memory mappable name space
00140                        [no]rcreate  - [don't] create file in MSS as well
00141                            r/o      - do not allow modifications (read/only)
00142                            r/w      - path is writable/modifiable
00143                        [no]ssdec    - [don't] perform server side decompression
00144                        [no]stage    - [don't] stage in files.
00145 
00146    Output: XrdOucPList object upon success or 0 upon failure.
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 // Get the path
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 // Process path options
00163 //
00164    rpval = ParseDefs(Config, Eroute, 0);
00165 
00166 // Make sure that we have no conflicting options
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 // Return the path specification
00176 //
00177    return new XrdOucPList(pbuff, rpval);
00178 }

Generated on Tue Jul 5 14:46:48 2011 for ROOT_528-00b_version by  doxygen 1.5.1