XRootD
XrdFrmAdmin.hh
Go to the documentation of this file.
1 #ifndef __FRMADMIN__HH
2 #define __FRMADMIN__HH
3 /******************************************************************************/
4 /* */
5 /* X r d F r m A d m i n . h h */
6 /* */
7 /* (c) 2009 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <cstdlib>
34 #include <sys/types.h>
35 
36 #include "XrdCks/XrdCksData.hh"
37 #include "XrdOuc/XrdOucNSWalk.hh"
38 
39 class XrdFrcProxy;
40 class XrdFrmFileset;
41 class XrdOucArgs;
42 class XrdOucTList;
43 
45 {
46 public:
47 
48 int Audit();
49 
50 int Chksum();
51 
52 int Copy();
53 
54 int Create();
55 
56 int Find();
57 
58 int Help();
59 
60 int MakeLF();
61 
62 int Mark();
63 
64 int Mmap();
65 
66 int Mv();
67 
68 int Pin();
69 
70 int Query();
71 
72 int Quit() {exit(finalRC); return 0;}
73 
74 int Reloc();
75 
76 int Remove();
77 
78 int Rename();
79 
80 void setArgs(int argc, char **argv);
81 
82 void setArgs(char *argv);
83 
84 int xeqArgs(char *Cmd);
85 
86  XrdFrmAdmin() : frmProxy(0), frmProxz(0), finalRC(0) {}
88 
89 private:
90 int AuditNameNB(XrdFrmFileset *sP);
91 int AuditNameNF(XrdFrmFileset *sP);
92 int AuditNameNL(XrdFrmFileset *sP);
93 int AuditNames();
94 int AuditNameXA(XrdFrmFileset *sP);
95 int AuditRemove(XrdFrmFileset *sP);
96 int AuditSpace();
97 int AuditSpaceAX(const char *Path);
98 int AuditSpaceAXDB(const char *Path);
99 int AuditSpaceAXDC(const char *Path, XrdOucNSWalk::NSEnt *nP);
100 int AuditSpaceAXDL(int dorm, const char *Path, const char *Dest);
101 int AuditSpaceXA(const char *Space, const char *Path);
102 int AuditSpaceXA(XrdFrmFileset *sP);
103 int AuditUsage();
104 int AuditUsage(char *Space);
105 int AuditUsageAX(const char *Path);
106 int AuditUsageXA(const char *Path, const char *Space);
107 int isXA(XrdOucNSWalk::NSEnt *nP);
108 
109 int ChksumList( const char *Lfn, const char *Pfn);
110 void ChksumPrint(const char *Lfn, int rc);
111 
112 int FindFail(XrdOucArgs &Spec);
113 int FindMmap(XrdOucArgs &Spec);
114 int FindNocs(XrdOucArgs &Spec);
115 int FindPins(XrdOucArgs &Spec);
116 int FindPins(XrdFrmFileset *sP);
117 int FindUnmi(XrdOucArgs &Spec);
118 
119 int Abbrev(const char *Spec, const char *Word, int minLen);
120 
121 void ConfigProxy();
122 
123 void Emsg(const char *tx1, const char *tx2=0, const char *tx3=0,
124  const char *tx4=0, const char *tx5=0);
125 void Emsg(int Enum, const char *tx2=0, const char *tx3=0,
126  const char *tx4=0, const char *tx5=0);
127 void Msg(const char *tx1, const char *tx2=0, const char *tx3=0,
128  const char *tx4=0, const char *tx5=0);
129 
130 int Parse(const char *What, XrdOucArgs &Spec, const char **Reqs);
131 int ParseKeep(const char *What, const char *kTime);
132 int ParseOwner(const char *What, char *Uname);
133 XrdOucTList *ParseSpace(char *Space, char **Path);
134 int ParseType(const char *What, char *Type);
135 
136 char ckAttr(int What, const char *Lfn, char *Pfn, int Pfnsz);
137 int mkLock(const char *Lfn);
138 int mkFile(int What, const char *Path, const char *Data=0, int Dlen=0);
139 int mkMark(const char *Lfn);
140 int mkMmap(const char *Lfn);
141 int mkPin(const char *Lfn);
142 char mkStat(int What, const char *Lfn, char *Pfn, int Pfnsz);
143 
144 // For mkFile and mkStat the following options may be passed via What
145 //
146 static const int isPFN= 0x0001; // Filename is actual physical name
147 static const int mkLF = 0x0002; // Make lock file or copy attribute
148 static const int mkMF = 0x0004; // Make mmap file or mmap attribute
149 static const int mkPF = 0x0008; // Make pin file or pin attribute
150 
151 int QueryPfn(XrdOucArgs &Spec);
152 int QueryRfn(XrdOucArgs &Spec);
153 int QuerySpace(XrdOucArgs &Spec);
154 int QuerySpace(const char *Pfn, char *Lnk=0, int Lsz=0);
155 int QueryUsage(XrdOucArgs &Spec);
156 int QueryXfrQ(XrdOucArgs &Spec);
157 
158 int Reloc(char *srcLfn, char *Space);
159 int RelocCP(const char *srcpfn, const char *trgpfn, off_t srcSz);
160 int RelocWR(const char *outFn, int oFD, char *Buff, size_t BLen, off_t Boff);
161 
162 int Unlink(const char *Path);
163 int UnlinkDir(const char *Path, const char *lclPath);
164 int UnlinkDir(XrdOucNSWalk::NSEnt *&nP, XrdOucNSWalk::NSEnt *&dP);
165 int UnlinkFile(const char *lclPath);
166 
167 int VerifyAll(char *path);
168 char VerifyMP(const char *func, const char *path);
169 
170 static const char *AuditHelp;
171 static const char *ChksumHelp;
172 static const char *FindHelp;
173 static const char *HelpHelp;
174 static const char *MakeLFHelp; // runOld
175 static const char *MarkHelp;
176 static const char *MmapHelp;
177 static const char *MvHelp;
178 static const char *PinHelp;
179 static const char *QueryHelp;
180 static const char *RelocHelp;
181 static const char *RemoveHelp;
182 
183 // Frm agent/proxy control
184 //
185 XrdFrcProxy *frmProxy;
186 int frmProxz;
187 
188 // Command control
189 //
190 char **ArgV;
191 char *ArgS;
192 int ArgC;
193 
194 // The following are common variables for audit functions
195 //
196 long long numBytes;
197 long long numBLost;
198 int numDirs;
199 int numFiles;
200 int numProb;
201 int numFix;
202 int finalRC;
203 
204 // Checksum control area
205 //
206 XrdCksData CksData;
207 
208 // Options from the command
209 //
210 struct {char All;
211  char Echo;
212  char Erase;
213  char Fix;
214  char Force;
215  char Keep;
216  char ktAlways;
217  char ktIdle;
218  char Local;
219  char MPType;
220  char Recurse;
221  char Verbose;
222  char *Args[2];
223  uid_t Uid;
224  gid_t Gid;
225  time_t KeepTime;
226  } Opt;
227 };
228 namespace XrdFrm
229 {
230 extern XrdFrmAdmin Admin;
231 }
232 #endif
XrdOucString Path
bool Force
void setArgs(int argc, char **argv)
Definition: XrdFrmAdmin.cc:690
int xeqArgs(char *Cmd)
Definition: XrdFrmAdmin.cc:705
XrdFrmAdmin Admin