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 
13 #include <stdlib.h>
14 #include <sys/types.h>
15 
16 #include "XrdCks/XrdCksData.hh"
17 #include "XrdOuc/XrdOucNSWalk.hh"
18 
19 class XrdFrcProxy;
20 class XrdFrmFileset;
21 class XrdOucArgs;
22 class XrdOucTList;
23 
25 {
26 public:
27 
28 int Audit();
29 
30 int Chksum();
31 
32 int Copy();
33 
34 int Create();
35 
36 int Find();
37 
38 int Help();
39 
40 int MakeLF();
41 
42 int Mark();
43 
44 int Mmap();
45 
46 int Pin();
47 
48 int Query();
49 
50 int Quit() {exit(finalRC); return 0;}
51 
52 int Reloc();
53 
54 int Remove();
55 
56 int Rename();
57 
58 void setArgs(int argc, char **argv);
59 
60 void setArgs(char *argv);
61 
62 int xeqArgs(char *Cmd);
63 
66 
67 private:
68 int AuditNameNB(XrdFrmFileset *sP);
69 int AuditNameNF(XrdFrmFileset *sP);
70 int AuditNameNL(XrdFrmFileset *sP);
71 int AuditNames();
72 int AuditNameXA(XrdFrmFileset *sP);
73 int AuditNameXB(XrdFrmFileset *sP); // runOld
74 int AuditNameXL(XrdFrmFileset *sP, int dorm); // runOld
75 int AuditRemove(XrdFrmFileset *sP);
76 int AuditSpace();
77 int AuditSpaceAX(const char *Path);
78 int AuditSpaceAXDB(const char *Path);
79 int AuditSpaceAXDC(const char *Path, XrdOucNSWalk::NSEnt *nP);
80 int AuditSpaceAXDL(int dorm, const char *Path, const char *Dest);
81 int AuditSpaceXA(const char *Space, const char *Path);
83 int AuditSpaceXB(const char *Space, const char *Path); // runOld
84 int AuditSpaceXANB(XrdFrmFileset *sP); // runOld
85 int AuditUsage();
86 int AuditUsage(char *Space);
87 int AuditUsageAX(const char *Path);
88 int AuditUsageXA(const char *Path, const char *Space);
89 int isXA(XrdOucNSWalk::NSEnt *nP);
90 
91 int ChksumList( const char *Lfn, const char *Pfn);
92 void ChksumPrint(const char *Lfn, int rc);
93 
94 int FindFail(XrdOucArgs &Spec);
95 int FindMmap(XrdOucArgs &Spec);
96 int FindNocs(XrdOucArgs &Spec);
97 int FindNolk(XrdOucArgs &Spec);
98 int FindPins(XrdOucArgs &Spec);
99 int FindPins(XrdFrmFileset *sP);
100 int FindUnmi(XrdOucArgs &Spec);
101 
102 int Abbrev(const char *Spec, const char *Word, int minLen);
103 
104 void ConfigProxy();
105 
106 void Emsg(const char *tx1, const char *tx2=0, const char *tx3=0,
107  const char *tx4=0, const char *tx5=0);
108 void Emsg(int Enum, const char *tx2=0, const char *tx3=0,
109  const char *tx4=0, const char *tx5=0);
110 void Msg(const char *tx1, const char *tx2=0, const char *tx3=0,
111  const char *tx4=0, const char *tx5=0);
112 
113 int Parse(const char *What, XrdOucArgs &Spec, const char **Reqs);
114 int ParseKeep(const char *What, const char *kTime);
115 int ParseOwner(const char *What, char *Uname);
116 XrdOucTList *ParseSpace(char *Space, char **Path);
117 int ParseType(const char *What, char *Type);
118 
119 char ckAttr(int What, const char *Lfn, char *Pfn, int Pfnsz);
120 int mkLock(const char *Lfn);
121 int mkFile(int What, const char *Path, const char *Data=0, int Dlen=0);
122 int mkMark(const char *Lfn);
123 int mkMmap(const char *Lfn);
124 int mkPin(const char *Lfn);
125 char mkStat(int What, const char *Lfn, char *Pfn, int Pfnsz);
126 
127 // For mkFile and mkStat the following options may be passed via What
128 //
129 static const int isPFN= 0x0001; // Filename is actual physical name
130 static const int mkLF = 0x0002; // Make lock file or copy attribute
131 static const int mkMF = 0x0004; // Make mmap file or mmap attribute
132 static const int mkPF = 0x0008; // Make pin file or pin attribute
133 
134 int QueryPfn(XrdOucArgs &Spec);
135 int QueryRfn(XrdOucArgs &Spec);
136 int QuerySpace(XrdOucArgs &Spec);
137 int QuerySpace(const char *Pfn, char *Lnk=0, int Lsz=0);
138 int QueryUsage(XrdOucArgs &Spec);
139 int QueryXfrQ(XrdOucArgs &Spec);
140 
141 int Reloc(char *srcLfn, char *Space);
142 int RelocCP(const char *srcpfn, const char *trgpfn, off_t srcSz);
143 int RelocWR(const char *outFn, int oFD, char *Buff, size_t BLen, off_t Boff);
144 
145 int Unlink(const char *Path);
146 int UnlinkDir(const char *Path, const char *lclPath);
148 int UnlinkFile(const char *lclPath);
149 
150 int VerifyAll(char *path);
151 char VerifyMP(const char *func, const char *path);
152 
153 // The following are for runOld conversion purposes and will be removed
154 //
155 int Convert();
156 int ConvTest(int doNames, int doSpaces);
157 int New2Old(int doNames, int doSpaces);
158 int Old2New(int doNames, int doSpaces);
159 int o2nFiles(XrdFrmFileset *sP, int &numOld);
160 int o2nSpace(XrdFrmFileset *sP, const char *Space);
162 int x2xRemove(const char *Type, const char *Path, int cvt=0);
164 
165 static const char *AuditHelp;
166 static const char *ChksumHelp;
167 static const char *FindHelp;
168 static const char *HelpHelp;
169 static const char *MakeLFHelp;
170 static const char *MarkHelp;
171 static const char *MmapHelp;
172 static const char *PinHelp;
173 static const char *QueryHelp;
174 static const char *RelocHelp;
175 static const char *RemoveHelp;
176 
177 // Frm agent/proxy control
178 //
181 
182 // Command control
183 //
184 char **ArgV;
185 char *ArgS;
186 int ArgC;
187 
188 // The following are common variables for audit functions
189 //
190 long long numBytes;
191 long long numBLost;
195 int numFix;
197 
198 // Checksum control area
199 //
201 
202 // Options from the command
203 //
204 struct {char All;
205  char Echo;
206  char Erase;
207  char Fix;
208  char Force;
209  char Keep;
210  char ktAlways;
211  char ktIdle;
212  char Local;
213  char MPType;
214  char Recurse;
215  char Verbose;
216  char *Args[2];
217  uid_t Uid;
218  gid_t Gid;
219  time_t KeepTime;
220  } Opt;
221 };
222 namespace XrdFrm
223 {
224 extern XrdFrmAdmin Admin;
225 }
226 #endif