xrootd
XrdOssSpace.hh
Go to the documentation of this file.
00001 #ifndef _OSS_SPACE_H
00002 #define _OSS_SPACE_H
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d O s s S p a c e . h h                         */
00006 /*                                                                            */
00007 /* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /*                                                                            */
00012 /* This file is part of the XRootD software suite.                            */
00013 /*                                                                            */
00014 /* XRootD is free software: you can redistribute it and/or modify it under    */
00015 /* the terms of the GNU Lesser General Public License as published by the     */
00016 /* Free Software Foundation, either version 3 of the License, or (at your     */
00017 /* option) any later version.                                                 */
00018 /*                                                                            */
00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00022 /* License for more details.                                                  */
00023 /*                                                                            */
00024 /* You should have received a copy of the GNU Lesser General Public License   */
00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00027 /*                                                                            */
00028 /* The copyright holder's institutional names and contributor's names may not */
00029 /* be used to endorse or promote products derived from this software without  */
00030 /* specific prior written permission of the institution or contributor.       */
00031 /******************************************************************************/
00032 
00033 class XrdSysError;
00034 
00035 class XrdOssSpace
00036 {
00037 public:
00038 
00039        enum       sType {Serv = 0, Pstg = 1, Purg = 2, Admin = 3,
00040                          RsvA = 4, RsvB = 5, RsvC = 6, addT  = 7,
00041                          Totn = 8};
00042 
00043 static const int  maxSNlen = 63;  // Maximum space name length (+1 for null)
00044 static const int  minSNbsz = 64;
00045 
00046 static void       Adjust(int Gent,          off_t Space, sType=Serv);
00047 
00048 static void       Adjust(const char *GName, off_t Space, sType=Serv);
00049 
00050 static int        Assign(const char *GName, long long &bytesUsed);
00051 
00052 static const int  haveUsage = 1;
00053 static const int  haveQuota = 2;
00054 
00055 static int        Init(); // Return the "or" of havexxxx (above)
00056 
00057 static int        Init(const char *aPath, const char *qFile, int isSOL);
00058 
00059 static int        Quotas();
00060 
00061 static int        Readjust();
00062 
00063 static void       Refresh();
00064 
00065 static int        Unassign(const char *GName);
00066 
00067 static long long  Usage(int gent) {return (gent < 0 || gent >= maxEnt
00068                                    ? 0 : uData[gent].Bytes[Serv]);}
00069 
00070                   XrdOssSpace() {}  // Everything is static
00071                  ~XrdOssSpace() {}  // Never gets deleted
00072 
00073 struct uEnt {char      gName[minSNbsz];
00074              long long Bytes[Totn]; // One of sType, above
00075             };
00076 
00077 static long long  Usage(const char *GName, struct uEnt &uVal, int rrd=0);
00078 
00079 private:
00080 static int    findEnt(const char *GName);
00081 static int    Readjust(int);
00082 static int    UsageLock(int Dolock=1);
00083 
00084 static const int ULen   = sizeof(long long);
00085 static const int DataSz = 16384;
00086 static const int maxEnt = DataSz/sizeof(uEnt);
00087 
00088 static const char *qFname;
00089 static const char *uFname;
00090 static uEnt        uData[maxEnt];
00091 static short       uDvec[maxEnt];
00092 static time_t      lastMtime;
00093 static int         fencEnt;
00094 static int         freeEnt;
00095 static int         aFD;
00096 static int         Solitary;
00097 };
00098 #endif