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