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