xrootd
XrdFrcXAttr.hh
Go to the documentation of this file.
1 #ifndef __XRDFRCXATTR_HH__
2 #define __XRDFRCXATTR_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d F r c X A t t r . h h */
6 /* */
7 /* (c) 2010 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 #include <sys/types.h>
14 #include <inttypes.h>
15 #include <netinet/in.h>
16 #include <sys/types.h>
17 
18 #include "XrdSys/XrdSysPlatform.hh"
19 
20 /* XrdFrcXAttr encapsulates the extended attributes needed to determine
21  file residency. It is used by the FRM in migrate and purge processing as well
22  as for the OSS to determine file residency in memory. It is self-contained
23  to prevent circular dependencies.
24 */
25 
26 /******************************************************************************/
27 /* X r d F r c X A t t r C p y */
28 /******************************************************************************/
29 
31 {
32 public:
33 
34 long long cpyTime; // Last time file was copied
35 char Rsvd[16]; // Reserved fields
36 
37 /* postGet() will put cpyTime in host byte order (see preSet()).
38 */
39  int postGet(int Result)
40  {if (Result > 0) cpyTime = ntohll(cpyTime);
41  return Result;
42  }
43 
44 /* preSet() will put cpyTime in network byte order to allow the attribute to
45  to be copied to different architectures and still work.
46 */
48  {tmp.cpyTime = htonll(cpyTime); return &tmp;}
49 
50 /* Name() returns the extended attribute name for this object.
51 */
52 static const char *Name() {return "XrdFrm.Cpy";}
53 
54 /* sizeGet() and sizeSet() return the actual size of the object is used.
55 */
56 static int sizeGet() {return sizeof(XrdFrcXAttrCpy);}
57 static int sizeSet() {return sizeof(XrdFrcXAttrCpy);}
58 
59  XrdFrcXAttrCpy() : cpyTime(0) {memset(Rsvd, 0, sizeof(Rsvd));}
61 };
62 
63 /******************************************************************************/
64 /* X r d F r c X A t t r M e m */
65 /******************************************************************************/
66 
68 {
69 public:
70 
71 char Flags; // See definitions below
72 char Rsvd[7]; // Reserved fields
73 
74 // The following flags are defined for Flags
75 //
76 static const char memMap = 0x01; // Mmap the file
77 static const char memKeep = 0x02; // Mmap the file and keep mapping
78 static const char memLock = 0x04; // Mmap the file and lock it in memory
79 
80 /* postGet() and preSet() are minimal as no chages are needed
81 */
82 static int postGet(int Result) {return Result;}
83  XrdFrcXAttrMem *preSet(XrdFrcXAttrMem &tmp) {return this;}
84 
85 /* Name() returns the extended attribute name for this object.
86 */
87 static const char *Name() {return "XrdFrm.Mem";}
88 
89 /* sizeGet() and sizeSet() return the actual size of the object is used.
90 */
91 static int sizeGet() {return sizeof(XrdFrcXAttrMem);}
92 static int sizeSet() {return sizeof(XrdFrcXAttrMem);}
93 
94  XrdFrcXAttrMem() : Flags(0) {memset(Rsvd, 0, sizeof(Rsvd));}
96 };
97 
98 /******************************************************************************/
99 /* X r d F r c X A t t r P i n */
100 /******************************************************************************/
101 
103 {
104 public:
105 
106 long long pinTime; // Pin-to-time or pin-for-time value
107 char Flags; // See definitions below
108 char Rsvd[7]; // Reserved fields
109 
110 // The following flags are defined for Flags
111 //
112 static const char pinPerm = 0x01; // Pin forever
113 static const char pinIdle = 0x02; // Pin unless pinTime idle met
114 static const char pinKeep = 0x04; // Pin until pinTime
115 static const char pinSet = 0x07; // Pin is valid
116 
117 /* postGet() will put pinTime in host byte order (see preSet()).
118 */
119  int postGet(int Result)
120  {if (Result > 0) pinTime = ntohll(pinTime);
121  return Result;
122  }
123 
124 /* preSet() will put pinTime in network byte order to allow the attribute to
125  to be copied to different architectures and still work.
126 */
128  {tmp.pinTime = htonll(pinTime); tmp.Flags = Flags;
129  return &tmp;
130  }
131 
132 /* Name() returns the extended attribute name for this object.
133 */
134 static const char *Name() {return "XrdFrm.Pin";}
135 
136 
137 /* sizeGet() and sizeSet() return the actual size of the object is used.
138 */
139 static int sizeGet() {return sizeof(XrdFrcXAttrCpy);}
140 static int sizeSet() {return sizeof(XrdFrcXAttrCpy);}
141 
142  XrdFrcXAttrPin() : pinTime(0), Flags(0) {memset(Rsvd, 0, sizeof(Rsvd));}
144 };
145 
146 /******************************************************************************/
147 /* X r d F r c X A t t r P f n */
148 /******************************************************************************/
149 
151 {
152 public:
153 
154 char Pfn[MAXPATHLEN+8]; // Enough room for the Pfn
155 
156 /* postGet() and preSet() are minimal as no chages are needed
157 */
158 static int postGet(int Result) {return Result;}
159  XrdFrcXAttrPfn *preSet(XrdFrcXAttrPfn &tmp) {return this;}
160 
161 /* Name() returns the extended attribute name for this object.
162 */
163 static const char *Name() {return "XrdFrm.Pfn";}
164 
165 /* sizeGet() return the actual size of the object is used.
166 */
167 static int sizeGet() {return sizeof(XrdFrcXAttrPfn);}
168 
169 /* sizeSet() returns the length of the Pfn string plus the null byte.
170 */
171  int sizeSet() {return strlen(Pfn)+1;}
172 
173  XrdFrcXAttrPfn() {*Pfn = 0;}
175 };
176 #endif