xrootd
XrdFrcXAttr.hh
Go to the documentation of this file.
00001 #ifndef __XRDFRCXATTR_HH__
00002 #define __XRDFRCXATTR_HH__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d F r c X A t t r . h h                         */
00006 /*                                                                            */
00007 /* (c) 2010 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 #include <sys/types.h>
00034 #include <inttypes.h>
00035 #include <netinet/in.h>
00036 #include <sys/types.h>
00037 
00038 #include "XrdSys/XrdSysPlatform.hh"
00039 
00040 /* XrdFrcXAttr encapsulates the extended attributes needed to determine
00041    file residency. It is used by the FRM in migrate and purge processing as well
00042    as for the OSS to determine file residency in memory. It is self-contained
00043    to prevent circular dependencies.
00044 */
00045 
00046 /******************************************************************************/
00047 /*                        X r d F r c X A t t r C p y                         */
00048 /******************************************************************************/
00049   
00050 class XrdFrcXAttrCpy
00051 {
00052 public:
00053 
00054 long long cpyTime;     // Last time file was copied
00055 char      Rsvd[16];    // Reserved fields
00056 
00057 /* postGet() will put cpyTime in host byte order (see preSet()).
00058 */
00059        int             postGet(int Result)
00060                               {if (Result > 0) cpyTime = ntohll(cpyTime);
00061                                return Result;
00062                               }
00063 
00064 /* preSet() will put cpyTime in network byte order to allow the attribute to
00065             to be copied to different architectures and still work.
00066 */
00067        XrdFrcXAttrCpy *preSet(XrdFrcXAttrCpy &tmp)
00068                              {tmp.cpyTime = htonll(cpyTime); return &tmp;}
00069 
00070 /* Name() returns the extended attribute name for this object.
00071 */
00072 static const char     *Name() {return "XrdFrm.Cpy";}
00073 
00074 /* sizeGet() and sizeSet() return the actual size of the object is used.
00075 */
00076 static int             sizeGet() {return sizeof(XrdFrcXAttrCpy);}
00077 static int             sizeSet() {return sizeof(XrdFrcXAttrCpy);}
00078 
00079        XrdFrcXAttrCpy() : cpyTime(0) {memset(Rsvd, 0, sizeof(Rsvd));}
00080       ~XrdFrcXAttrCpy() {}
00081 };
00082   
00083 /******************************************************************************/
00084 /*                        X r d F r c X A t t r M e m                         */
00085 /******************************************************************************/
00086   
00087 class XrdFrcXAttrMem
00088 {
00089 public:
00090 
00091 char      Flags;       // See definitions below
00092 char      Rsvd[7];     // Reserved fields
00093 
00094 // The following flags are defined for Flags
00095 //
00096 static const char memMap  = 0x01; // Mmap the file
00097 static const char memKeep = 0x02; // Mmap the file and keep mapping
00098 static const char memLock = 0x04; // Mmap the file and lock it in memory
00099 
00100 /* postGet() and preSet() are minimal as no chages are needed
00101 */
00102 static int             postGet(int Result)         {return Result;}
00103        XrdFrcXAttrMem *preSet(XrdFrcXAttrMem &tmp) {return this;}
00104 
00105 /* Name() returns the extended attribute name for this object.
00106 */
00107 static const char     *Name() {return "XrdFrm.Mem";}
00108 
00109 /* sizeGet() and sizeSet() return the actual size of the object is used.
00110 */
00111 static int             sizeGet() {return sizeof(XrdFrcXAttrMem);}
00112 static int             sizeSet() {return sizeof(XrdFrcXAttrMem);}
00113 
00114        XrdFrcXAttrMem() : Flags(0) {memset(Rsvd, 0, sizeof(Rsvd));}
00115       ~XrdFrcXAttrMem() {}
00116 };
00117 
00118 /******************************************************************************/
00119 /*                        X r d F r c X A t t r P i n                         */
00120 /******************************************************************************/
00121   
00122 class XrdFrcXAttrPin
00123 {
00124 public:
00125 
00126 long long pinTime;     // Pin-to-time or pin-for-time value
00127 char      Flags;       // See definitions below
00128 char      Rsvd[7];     // Reserved fields
00129 
00130 // The following flags are defined for Flags
00131 //
00132 static const char pinPerm = 0x01; // Pin forever
00133 static const char pinIdle = 0x02; // Pin unless pinTime idle met
00134 static const char pinKeep = 0x04; // Pin until  pinTime
00135 static const char pinSet  = 0x07; // Pin is valid
00136 
00137 /* postGet() will put pinTime in host byte order (see preSet()).
00138 */
00139        int             postGet(int Result)
00140                               {if (Result > 0) pinTime = ntohll(pinTime);
00141                                return Result;
00142                               }
00143 
00144 /* preSet() will put pinTime in network byte order to allow the attribute to
00145             to be copied to different architectures and still work.
00146 */
00147        XrdFrcXAttrPin *preSet(XrdFrcXAttrPin &tmp)
00148                              {tmp.pinTime = htonll(pinTime); tmp.Flags = Flags;
00149                               return &tmp;
00150                              }
00151 
00152 /* Name() returns the extended attribute name for this object.
00153 */
00154 static const char     *Name() {return "XrdFrm.Pin";}
00155 
00156 
00157 /* sizeGet() and sizeSet() return the actual size of the object is used.
00158 */
00159 static int             sizeGet() {return sizeof(XrdFrcXAttrCpy);}
00160 static int             sizeSet() {return sizeof(XrdFrcXAttrCpy);}
00161 
00162        XrdFrcXAttrPin() : pinTime(0), Flags(0) {memset(Rsvd, 0, sizeof(Rsvd));}
00163       ~XrdFrcXAttrPin() {}
00164 };
00165 
00166 /******************************************************************************/
00167 /*                        X r d F r c X A t t r P f n                         */
00168 /******************************************************************************/
00169   
00170 class XrdFrcXAttrPfn
00171 {
00172 public:
00173 
00174 char      Pfn[MAXPATHLEN+8]; // Enough room for the Pfn
00175 
00176 /* postGet() and preSet() are minimal as no chages are needed
00177 */
00178 static int             postGet(int Result)         {return Result;}
00179        XrdFrcXAttrPfn *preSet(XrdFrcXAttrPfn &tmp) {return this;}
00180 
00181 /* Name() returns the extended attribute name for this object.
00182 */
00183 static const char     *Name() {return "XrdFrm.Pfn";}
00184 
00185 /* sizeGet() return the actual size of the object is used.
00186 */
00187 static int             sizeGet() {return sizeof(XrdFrcXAttrPfn);}
00188 
00189 /* sizeSet() returns the length of the Pfn string plus the null byte.
00190 */
00191        int             sizeSet() {return strlen(Pfn)+1;}
00192 
00193        XrdFrcXAttrPfn() {*Pfn = 0;}
00194       ~XrdFrcXAttrPfn() {}
00195 };
00196 #endif