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 <stdlib.h>
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 Pin();
67 
68 int Query();
69 
70 int Quit() {exit(finalRC); return 0;}
71 
72 int Reloc();
73 
74 int Remove();
75 
76 int Rename();
77 
78 void setArgs(int argc, char **argv);
79 
80 void setArgs(char *argv);
81 
82 int xeqArgs(char *Cmd);
83 
86 
87 private:
88 int AuditNameNB(XrdFrmFileset *sP);
89 int AuditNameNF(XrdFrmFileset *sP);
90 int AuditNameNL(XrdFrmFileset *sP);
91 int AuditNames();
92 int AuditNameXA(XrdFrmFileset *sP);
93 int AuditNameXB(XrdFrmFileset *sP); // runOld
94 int AuditNameXL(XrdFrmFileset *sP, int dorm); // runOld
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 AuditSpaceXB(const char *Space, const char *Path); // runOld
104 int AuditSpaceXANB(XrdFrmFileset *sP); // runOld
105 int AuditUsage();
106 int AuditUsage(char *Space);
107 int AuditUsageAX(const char *Path);
108 int AuditUsageXA(const char *Path, const char *Space);
109 int isXA(XrdOucNSWalk::NSEnt *nP);
110 
111 int ChksumList( const char *Lfn, const char *Pfn);
112 void ChksumPrint(const char *Lfn, int rc);
113 
114 int FindFail(XrdOucArgs &Spec);
115 int FindMmap(XrdOucArgs &Spec);
116 int FindNocs(XrdOucArgs &Spec);
117 int FindNolk(XrdOucArgs &Spec);
118 int FindPins(XrdOucArgs &Spec);
119 int FindPins(XrdFrmFileset *sP);
120 int FindUnmi(XrdOucArgs &Spec);
121 
122 int Abbrev(const char *Spec, const char *Word, int minLen);
123 
124 void ConfigProxy();
125 
126 void Emsg(const char *tx1, const char *tx2=0, const char *tx3=0,
127  const char *tx4=0, const char *tx5=0);
128 void Emsg(int Enum, const char *tx2=0, const char *tx3=0,
129  const char *tx4=0, const char *tx5=0);
130 void Msg(const char *tx1, const char *tx2=0, const char *tx3=0,
131  const char *tx4=0, const char *tx5=0);
132 
133 int Parse(const char *What, XrdOucArgs &Spec, const char **Reqs);
134 int ParseKeep(const char *What, const char *kTime);
135 int ParseOwner(const char *What, char *Uname);
136 XrdOucTList *ParseSpace(char *Space, char **Path);
137 int ParseType(const char *What, char *Type);
138 
139 char ckAttr(int What, const char *Lfn, char *Pfn, int Pfnsz);
140 int mkLock(const char *Lfn);
141 int mkFile(int What, const char *Path, const char *Data=0, int Dlen=0);
142 int mkMark(const char *Lfn);
143 int mkMmap(const char *Lfn);
144 int mkPin(const char *Lfn);
145 char mkStat(int What, const char *Lfn, char *Pfn, int Pfnsz);
146 
147 // For mkFile and mkStat the following options may be passed via What
148 //
149 static const int isPFN= 0x0001; // Filename is actual physical name
150 static const int mkLF = 0x0002; // Make lock file or copy attribute
151 static const int mkMF = 0x0004; // Make mmap file or mmap attribute
152 static const int mkPF = 0x0008; // Make pin file or pin attribute
153 
154 int QueryPfn(XrdOucArgs &Spec);
155 int QueryRfn(XrdOucArgs &Spec);
156 int QuerySpace(XrdOucArgs &Spec);
157 int QuerySpace(const char *Pfn, char *Lnk=0, int Lsz=0);
158 int QueryUsage(XrdOucArgs &Spec);
159 int QueryXfrQ(XrdOucArgs &Spec);
160 
161 int Reloc(char *srcLfn, char *Space);
162 int RelocCP(const char *srcpfn, const char *trgpfn, off_t srcSz);
163 int RelocWR(const char *outFn, int oFD, char *Buff, size_t BLen, off_t Boff);
164 
165 int Unlink(const char *Path);
166 int UnlinkDir(const char *Path, const char *lclPath);
168 int UnlinkFile(const char *lclPath);
169 
170 int VerifyAll(char *path);
171 char VerifyMP(const char *func, const char *path);
172 
173 // The following are for runOld conversion purposes and will be removed
174 //
175 int Convert();
176 int ConvTest(int doNames, int doSpaces);
177 int New2Old(int doNames, int doSpaces);
178 int Old2New(int doNames, int doSpaces);
179 int o2nFiles(XrdFrmFileset *sP, int &numOld);
180 int o2nSpace(XrdFrmFileset *sP, const char *Space);
182 int x2xRemove(const char *Type, const char *Path, int cvt=0);
184 
185 static const char *AuditHelp;
186 static const char *ChksumHelp;
187 static const char *FindHelp;
188 static const char *HelpHelp;
189 static const char *MakeLFHelp;
190 static const char *MarkHelp;
191 static const char *MmapHelp;
192 static const char *PinHelp;
193 static const char *QueryHelp;
194 static const char *RelocHelp;
195 static const char *RemoveHelp;
196 
197 // Frm agent/proxy control
198 //
201 
202 // Command control
203 //
204 char **ArgV;
205 char *ArgS;
206 int ArgC;
207 
208 // The following are common variables for audit functions
209 //
210 long long numBytes;
211 long long numBLost;
215 int numFix;
217 
218 // Checksum control area
219 //
221 
222 // Options from the command
223 //
224 struct {char All;
225  char Echo;
226  char Erase;
227  char Fix;
228  char Force;
229  char Keep;
230  char ktAlways;
231  char ktIdle;
232  char Local;
233  char MPType;
234  char Recurse;
235  char Verbose;
236  char *Args[2];
237  uid_t Uid;
238  gid_t Gid;
239  time_t KeepTime;
240  } Opt;
241 };
242 namespace XrdFrm
243 {
244 extern XrdFrmAdmin Admin;
245 }
246 #endif