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