xrootd
XrdFrmAdmin.hh
Go to the documentation of this file.
00001 #ifndef __FRMADMIN__HH
00002 #define __FRMADMIN__HH
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d F r m A d m i n . h h                         */
00006 /*                                                                            */
00007 /* (c) 2009 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /*                                                                            */
00012 /* This file is part of the XRootD software suite.                            */
00013 /*                                                                            */
00014 /* XRootD is free software: you can redistribute it and/or modify it under    */
00015 /* the terms of the GNU Lesser General Public License as published by the     */
00016 /* Free Software Foundation, either version 3 of the License, or (at your     */
00017 /* option) any later version.                                                 */
00018 /*                                                                            */
00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00022 /* License for more details.                                                  */
00023 /*                                                                            */
00024 /* You should have received a copy of the GNU Lesser General Public License   */
00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00027 /*                                                                            */
00028 /* The copyright holder's institutional names and contributor's names may not */
00029 /* be used to endorse or promote products derived from this software without  */
00030 /* specific prior written permission of the institution or contributor.       */
00031 /******************************************************************************/
00032   
00033 #include <stdlib.h>
00034 #include <sys/types.h>
00035 
00036 #include "XrdCks/XrdCksData.hh"
00037 #include "XrdOuc/XrdOucNSWalk.hh"
00038 
00039 class  XrdFrcProxy;
00040 class  XrdFrmFileset;
00041 class  XrdOucArgs;
00042 class  XrdOucTList;
00043 
00044 class XrdFrmAdmin
00045 {
00046 public:
00047 
00048 int  Audit();
00049 
00050 int  Chksum();
00051 
00052 int  Copy();
00053 
00054 int  Create();
00055 
00056 int  Find();
00057 
00058 int  Help();
00059 
00060 int  MakeLF();
00061 
00062 int  Mark();
00063 
00064 int  Mmap();
00065 
00066 int  Pin();
00067 
00068 int  Query();
00069 
00070 int  Quit() {exit(finalRC); return 0;}
00071 
00072 int  Reloc();
00073 
00074 int  Remove();
00075 
00076 int  Rename();
00077 
00078 void setArgs(int argc, char **argv);
00079 
00080 void setArgs(char *argv);
00081 
00082 int  xeqArgs(char *Cmd);
00083 
00084      XrdFrmAdmin() : frmProxy(0), frmProxz(0), finalRC(0) {}
00085     ~XrdFrmAdmin() {}
00086 
00087 private:
00088 int  AuditNameNB(XrdFrmFileset *sP);
00089 int  AuditNameNF(XrdFrmFileset *sP);
00090 int  AuditNameNL(XrdFrmFileset *sP);
00091 int  AuditNames();
00092 int  AuditNameXA(XrdFrmFileset *sP);
00093 int  AuditNameXB(XrdFrmFileset *sP);                // runOld
00094 int  AuditNameXL(XrdFrmFileset *sP, int dorm);      // runOld
00095 int  AuditRemove(XrdFrmFileset *sP);
00096 int  AuditSpace();
00097 int  AuditSpaceAX(const char *Path);
00098 int  AuditSpaceAXDB(const char *Path);
00099 int  AuditSpaceAXDC(const char *Path, XrdOucNSWalk::NSEnt *nP);
00100 int  AuditSpaceAXDL(int dorm, const char *Path, const char *Dest);
00101 int  AuditSpaceXA(const char *Space, const char *Path);
00102 int  AuditSpaceXA(XrdFrmFileset *sP);
00103 int  AuditSpaceXB(const char *Space, const char *Path); // runOld
00104 int  AuditSpaceXANB(XrdFrmFileset *sP);                 // runOld
00105 int  AuditUsage();
00106 int  AuditUsage(char *Space);
00107 int  AuditUsageAX(const char *Path);
00108 int  AuditUsageXA(const char *Path, const char *Space);
00109 int  isXA(XrdOucNSWalk::NSEnt *nP);
00110 
00111 int  ChksumList( const char *Lfn, const char *Pfn);
00112 void ChksumPrint(const char *Lfn, int rc);
00113 
00114 int  FindFail(XrdOucArgs &Spec);
00115 int  FindMmap(XrdOucArgs &Spec);
00116 int  FindNocs(XrdOucArgs &Spec);
00117 int  FindNolk(XrdOucArgs &Spec);
00118 int  FindPins(XrdOucArgs &Spec);
00119 int  FindPins(XrdFrmFileset *sP);
00120 int  FindUnmi(XrdOucArgs &Spec);
00121 
00122 int  Abbrev(const char *Spec, const char *Word, int minLen);
00123 
00124 void ConfigProxy();
00125 
00126 void Emsg(const char *tx1, const char *tx2=0, const char *tx3=0,
00127                            const char *tx4=0, const char *tx5=0);
00128 void Emsg(int Enum,        const char *tx2=0, const char *tx3=0,
00129                            const char *tx4=0, const char *tx5=0);
00130 void Msg(const char *tx1,  const char *tx2=0, const char *tx3=0,
00131                            const char *tx4=0, const char *tx5=0);
00132 
00133 int          Parse(const char *What, XrdOucArgs &Spec, const char **Reqs);
00134 int          ParseKeep(const char *What, const char *kTime);
00135 int          ParseOwner(const char *What, char *Uname);
00136 XrdOucTList *ParseSpace(char *Space, char **Path);
00137 int          ParseType(const char *What, char *Type);
00138 
00139 char ckAttr(int What, const char *Lfn, char *Pfn, int Pfnsz);
00140 int  mkLock(const char *Lfn);
00141 int  mkFile(int What, const char *Path, const char *Data=0, int Dlen=0);
00142 int  mkMark(const char *Lfn);
00143 int  mkMmap(const char *Lfn);
00144 int  mkPin(const char *Lfn);
00145 char mkStat(int What, const char *Lfn, char *Pfn, int Pfnsz);
00146 
00147 // For mkFile and mkStat the following options may be passed via What
00148 //
00149 static const int isPFN= 0x0001; // Filename is actual physical name
00150 static const int mkLF = 0x0002; // Make lock file or copy attribute
00151 static const int mkMF = 0x0004; // Make mmap file or mmap attribute
00152 static const int mkPF = 0x0008; // Make pin  file or pin  attribute
00153 
00154 int  QueryPfn(XrdOucArgs &Spec);
00155 int  QueryRfn(XrdOucArgs &Spec);
00156 int  QuerySpace(XrdOucArgs &Spec);
00157 int  QuerySpace(const char *Pfn, char *Lnk=0, int Lsz=0);
00158 int  QueryUsage(XrdOucArgs &Spec);
00159 int  QueryXfrQ(XrdOucArgs &Spec);
00160 
00161 int  Reloc(char *srcLfn, char *Space);
00162 int  RelocCP(const char *srcpfn, const char *trgpfn, off_t srcSz);
00163 int  RelocWR(const char *outFn,  int oFD, char *Buff, size_t BLen, off_t Boff);
00164 
00165 int  Unlink(const char *Path);
00166 int  UnlinkDir(const char *Path, const char *lclPath);
00167 int  UnlinkDir(XrdOucNSWalk::NSEnt *&nP, XrdOucNSWalk::NSEnt *&dP);
00168 int  UnlinkFile(const char *lclPath);
00169 
00170 int  VerifyAll(char *path);
00171 char VerifyMP(const char *func, const char *path);
00172 
00173 // The following are for runOld conversion purposes and will be removed
00174 //
00175 int          Convert();
00176 int          ConvTest(int doNames, int doSpaces);
00177 int          New2Old(int doNames, int doSpaces);
00178 int          Old2New(int doNames, int doSpaces);
00179 int          o2nFiles(XrdFrmFileset *sP, int &numOld);
00180 int          o2nSpace(XrdFrmFileset *sP, const char *Space);
00181 XrdOucTList *x2xPaths();
00182 int          x2xRemove(const char *Type, const char *Path, int cvt=0);
00183 XrdOucTList *x2xSpaces();
00184 
00185 static const char *AuditHelp;
00186 static const char *ChksumHelp;
00187 static const char *FindHelp;
00188 static const char *HelpHelp;
00189 static const char *MakeLFHelp;
00190 static const char *MarkHelp;
00191 static const char *MmapHelp;
00192 static const char *PinHelp;
00193 static const char *QueryHelp;
00194 static const char *RelocHelp;
00195 static const char *RemoveHelp;
00196 
00197 // Frm agent/proxy control
00198 //
00199 XrdFrcProxy *frmProxy;
00200 int          frmProxz;
00201 
00202 // Command control
00203 //
00204 char    **ArgV;
00205 char     *ArgS;
00206 int       ArgC;
00207 
00208 // The following are common variables for audit functions
00209 //
00210 long long numBytes;
00211 long long numBLost;
00212 int       numDirs;
00213 int       numFiles;
00214 int       numProb;
00215 int       numFix;
00216 int       finalRC;
00217 
00218 // Checksum control area
00219 //
00220 XrdCksData     CksData;
00221 
00222 // Options from the command
00223 //
00224 struct {char   All;
00225         char   Echo;
00226         char   Erase;
00227         char   Fix;
00228         char   Force;
00229         char   Keep;
00230         char   ktAlways;
00231         char   ktIdle;
00232         char   Local;
00233         char   MPType;
00234         char   Recurse;
00235         char   Verbose;
00236         char  *Args[2];
00237         uid_t  Uid;
00238         gid_t  Gid;
00239         time_t KeepTime;
00240        } Opt;
00241 };
00242 namespace XrdFrm
00243 {
00244 extern XrdFrmAdmin Admin;
00245 }
00246 #endif