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 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 
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);
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 //
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;
201 int numFix;
203 
204 // Checksum control area
205 //
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
char ktAlways
Definition: XrdFrmAdmin.hh:216
char Fix
Definition: XrdFrmAdmin.hh:213
static const char * MmapHelp
Definition: XrdFrmAdmin.hh:176
int mkMark(const char *Lfn)
int AuditSpaceAXDL(int dorm, const char *Path, const char *Dest)
uid_t Uid
Definition: XrdFrmAdmin.hh:223
int AuditRemove(XrdFrmFileset *sP)
static const int isPFN
Definition: XrdFrmAdmin.hh:146
int AuditSpaceAX(const char *Path)
char Erase
Definition: XrdFrmAdmin.hh:212
int ParseKeep(const char *What, const char *kTime)
int UnlinkDir(const char *Path, const char *lclPath)
static const char * RemoveHelp
Definition: XrdFrmAdmin.hh:181
int AuditNames()
XrdCksData CksData
Definition: XrdFrmAdmin.hh:206
void ChksumPrint(const char *Lfn, int rc)
int numFiles
Definition: XrdFrmAdmin.hh:199
int xeqArgs(char *Cmd)
char ckAttr(int What, const char *Lfn, char *Pfn, int Pfnsz)
static const char * RelocHelp
Definition: XrdFrmAdmin.hh:180
int AuditNameXA(XrdFrmFileset *sP)
static const char * PinHelp
Definition: XrdFrmAdmin.hh:178
int Quit()
Definition: XrdFrmAdmin.hh:72
int RelocWR(const char *outFn, int oFD, char *Buff, size_t BLen, off_t Boff)
int QueryXfrQ(XrdOucArgs &Spec)
int QueryRfn(XrdOucArgs &Spec)
Definition: XrdCksData.hh:37
void setArgs(int argc, char **argv)
int RelocCP(const char *srcpfn, const char *trgpfn, off_t srcSz)
struct XrdFrmAdmin::@88 Opt
XrdFrcProxy * frmProxy
Definition: XrdFrmAdmin.hh:185
char Recurse
Definition: XrdFrmAdmin.hh:220
int mkFile(int What, const char *Path, const char *Data=0, int Dlen=0)
int AuditUsageAX(const char *Path)
int AuditUsage()
static const char * ChksumHelp
Definition: XrdFrmAdmin.hh:171
int Abbrev(const char *Spec, const char *Word, int minLen)
static const int mkLF
Definition: XrdFrmAdmin.hh:147
int FindPins(XrdOucArgs &Spec)
long long numBytes
Definition: XrdFrmAdmin.hh:196
time_t KeepTime
Definition: XrdFrmAdmin.hh:225
int AuditSpaceXA(const char *Space, const char *Path)
int UnlinkFile(const char *lclPath)
static const char * FindHelp
Definition: XrdFrmAdmin.hh:172
XrdFrmAdmin()
Definition: XrdFrmAdmin.hh:86
int ParseOwner(const char *What, char *Uname)
int Parse(const char *What, XrdOucArgs &Spec, const char **Reqs)
int FindMmap(XrdOucArgs &Spec)
static const char * AuditHelp
Definition: XrdFrmAdmin.hh:170
char MPType
Definition: XrdFrmAdmin.hh:219
int numFix
Definition: XrdFrmAdmin.hh:201
char All
Definition: XrdFrmAdmin.hh:210
static const char * MarkHelp
Definition: XrdFrmAdmin.hh:175
int ChksumList(const char *Lfn, const char *Pfn)
void ConfigProxy()
int QueryUsage(XrdOucArgs &Spec)
int numProb
Definition: XrdFrmAdmin.hh:200
Definition: XrdFrmAdmin.hh:228
XrdOucTList * ParseSpace(char *Space, char **Path)
int Unlink(const char *Path)
Definition: XrdOucTList.hh:41
void Emsg(const char *tx1, const char *tx2=0, const char *tx3=0, const char *tx4=0, const char *tx5=0)
static const char * QueryHelp
Definition: XrdFrmAdmin.hh:179
char VerifyMP(const char *func, const char *path)
char ktIdle
Definition: XrdFrmAdmin.hh:217
int mkMmap(const char *Lfn)
char * ArgS
Definition: XrdFrmAdmin.hh:191
char Keep
Definition: XrdFrmAdmin.hh:215
XrdFrmAdmin Admin
int FindUnmi(XrdOucArgs &Spec)
static const char * HelpHelp
Definition: XrdFrmAdmin.hh:173
char Echo
Definition: XrdFrmAdmin.hh:211
char Verbose
Definition: XrdFrmAdmin.hh:221
int ArgC
Definition: XrdFrmAdmin.hh:192
int ParseType(const char *What, char *Type)
Definition: XrdOucArgs.hh:41
int QuerySpace(XrdOucArgs &Spec)
int AuditSpaceAXDC(const char *Path, XrdOucNSWalk::NSEnt *nP)
int VerifyAll(char *path)
int AuditNameNL(XrdFrmFileset *sP)
int AuditUsageXA(const char *Path, const char *Space)
int AuditNameNB(XrdFrmFileset *sP)
int AuditNameNF(XrdFrmFileset *sP)
int AuditSpace()
gid_t Gid
Definition: XrdFrmAdmin.hh:224
static const int mkMF
Definition: XrdFrmAdmin.hh:148
char mkStat(int What, const char *Lfn, char *Pfn, int Pfnsz)
int finalRC
Definition: XrdFrmAdmin.hh:202
int isXA(XrdOucNSWalk::NSEnt *nP)
int FindNocs(XrdOucArgs &Spec)
int QueryPfn(XrdOucArgs &Spec)
char ** ArgV
Definition: XrdFrmAdmin.hh:190
int AuditSpaceAXDB(const char *Path)
int mkLock(const char *Lfn)
int mkPin(const char *Lfn)
int numDirs
Definition: XrdFrmAdmin.hh:198
static const int mkPF
Definition: XrdFrmAdmin.hh:149
Definition: XrdFrcProxy.hh:39
static const char * MvHelp
Definition: XrdFrmAdmin.hh:177
int FindFail(XrdOucArgs &Spec)
static const char * MakeLFHelp
Definition: XrdFrmAdmin.hh:174
Definition: XrdOucNSWalk.hh:46
char Local
Definition: XrdFrmAdmin.hh:218
Definition: XrdFrmAdmin.hh:44
char Force
Definition: XrdFrmAdmin.hh:214
int frmProxz
Definition: XrdFrmAdmin.hh:186
char * Args[2]
Definition: XrdFrmAdmin.hh:222
Definition: XrdFrmFiles.hh:48
void Msg(const char *tx1, const char *tx2=0, const char *tx3=0, const char *tx4=0, const char *tx5=0)
~XrdFrmAdmin()
Definition: XrdFrmAdmin.hh:87
long long numBLost
Definition: XrdFrmAdmin.hh:197