|
xrootd
|
00001 #ifndef __XPROTOCOL_H 00002 #define __XPROTOCOL_H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X P r o t o c o l . h h */ 00006 /* */ 00007 /* (c) 2012 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 //#ifndef __GNUC__ 00034 //#define __attribute__(x) 00035 //#ifdef SUNCC 00036 //#pragma pack(4) 00037 //#endif 00038 //#endif 00039 00040 #ifdef __CINT__ 00041 #define __attribute__(x) 00042 #endif 00043 00044 // The following is the binary representation of the protocol version here. 00045 // Protocol version is repesented as three base10 digits x.y.z with x having no 00046 // upper limit (i.e. n.9.9 + 1 -> n+1.0.0). 00047 // 00048 #define kXR_PROTOCOLVERSION 0x00000297 00049 #define kXR_PROTOCOLVSTRING "2.9.7" 00050 00051 #include "XProtocol/XPtypes.hh" 00052 00053 // KINDS of SERVERS 00054 // 00055 // 00056 #define kXR_DataServer 1 00057 #define kXR_LBalServer 0 00058 00059 // The below are defined for protocol version 2.9.7 or higher 00060 // 00061 #define kXR_isManager 0x00000002 00062 #define kXR_isServer 0x00000001 00063 #define kXR_attrMeta 0x00000100 00064 #define kXR_attrProxy 0x00000200 00065 #define kXR_attrSuper 0x00000400 00066 00067 #define kXR_maxReqRetry 10 00068 00069 // 00070 // Kind of error inside a XTNetFile's routine (temporary) 00071 // 00072 enum XReqErrorType { 00073 kGENERICERR = 0, // Generic error 00074 kREAD, // Error while reading from stream 00075 kWRITE, // Error while writing to stream 00076 kREDIRCONNECT, // Error redirecting to a given host 00077 kOK, // Everything seems ok 00078 kNOMORESTREAMS // No more available stream IDs for 00079 // async processing 00080 }; 00081 00082 //______________________________________________ 00083 // PROTOCOL DEFINITION: CLIENT'S REQUESTS TYPES 00084 //______________________________________________ 00085 // 00086 enum XRequestTypes { 00087 kXR_auth = 3000, 00088 kXR_query, // 3001 00089 kXR_chmod, // 3002 00090 kXR_close, // 3003 00091 kXR_dirlist, // 3004 00092 kXR_getfile, // 3005 00093 kXR_protocol,// 3006 00094 kXR_login, // 3007 00095 kXR_mkdir, // 3008 00096 kXR_mv, // 3009 00097 kXR_open, // 3010 00098 kXR_ping, // 3011 00099 kXR_putfile, // 3012 00100 kXR_read, // 3013 00101 kXR_rm, // 3014 00102 kXR_rmdir, // 3015 00103 kXR_sync, // 3016 00104 kXR_stat, // 3017 00105 kXR_set, // 3018 00106 kXR_write, // 3019 00107 kXR_admin, // 3020 00108 kXR_prepare, // 3021 00109 kXR_statx, // 3022 00110 kXR_endsess, // 3023 00111 kXR_bind, // 3024 00112 kXR_readv, // 3025 00113 kXR_verifyw, // 3026 00114 kXR_locate, // 3027 00115 kXR_truncate // 3028 00116 }; 00117 00118 // OPEN MODE FOR A REMOTE FILE 00119 enum XOpenRequestMode { 00120 kXR_ur = 0x100, 00121 kXR_uw = 0x080, 00122 kXR_ux = 0x040, 00123 kXR_gr = 0x020, 00124 kXR_gw = 0x010, 00125 kXR_gx = 0x008, 00126 kXR_or = 0x004, 00127 kXR_ow = 0x002, 00128 kXR_ox = 0x001 00129 }; 00130 00131 enum XMkdirOptions { 00132 kXR_mknone = 0, 00133 kXR_mkdirpath = 1 00134 }; 00135 00136 // this is a bitmask 00137 enum XLoginCapVer { 00138 kXR_lcvnone = 0, 00139 kXR_vermask = 63, 00140 kXR_asyncap = 128 00141 }; 00142 00143 // this is a single number that goes into capver as the version 00144 // 00145 enum XLoginVersion { 00146 kXR_ver000 = 0, // Old clients predating history 00147 kXR_ver001 = 1, // Generally implemented 2005 protocol 00148 kXR_ver002 = 2, // Same as 1 but adds asyncresp recognition 00149 kXR_ver003 = 3 // The 2011-2012 rewritten client 00150 }; 00151 00152 enum XStatRequestOption { 00153 kXR_vfs = 1 00154 }; 00155 00156 enum XStatRespFlags { 00157 kXR_file = 0, 00158 kXR_xset = 1, 00159 kXR_isDir = 2, 00160 kXR_other = 4, 00161 kXR_offline = 8, 00162 kXR_readable=16, 00163 kXR_writable=32, 00164 kXR_poscpend=64 00165 }; 00166 00167 enum XDirlistRequestOption { 00168 kXR_online = 1 00169 }; 00170 00171 enum XOpenRequestOption { 00172 kXR_compress = 1, 00173 kXR_delete = 2, 00174 kXR_force = 4, 00175 kXR_new = 8, 00176 kXR_open_read= 16, 00177 kXR_open_updt= 32, 00178 kXR_async = 64, 00179 kXR_refresh = 128, 00180 kXR_mkpath = 256, 00181 kXR_open_apnd= 512, 00182 kXR_retstat = 1024, 00183 kXR_replica = 2048, 00184 kXR_posc = 4096, 00185 kXR_nowait = 8192, 00186 kXR_seqio =16384 00187 }; 00188 00189 enum XQueryType { 00190 kXR_QStats = 1, 00191 kXR_QPrep = 2, 00192 kXR_Qcksum = 3, 00193 kXR_Qxattr = 4, 00194 kXR_Qspace = 5, 00195 kXR_Qckscan= 6, 00196 kXR_Qconfig= 7, 00197 kXR_Qvisa = 8, 00198 kXR_Qopaque=16, 00199 kXR_Qopaquf=32 00200 }; 00201 00202 enum XVerifyType { 00203 kXR_nocrc = 0, 00204 kXR_crc32 = 1 00205 }; 00206 00207 enum XLogonType { 00208 kXR_useruser = 0, 00209 kXR_useradmin = 1 00210 }; 00211 00212 // Andy's request for async/unsolicited 00213 enum XPrepRequestOption { 00214 kXR_cancel = 1, 00215 kXR_notify = 2, 00216 kXR_noerrs = 4, 00217 kXR_stage = 8, 00218 kXR_wmode = 16, 00219 kXR_coloc = 32, 00220 kXR_fresh = 64 00221 }; 00222 00223 //_______________________________________________ 00224 // PROTOCOL DEFINITION: SERVER'S RESPONSES TYPES 00225 //_______________________________________________ 00226 // 00227 enum XResponseType { 00228 kXR_ok = 0, 00229 kXR_oksofar = 4000, 00230 kXR_attn, 00231 kXR_authmore, 00232 kXR_error, 00233 kXR_redirect, 00234 kXR_wait, 00235 kXR_waitresp, 00236 kXR_noResponsesYet = 10000 00237 }; 00238 00239 //_______________________________________________ 00240 // PROTOCOL DEFINITION: SERVER"S ATTN CODES 00241 //_______________________________________________ 00242 00243 enum XActionCode { 00244 kXR_asyncab = 5000, 00245 kXR_asyncdi, 00246 kXR_asyncms, 00247 kXR_asyncrd, 00248 kXR_asyncwt, 00249 kXR_asyncav, 00250 kXR_asynunav, 00251 kXR_asyncgo, 00252 kXR_asynresp 00253 }; 00254 00255 //_______________________________________________ 00256 // PROTOCOL DEFINITION: SERVER'S ERROR CODES 00257 //_______________________________________________ 00258 // 00259 enum XErrorCode { 00260 kXR_ArgInvalid = 3000, 00261 kXR_ArgMissing, 00262 kXR_ArgTooLong, 00263 kXR_FileLocked, 00264 kXR_FileNotOpen, 00265 kXR_FSError, 00266 kXR_InvalidRequest, 00267 kXR_IOError, 00268 kXR_NoMemory, 00269 kXR_NoSpace, 00270 kXR_NotAuthorized, 00271 kXR_NotFound, 00272 kXR_ServerError, 00273 kXR_Unsupported, 00274 kXR_noserver, 00275 kXR_NotFile, 00276 kXR_isDirectory, 00277 kXR_Cancelled, 00278 kXR_ChkLenErr, 00279 kXR_ChkSumErr, 00280 kXR_inProgress, 00281 kXR_noErrorYet = 10000 00282 }; 00283 00284 00285 //______________________________________________ 00286 // PROTOCOL DEFINITION: CLIENT'S REQUESTS STRUCTS 00287 //______________________________________________ 00288 // 00289 // We need to pack structures sent all over the net! 00290 // __attribute__((packed)) assures no padding bytes. 00291 // 00292 // Nice bodies of the headers for the client requests. 00293 // Note that the protocol specifies these values to be in network 00294 // byte order when sent 00295 // 00296 // G.Ganis: use of flat structures to avoid packing options 00297 00298 struct ClientAdminRequest { 00299 kXR_char streamid[2]; 00300 kXR_unt16 requestid; 00301 kXR_char reserved[16]; 00302 kXR_int32 dlen; 00303 }; 00304 struct ClientAuthRequest { 00305 kXR_char streamid[2]; 00306 kXR_unt16 requestid; 00307 kXR_char reserved[12]; 00308 kXR_char credtype[4]; 00309 kXR_int32 dlen; 00310 }; 00311 struct ClientBindRequest { 00312 kXR_char streamid[2]; 00313 kXR_unt16 requestid; 00314 kXR_char sessid[16]; 00315 kXR_int32 dlen; 00316 }; 00317 struct ClientChmodRequest { 00318 kXR_char streamid[2]; 00319 kXR_unt16 requestid; 00320 kXR_char reserved[14]; 00321 kXR_unt16 mode; 00322 kXR_int32 dlen; 00323 }; 00324 struct ClientCloseRequest { 00325 kXR_char streamid[2]; 00326 kXR_unt16 requestid; 00327 kXR_char fhandle[4]; 00328 kXR_int64 fsize; 00329 kXR_char reserved[4]; 00330 kXR_int32 dlen; 00331 }; 00332 struct ClientDirlistRequest { 00333 kXR_char streamid[2]; 00334 kXR_unt16 requestid; 00335 kXR_char reserved[15]; 00336 kXR_char options[1]; 00337 kXR_int32 dlen; 00338 }; 00339 struct ClientEndsessRequest { 00340 kXR_char streamid[2]; 00341 kXR_unt16 requestid; 00342 kXR_char sessid[16]; 00343 kXR_int32 dlen; 00344 }; 00345 struct ClientGetfileRequest { 00346 kXR_char streamid[2]; 00347 kXR_unt16 requestid; 00348 kXR_int32 options; 00349 kXR_char reserved[8]; 00350 kXR_int32 buffsz; 00351 kXR_int32 dlen; 00352 }; 00353 struct ClientLocateRequest { 00354 kXR_char streamid[2]; 00355 kXR_unt16 requestid; 00356 kXR_unt16 options; 00357 kXR_char reserved[14]; 00358 kXR_int32 dlen; 00359 }; 00360 struct ClientLoginRequest { 00361 kXR_char streamid[2]; 00362 kXR_unt16 requestid; 00363 kXR_int32 pid; 00364 kXR_char username[8]; 00365 kXR_char reserved[2]; 00366 kXR_char capver[1]; 00367 kXR_char role[1]; 00368 kXR_int32 dlen; 00369 }; 00370 struct ClientMkdirRequest { 00371 kXR_char streamid[2]; 00372 kXR_unt16 requestid; 00373 kXR_char options[1]; 00374 kXR_char reserved[13]; 00375 kXR_unt16 mode; 00376 kXR_int32 dlen; 00377 }; 00378 struct ClientMvRequest { 00379 kXR_char streamid[2]; 00380 kXR_unt16 requestid; 00381 kXR_char reserved[16]; 00382 kXR_int32 dlen; 00383 }; 00384 struct ClientOpenRequest { 00385 kXR_char streamid[2]; 00386 kXR_unt16 requestid; 00387 kXR_unt16 mode; 00388 kXR_unt16 options; 00389 kXR_char reserved[12]; 00390 kXR_int32 dlen; 00391 }; 00392 00393 struct ClientPingRequest { 00394 kXR_char streamid[2]; 00395 kXR_unt16 requestid; 00396 kXR_char reserved[16]; 00397 kXR_int32 dlen; 00398 }; 00399 struct ClientProtocolRequest { 00400 kXR_char streamid[2]; 00401 kXR_unt16 requestid; 00402 kXR_int32 clientpv; // 2.9.7 or higher 00403 kXR_char reserved[12]; 00404 kXR_int32 dlen; 00405 }; 00406 struct ClientPrepareRequest { 00407 kXR_char streamid[2]; 00408 kXR_unt16 requestid; 00409 kXR_char options; 00410 kXR_char prty; 00411 kXR_unt16 port; // 2.9.9 or higher 00412 kXR_char reserved[12]; 00413 kXR_int32 dlen; 00414 }; 00415 struct ClientPutfileRequest { 00416 kXR_char streamid[2]; 00417 kXR_unt16 requestid; 00418 kXR_int32 options; 00419 kXR_char reserved[8]; 00420 kXR_int32 buffsz; 00421 kXR_int32 dlen; 00422 }; 00423 struct ClientQueryRequest { 00424 kXR_char streamid[2]; 00425 kXR_unt16 requestid; 00426 kXR_unt16 infotype; 00427 kXR_char reserved1[2]; 00428 kXR_char fhandle[4]; 00429 kXR_char reserved2[8]; 00430 kXR_int32 dlen; 00431 }; 00432 struct ClientReadRequest { 00433 kXR_char streamid[2]; 00434 kXR_unt16 requestid; 00435 kXR_char fhandle[4]; 00436 kXR_int64 offset; 00437 kXR_int32 rlen; 00438 kXR_int32 dlen; 00439 }; 00440 struct ClientReadVRequest { 00441 kXR_char streamid[2]; 00442 kXR_unt16 requestid; 00443 kXR_char reserved[15]; 00444 kXR_char pathid; 00445 kXR_int32 dlen; 00446 }; 00447 struct ClientRmRequest { 00448 kXR_char streamid[2]; 00449 kXR_unt16 requestid; 00450 kXR_char reserved[16]; 00451 kXR_int32 dlen; 00452 }; 00453 struct ClientRmdirRequest { 00454 kXR_char streamid[2]; 00455 kXR_unt16 requestid; 00456 kXR_char reserved[16]; 00457 kXR_int32 dlen; 00458 }; 00459 struct ClientSetRequest { 00460 kXR_char streamid[2]; 00461 kXR_unt16 requestid; 00462 kXR_char reserved[16]; 00463 kXR_int32 dlen; 00464 }; 00465 struct ClientStatRequest { 00466 kXR_char streamid[2]; 00467 kXR_unt16 requestid; 00468 kXR_char options; 00469 kXR_char reserved[11]; 00470 kXR_char fhandle[4]; 00471 kXR_int32 dlen; 00472 }; 00473 struct ClientSyncRequest { 00474 kXR_char streamid[2]; 00475 kXR_unt16 requestid; 00476 kXR_char fhandle[4]; 00477 kXR_char reserved[12]; 00478 kXR_int32 dlen; 00479 }; 00480 struct ClientTruncateRequest { 00481 kXR_char streamid[2]; 00482 kXR_unt16 requestid; 00483 kXR_char fhandle[4]; 00484 kXR_int64 offset; 00485 kXR_char reserved[4]; 00486 kXR_int32 dlen; 00487 }; 00488 struct ClientWriteRequest { 00489 kXR_char streamid[2]; 00490 kXR_unt16 requestid; 00491 kXR_char fhandle[4]; 00492 kXR_int64 offset; 00493 kXR_char pathid; 00494 kXR_char reserved[3]; 00495 kXR_int32 dlen; 00496 }; 00497 struct ClientVerifywRequest { 00498 kXR_char streamid[2]; 00499 kXR_unt16 requestid; 00500 kXR_char fhandle[4]; 00501 kXR_int64 offset; 00502 kXR_char pathid; 00503 kXR_char vertype; // One of XVerifyType 00504 kXR_char reserved[2]; 00505 kXR_int32 dlen; // Includes crc length 00506 }; 00507 00508 struct ClientRequestHdr { 00509 kXR_char streamid[2]; 00510 kXR_unt16 requestid; 00511 kXR_char body[16]; 00512 kXR_int32 dlen; 00513 }; 00514 00515 typedef union { 00516 struct ClientRequestHdr header; 00517 struct ClientAdminRequest admin; 00518 struct ClientAuthRequest auth; 00519 struct ClientBindRequest bind; 00520 struct ClientChmodRequest chmod; 00521 struct ClientCloseRequest close; 00522 struct ClientDirlistRequest dirlist; 00523 struct ClientEndsessRequest endsess; 00524 struct ClientGetfileRequest getfile; 00525 struct ClientLocateRequest locate; 00526 struct ClientLoginRequest login; 00527 struct ClientMkdirRequest mkdir; 00528 struct ClientMvRequest mv; 00529 struct ClientOpenRequest open; 00530 struct ClientPingRequest ping; 00531 struct ClientPrepareRequest prepare; 00532 struct ClientProtocolRequest protocol; 00533 struct ClientPutfileRequest putfile; 00534 struct ClientQueryRequest query; 00535 struct ClientReadRequest read; 00536 struct ClientReadVRequest readv; 00537 struct ClientRmRequest rm; 00538 struct ClientRmdirRequest rmdir; 00539 struct ClientSetRequest set; 00540 struct ClientStatRequest stat; 00541 struct ClientSyncRequest sync; 00542 struct ClientTruncateRequest truncate; 00543 struct ClientWriteRequest write; 00544 } ClientRequest; 00545 00546 struct readahead_list { 00547 kXR_char fhandle[4]; 00548 kXR_int32 rlen; 00549 kXR_int64 offset; 00550 }; 00551 00552 struct read_args { 00553 kXR_char pathid; 00554 kXR_char reserved[7]; 00555 // his struct is followed by an array of readahead_list 00556 }; 00557 00558 //_____________________________________________________________________ 00559 // PROTOCOL DEFINITION: SERVER'S RESPONSE 00560 //_____________________________________________________________________ 00561 // 00562 00563 // Nice header for the server response. 00564 // Note that the protocol specifies these values to be in network 00565 // byte order when sent 00566 // 00567 // G.Ganis: The following structures never need padding bytes: 00568 // no need of packing options 00569 00570 struct ServerResponseHeader { 00571 kXR_char streamid[2]; 00572 kXR_unt16 status; 00573 kXR_int32 dlen; 00574 }; 00575 00576 // Body for the kXR_bind response... useful 00577 struct ServerResponseBody_Bind { 00578 kXR_char substreamid; 00579 }; 00580 00581 // Body for the kXR_open response... useful 00582 struct ServerResponseBody_Open { 00583 kXR_char fhandle[4]; 00584 kXR_int32 cpsize; // cpsize & cptype returned if kXR_compress *or* 00585 kXR_char cptype[4]; // kXR_retstat is specified 00586 }; // info will follow if kXR_retstat is specified 00587 00588 // Body for the kXR_protocol response... useful 00589 struct ServerResponseBody_Protocol { 00590 kXR_int32 pval; 00591 kXR_int32 flags; 00592 }; 00593 00594 struct ServerResponseBody_Login { 00595 kXR_char sessid[16]; 00596 kXR_char sec[4096]; // Should be sufficient for every use 00597 }; 00598 00599 struct ServerResponseBody_Redirect { 00600 kXR_int32 port; 00601 char host[4096]; // Should be sufficient for every use 00602 }; 00603 00604 struct ServerResponseBody_Error { 00605 kXR_int32 errnum; 00606 char errmsg[4096]; // Should be sufficient for every use 00607 }; 00608 00609 struct ServerResponseBody_Wait { 00610 kXR_int32 seconds; 00611 char infomsg[4096]; // Should be sufficient for every use 00612 }; 00613 00614 struct ServerResponseBody_Waitresp { 00615 kXR_int32 seconds; 00616 }; 00617 00618 struct ServerResponseBody_Attn { 00619 kXR_int32 actnum; 00620 char parms[4096]; // Should be sufficient for every use 00621 }; 00622 00623 struct ServerResponseBody_Attn_asyncrd { 00624 kXR_int32 actnum; 00625 kXR_int32 port; 00626 char host[4092]; 00627 }; 00628 00629 struct ServerResponseBody_Attn_asynresp { 00630 kXR_int32 actnum; 00631 char reserved[4]; 00632 ServerResponseHeader resphdr; 00633 char respdata[4096]; 00634 }; 00635 00636 struct ServerResponseBody_Attn_asyncwt { 00637 kXR_int32 actnum; 00638 kXR_int32 wsec; 00639 }; 00640 00641 struct ServerResponseBody_Attn_asyncdi { 00642 kXR_int32 actnum; 00643 kXR_int32 wsec; 00644 kXR_int32 msec; 00645 }; 00646 00647 struct ServerResponseBody_Authmore { 00648 char data[4096]; 00649 }; 00650 00651 struct ServerResponseBody_Buffer { 00652 char data[4096]; 00653 }; 00654 00655 struct ServerResponse 00656 { 00657 ServerResponseHeader hdr; 00658 union 00659 { 00660 ServerResponseBody_Error error; 00661 ServerResponseBody_Authmore authmore; 00662 ServerResponseBody_Wait wait; 00663 ServerResponseBody_Waitresp waitresp; 00664 ServerResponseBody_Redirect redirect; 00665 ServerResponseBody_Attn attn; 00666 ServerResponseBody_Protocol protocol; 00667 ServerResponseBody_Login login; 00668 ServerResponseBody_Buffer buffer; 00669 ServerResponseBody_Bind bind; 00670 } body; 00671 }; 00672 00673 void ServerResponseHeader2NetFmt(struct ServerResponseHeader *srh); 00674 00675 // The fields to be sent as initial handshake 00676 struct ClientInitHandShake { 00677 kXR_int32 first; 00678 kXR_int32 second; 00679 kXR_int32 third; 00680 kXR_int32 fourth; 00681 kXR_int32 fifth; 00682 }; 00683 00684 // The body received after the first handshake's header 00685 struct ServerInitHandShake { 00686 kXR_int32 msglen; 00687 kXR_int32 protover; 00688 kXR_int32 msgval; 00689 }; 00690 00691 00692 00693 typedef kXR_int32 ServerResponseType; 00694 00695 struct ALIGN_CHECK {char chkszreq[25-sizeof(ClientRequest)]; 00696 char chkszrsp[ 9-sizeof(ServerResponseHeader)]; 00697 }; 00698 00699 /******************************************************************************/ 00700 /* X P r o t o c o l U t i l i t i e s */ 00701 /******************************************************************************/ 00702 00703 #include <errno.h> 00704 #if defined(WIN32) 00705 #if !defined(ENOTBLK) 00706 # define ENOTBLK 15 00707 #endif 00708 #if !defined(ETXTBSY) 00709 #define ETXTBSY 26 00710 #endif 00711 #if !defined(ENOBUFS) 00712 #define ENOBUFS 105 00713 #endif 00714 #if !defined(ENETUNREACH) 00715 #define ENETUNREACH 114 00716 #endif 00717 #endif 00718 00719 class XProtocol 00720 { 00721 public: 00722 00723 // mapError() is the occicial mapping from errno to xrootd protocol error. 00724 // 00725 static int mapError(int rc) 00726 {if (rc < 0) rc = -rc; 00727 switch(rc) 00728 {case ENOENT: return kXR_NotFound; 00729 case EPERM: return kXR_NotAuthorized; 00730 case EACCES: return kXR_NotAuthorized; 00731 case EIO: return kXR_IOError; 00732 case ENOMEM: return kXR_NoMemory; 00733 case ENOBUFS: return kXR_NoMemory; 00734 case ENOSPC: return kXR_NoSpace; 00735 case ENAMETOOLONG: return kXR_ArgTooLong; 00736 case ENETUNREACH: return kXR_noserver; 00737 case ENOTBLK: return kXR_NotFile; 00738 case EISDIR: return kXR_isDirectory; 00739 case EEXIST: return kXR_InvalidRequest; 00740 case ETXTBSY: return kXR_inProgress; 00741 default: return kXR_FSError; 00742 } 00743 } 00744 }; 00745 #endif
1.7.6.1