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 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <sys/types.h>
34 #include <cinttypes>
35 #include <netinet/in.h>
36 #include <sys/types.h>
37 #include <cstring>
38 
39 #include "XrdSys/XrdSysPlatform.hh"
40 
41 /* XrdFrcXAttr encapsulates the extended attributes needed to determine
42  file residency. It is used by the FRM in migrate and purge processing as well
43  as for the OSS to determine file residency in memory. It is self-contained
44  to prevent circular dependencies.
45 */
46 
47 /******************************************************************************/
48 /* X r d F r c X A t t r C p y */
49 /******************************************************************************/
50 
52 {
53 public:
54 
55 long long cpyTime; // Last time file was copied
56 char Rsvd[16]; // Reserved fields
57 
58 /* postGet() will put cpyTime in host byte order (see preSet()).
59 */
60  int postGet(int Result)
61  {if (Result > 0) cpyTime = ntohll(cpyTime);
62  return Result;
63  }
64 
65 /* preSet() will put cpyTime in network byte order to allow the attribute to
66  to be copied to different architectures and still work.
67 */
69  {tmp.cpyTime = htonll(cpyTime); return &tmp;}
70 
71 /* Name() returns the extended attribute name for this object.
72 */
73 static const char *Name() {return "XrdFrm.Cpy";}
74 
75 /* sizeGet() and sizeSet() return the actual size of the object is used.
76 */
77 static int sizeGet() {return sizeof(XrdFrcXAttrCpy);}
78 static int sizeSet() {return sizeof(XrdFrcXAttrCpy);}
79 
80  XrdFrcXAttrCpy() : cpyTime(0) {memset(Rsvd, 0, sizeof(Rsvd));}
82 };
83 
84 /******************************************************************************/
85 /* X r d F r c X A t t r M e m */
86 /******************************************************************************/
87 
89 {
90 public:
91 
92 char Flags; // See definitions below
93 char Rsvd[7]; // Reserved fields
94 
95 // The following flags are defined for Flags
96 //
97 static const char memMap = 0x01; // Mmap the file
98 static const char memKeep = 0x02; // Mmap the file and keep mapping
99 static const char memLock = 0x04; // Mmap the file and lock it in memory
100 
101 /* postGet() and preSet() are minimal as no chages are needed
102 */
103 static int postGet(int Result) {return Result;}
104  XrdFrcXAttrMem *preSet(XrdFrcXAttrMem &tmp) {return this;}
105 
106 /* Name() returns the extended attribute name for this object.
107 */
108 static const char *Name() {return "XrdFrm.Mem";}
109 
110 /* sizeGet() and sizeSet() return the actual size of the object is used.
111 */
112 static int sizeGet() {return sizeof(XrdFrcXAttrMem);}
113 static int sizeSet() {return sizeof(XrdFrcXAttrMem);}
114 
115  XrdFrcXAttrMem() : Flags(0) {memset(Rsvd, 0, sizeof(Rsvd));}
117 };
118 
119 /******************************************************************************/
120 /* X r d F r c X A t t r P i n */
121 /******************************************************************************/
122 
124 {
125 public:
126 
127 long long pinTime; // Pin-to-time or pin-for-time value
128 char Flags; // See definitions below
129 char Rsvd[7]; // Reserved fields
130 
131 // The following flags are defined for Flags
132 //
133 static const char pinPerm = 0x01; // Pin forever
134 static const char pinIdle = 0x02; // Pin unless pinTime idle met
135 static const char pinKeep = 0x04; // Pin until pinTime
136 static const char pinSet = 0x07; // Pin is valid
137 
138 /* postGet() will put pinTime in host byte order (see preSet()).
139 */
140  int postGet(int Result)
141  {if (Result > 0) pinTime = ntohll(pinTime);
142  return Result;
143  }
144 
145 /* preSet() will put pinTime in network byte order to allow the attribute to
146  to be copied to different architectures and still work.
147 */
149  {tmp.pinTime = htonll(pinTime); tmp.Flags = Flags;
150  return &tmp;
151  }
152 
153 /* Name() returns the extended attribute name for this object.
154 */
155 static const char *Name() {return "XrdFrm.Pin";}
156 
157 
158 /* sizeGet() and sizeSet() return the actual size of the object is used.
159 */
160 static int sizeGet() {return sizeof(XrdFrcXAttrCpy);}
161 static int sizeSet() {return sizeof(XrdFrcXAttrCpy);}
162 
163  XrdFrcXAttrPin() : pinTime(0), Flags(0) {memset(Rsvd, 0, sizeof(Rsvd));}
165 };
166 
167 /******************************************************************************/
168 /* X r d F r c X A t t r P f n */
169 /******************************************************************************/
170 
172 {
173 public:
174 
175 char Pfn[MAXPATHLEN+8]; // Enough room for the Pfn
176 
177 /* postGet() and preSet() are minimal as no chages are needed
178 */
179 static int postGet(int Result) {return Result;}
180  XrdFrcXAttrPfn *preSet(XrdFrcXAttrPfn &tmp) {(void)tmp; return this;}
181 
182 /* Name() returns the extended attribute name for this object.
183 */
184 static const char *Name() {return "XrdFrm.Pfn";}
185 
186 /* sizeGet() return the actual size of the object is used.
187 */
188 static int sizeGet() {return sizeof(XrdFrcXAttrPfn);}
189 
190 /* sizeSet() returns the length of the Pfn string plus the null byte.
191 */
192  int sizeSet() {return strlen(Pfn)+1;}
193 
194  XrdFrcXAttrPfn() {*Pfn = 0;}
196 };
197 #endif
int postGet(int Result)
Definition: XrdFrcXAttr.hh:60
static int sizeGet()
Definition: XrdFrcXAttr.hh:77
long long cpyTime
Definition: XrdFrcXAttr.hh:55
char Rsvd[16]
Definition: XrdFrcXAttr.hh:56
static const char * Name()
Definition: XrdFrcXAttr.hh:73
static int sizeSet()
Definition: XrdFrcXAttr.hh:78
XrdFrcXAttrCpy * preSet(XrdFrcXAttrCpy &tmp)
Definition: XrdFrcXAttr.hh:68
static int postGet(int Result)
Definition: XrdFrcXAttr.hh:103
static int sizeGet()
Definition: XrdFrcXAttr.hh:112
static int sizeSet()
Definition: XrdFrcXAttr.hh:113
static const char memKeep
Definition: XrdFrcXAttr.hh:98
static const char memLock
Definition: XrdFrcXAttr.hh:99
XrdFrcXAttrMem * preSet(XrdFrcXAttrMem &tmp)
Definition: XrdFrcXAttr.hh:104
static const char * Name()
Definition: XrdFrcXAttr.hh:108
static const char memMap
Definition: XrdFrcXAttr.hh:97
static const char * Name()
Definition: XrdFrcXAttr.hh:184
char Pfn[MAXPATHLEN+8]
Definition: XrdFrcXAttr.hh:175
static int postGet(int Result)
Definition: XrdFrcXAttr.hh:179
static int sizeGet()
Definition: XrdFrcXAttr.hh:188
XrdFrcXAttrPfn * preSet(XrdFrcXAttrPfn &tmp)
Definition: XrdFrcXAttr.hh:180
XrdFrcXAttrPin * preSet(XrdFrcXAttrPin &tmp)
Definition: XrdFrcXAttr.hh:148
static int sizeGet()
Definition: XrdFrcXAttr.hh:160
static const char pinSet
Definition: XrdFrcXAttr.hh:136
static const char pinKeep
Definition: XrdFrcXAttr.hh:135
static const char pinPerm
Definition: XrdFrcXAttr.hh:133
static const char pinIdle
Definition: XrdFrcXAttr.hh:134
long long pinTime
Definition: XrdFrcXAttr.hh:127
static const char * Name()
Definition: XrdFrcXAttr.hh:155
int postGet(int Result)
Definition: XrdFrcXAttr.hh:140
static int sizeSet()
Definition: XrdFrcXAttr.hh:161