XrdFrmAdminFind.cc

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /*                       X r d A d m i n F i n d . c c                        */
00004 /*                                                                            */
00005 /* (c) 2009 by the Board of Trustees of the Leland Stanford, Jr., University  */
00006 /*                            All Rights Reserved                             */
00007 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00008 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00009 /******************************************************************************/
00010 
00011 //          $Id: XrdFrmAdminFind.cc 34000 2010-06-21 06:49:56Z ganis $
00012 
00013 #include <stdio.h>
00014 #include <string.h>
00015 #include <strings.h>
00016 #include <sys/param.h>
00017 
00018 #include "XrdFrm/XrdFrmAdmin.hh"
00019 #include "XrdFrm/XrdFrmConfig.hh"
00020 #include "XrdFrm/XrdFrmFiles.hh"
00021 #include "XrdFrm/XrdFrmTrace.hh"
00022 #include "XrdOuc/XrdOucArgs.hh"
00023 #include "XrdOuc/XrdOucNSWalk.hh"
00024 
00025 const char *XrdFrmAdminFindCVSID = "$Id: XrdFrmAdminFind.cc 34000 2010-06-21 06:49:56Z ganis $";
00026 
00027 using namespace XrdFrm;
00028 
00029 /******************************************************************************/
00030 /*                              F i n d F a i l                               */
00031 /******************************************************************************/
00032   
00033 int XrdFrmAdmin::FindFail(XrdOucArgs &Spec)
00034 {
00035    XrdOucNSWalk::NSEnt *nP, *fP;
00036    XrdOucNSWalk *nsP;
00037    char pDir[MAXPATHLEN], *dotP, *dirFN, *lDir = Opt.Args[1];
00038    int opts = XrdOucNSWalk::retFile | (Opt.Recurse ? XrdOucNSWalk::Recurse : 0);
00039    int ec, rc = 0, num = 0;
00040 
00041 // Process each directory
00042 //
00043    do {if (!Config.LocalPath(lDir, pDir, sizeof(pDir))) continue;
00044        nsP = new XrdOucNSWalk(&Say, pDir, Config.lockFN, opts);
00045        while((nP = nsP->Index(ec)) || ec)
00046             {while((fP = nP))
00047                   {if ((dotP = rindex(fP->File,'.')) && !strcmp(dotP,".fail"))
00048                       {Msg(fP->Path); num++;}
00049                    nP = fP->Next; delete fP;
00050                   }
00051             if (ec) rc = 4;
00052             }
00053         delete nsP;
00054        } while((dirFN = Spec.getarg()));
00055 
00056 // All done
00057 //
00058    sprintf(pDir, "%d fail file%s found.", num, (num == 1 ? "" : "s"));
00059    Msg(pDir);
00060    return rc;
00061 }
00062 
00063 /******************************************************************************/
00064 /*                              F i n d N o l k                               */
00065 /******************************************************************************/
00066   
00067 int XrdFrmAdmin::FindNolk(XrdOucArgs &Spec)
00068 {
00069    XrdFrmFileset *sP;
00070    XrdFrmFiles   *fP;
00071    char pDir[MAXPATHLEN], *lDir = Opt.Args[1];
00072    int opts = (Opt.Recurse ? XrdFrmFiles::Recursive : 0);
00073    int ec = 0, rc = 0, num = 0;
00074 
00075 // Process each directory
00076 //
00077    do {if (!Config.LocalPath(lDir, pDir, sizeof(pDir))) continue;
00078        fP = new XrdFrmFiles(pDir, opts);
00079        while((sP = fP->Get(ec)))
00080             {if (!(sP->lockFile())) {Msg(sP->basePath()); num++;}
00081             }
00082        if (ec) rc = 4;
00083        delete fP;
00084       } while((lDir = Spec.getarg()));
00085 
00086 // All done
00087 //
00088    sprintf(pDir,"%d missing lock file%s found.", num, (num == 1 ? "" : "s"));
00089    Msg(pDir);
00090    return rc;
00091 }
00092   
00093 /******************************************************************************/
00094 /*                              F i n d U n m i                               */
00095 /******************************************************************************/
00096   
00097 int XrdFrmAdmin::FindUnmi(XrdOucArgs &Spec)
00098 {
00099    XrdFrmFileset *sP;
00100    XrdFrmFiles   *fP;
00101    const char *Why;
00102    char buff[128], pDir[MAXPATHLEN], *lDir = Opt.Args[1];
00103    int opts = (Opt.Recurse ? XrdFrmFiles::Recursive : 0);
00104    int ec = 0, rc = 0, num = 0;
00105 
00106 // Process each directory
00107 //
00108    do {if (!Config.LocalPath(lDir, pDir, sizeof(pDir))) continue;
00109        fP = new XrdFrmFiles(pDir, opts);
00110        while((sP = fP->Get(ec)))
00111             {     if (!(sP->lockFile()))
00112                      Why = "Unmigrated; no lock file: ";
00113              else if (sP->baseFile()->Stat.st_mtime >
00114                       sP->lockFile()->Stat.st_mtime)
00115                      Why="Unmigrated; modified: ";
00116              else continue;
00117              Msg(Why, sP->basePath()); num++;
00118             }
00119        if (ec) rc = 4;
00120        delete fP;
00121       } while((lDir = Spec.getarg()));
00122 
00123 // All done
00124 //
00125    sprintf(buff,"%d file%s unmigrated files found.",num,(num == 1 ? "" : "s"));
00126    Msg(buff);
00127    return rc;
00128 }

Generated on Tue Jul 5 14:46:35 2011 for ROOT_528-00b_version by  doxygen 1.5.1