nfs-ganesha 1.4
|
00001 /* 00002 * vim:expandtab:shiftwidth=8:tabstop=8: 00003 */ 00004 00013 #ifdef HAVE_CONFIG_H 00014 #include "config.h" 00015 #endif 00016 00017 #include "fsal.h" 00018 #include "fsal_internal.h" 00019 #include "fsal_common.h" 00020 #include "fsal_convert.h" 00021 #include "config_parsing.h" 00022 #include "fsal_common.h" 00023 #include <string.h> 00024 00025 /* case unsensitivity */ 00026 #define STRCMP strcasecmp 00027 00028 #if HPSS_VERSION_MAJOR == 5 00029 #define TYPE_UUIDT uuid_t 00030 #else 00031 #define TYPE_UUIDT hpss_uuid_t 00032 #endif 00033 00034 #define INTMACRO_TO_STR(_x) _DEREF(_x) 00035 #define _DEREF(_x) #_x 00036 00037 char *HPSSFSAL_GetFSName() 00038 { 00039 return "HPSS " INTMACRO_TO_STR(HPSS_MAJOR_VERSION) "." 00040 INTMACRO_TO_STR(HPSS_MINOR_VERSION) "." INTMACRO_TO_STR(HPSS_PATCH_LEVEL); 00041 } 00042 00059 int HPSSFSAL_handlecmp(hpssfsal_handle_t * handle1, hpssfsal_handle_t * handle2, 00060 fsal_status_t * status) 00061 { 00062 00063 fsal_u64_t fileid1, fileid2; 00064 00065 *status = FSAL_STATUS_NO_ERROR; 00066 00067 if(!handle1 || !handle2) 00068 { 00069 status->major = ERR_FSAL_FAULT; 00070 return -1; 00071 } 00072 00073 /* hpss_HandleCompare returns wrong results for hardlinks : 00074 * it says that the two objects are different. 00075 * so we use our own comparation method, 00076 * by comparing fileids. 00077 */ 00078 fileid1 = hpss_GetObjId(&handle1->data.ns_handle); 00079 fileid2 = hpss_GetObjId(&handle2->data.ns_handle); 00080 00081 if(fileid1 > fileid2) 00082 return 1; 00083 else if(fileid2 == fileid1) 00084 return 0; 00085 else 00086 return -1; 00087 00088 } 00089 00104 unsigned int HPSSFSAL_Handle_to_HashIndex(hpssfsal_handle_t * p_handle, 00105 unsigned int cookie, 00106 unsigned int alphabet_len, 00107 unsigned int index_size) 00108 { 00109 #define SMALL_PRIME_MULT 3 00110 #define SMALL_PRIME_ADD 1999 00111 #define HASH_INCR( _h_, _i_ ) ( _h_ = (_h_ * SMALL_PRIME_MULT + SMALL_PRIME_ADD) % _i_ ) 00112 00113 unsigned int h = cookie; 00114 unsigned int i; 00115 unsigned32 objid = hpss_GetObjId(&p_handle->data.ns_handle); 00116 00117 /* In HPSS, the hardlink is a separated and independant object 00118 * because of this, the ns_handle.Generation may be different between 00119 * the file and its hadlink, leading to different FSAL handle. This would 00120 * mess up the cache a lot. Because of this, the next two lines are commented */ 00121 00122 //h ^= p_handle->data.ns_handle.Generation; 00123 //HASH_INCR(h, index_size); 00124 h ^= objid; 00125 HASH_INCR(h, index_size); 00126 h ^= p_handle->data.ns_handle.CoreServerUUID.time_low; 00127 HASH_INCR(h, index_size); 00128 h ^= p_handle->data.ns_handle.CoreServerUUID.time_mid; 00129 HASH_INCR(h, index_size); 00130 h ^= p_handle->data.ns_handle.CoreServerUUID.time_hi_and_version; 00131 HASH_INCR(h, index_size); 00132 h ^= p_handle->data.ns_handle.CoreServerUUID.clock_seq_hi_and_reserved; 00133 HASH_INCR(h, index_size); 00134 h ^= p_handle->data.ns_handle.CoreServerUUID.clock_seq_low; 00135 HASH_INCR(h, index_size); 00136 00137 for(i = 0; i < 6; i++) 00138 { 00139 h ^= p_handle->data.ns_handle.CoreServerUUID.node[i]; 00140 HASH_INCR(h, index_size); 00141 } 00142 00143 return h % index_size; 00144 00145 } 00146 00147 /* 00148 * FSAL_Handle_to_RBTIndex 00149 * This function is used for generating a RBT node ID 00150 * in order to identify entries into the RBT. 00151 * 00152 * \param p_handle The handle to be hashed 00153 * \param cookie Makes it possible to have different hash value for the 00154 * same handle, when cookie changes. 00155 * 00156 * \return The hash value 00157 */ 00158 00159 unsigned int HPSSFSAL_Handle_to_RBTIndex(hpssfsal_handle_t * p_handle, 00160 unsigned int cookie) 00161 { 00162 unsigned int h; 00163 unsigned int i; 00164 unsigned32 objid = hpss_GetObjId(&p_handle->data.ns_handle); 00165 00166 h = cookie; 00167 // h ^= p_handle->data.ns_handle.Generation << 1; /* Same reason as above */ 00168 h ^= objid << 2; 00169 00170 h ^= p_handle->data.ns_handle.CoreServerUUID.time_low << 3; 00171 h ^= p_handle->data.ns_handle.CoreServerUUID.time_mid << 4; 00172 h ^= p_handle->data.ns_handle.CoreServerUUID.time_hi_and_version << 5; 00173 h ^= p_handle->data.ns_handle.CoreServerUUID.clock_seq_hi_and_reserved << 6; 00174 h ^= p_handle->data.ns_handle.CoreServerUUID.clock_seq_low << 7; 00175 00176 for(i = 0; i < 6; i++) 00177 { 00178 h ^= ((unsigned int)p_handle->data.ns_handle.CoreServerUUID.node[i]) << 8 + i; 00179 } 00180 00181 return h; 00182 } 00183 00201 fsal_status_t HPSSFSAL_DigestHandle(hpssfsal_export_context_t * p_expcontext, /* IN */ 00202 fsal_digesttype_t output_type, /* IN */ 00203 hpssfsal_handle_t * in_fsal_handle, /* IN */ 00204 caddr_t out_buff /* OUT */ 00205 ) 00206 { 00207 int memlen; 00208 unsigned32 objid; /* to store objID */ 00209 fsal_u64_t objid64; /* to cast the objID */ 00210 fsal_nodetype_t nodetype; /* to store object type */ 00211 00212 /* sanity checks */ 00213 if(!in_fsal_handle || !out_buff || !p_expcontext) 00214 ReturnCode(ERR_FSAL_FAULT, 0); 00215 00216 switch (output_type) 00217 { 00218 00219 /* NFSV2 handle digest */ 00220 case FSAL_DIGEST_NFSV2: 00221 00222 /* min size for nfs handle digest. */ 00223 memlen = sizeof(ns_ObjHandle_t) - sizeof(TYPE_UUIDT); 00224 00225 /* The hpss handle must be converted 00226 * to a 25 bytes handle. To do so, 00227 * We copy all the fields from the hpss handle, 00228 * except the Coreserver ID. 00229 */ 00230 00231 #ifndef _NO_CHECKS 00232 00233 /* sanity check about output size */ 00234 00235 if(memlen > FSAL_DIGEST_SIZE_HDLV2) 00236 ReturnCode(ERR_FSAL_TOOSMALL, 0); 00237 00238 #endif 00239 00240 /* sanity check about core server ID */ 00241 00242 if(memcmp(&in_fsal_handle->data.ns_handle.CoreServerUUID, 00243 &p_expcontext->fileset_root_handle.CoreServerUUID, sizeof(TYPE_UUIDT))) 00244 { 00245 char buffer[128]; 00246 snprintmem(buffer, 128, (caddr_t) & (in_fsal_handle->data.ns_handle.CoreServerUUID), 00247 sizeof(TYPE_UUIDT)); 00248 LogMajor(COMPONENT_FSAL, 00249 "Invalid CoreServerUUID in HPSS handle: %s", buffer); 00250 } 00251 00252 /* building digest : 00253 * - fill it with zeros 00254 * - setting the first bytes to the fsal_handle value 00255 * (except CoreServerUUID) 00256 */ 00257 memset(out_buff, 0, FSAL_DIGEST_SIZE_HDLV2); 00258 memcpy(out_buff, &(in_fsal_handle->data.ns_handle), memlen); 00259 00260 break; 00261 00262 /* NFSV3 handle digest */ 00263 case FSAL_DIGEST_NFSV3: 00264 00265 #ifdef _STRIP_CORESERVER_UUID 00266 memlen = sizeof(ns_ObjHandle_t) - sizeof(TYPE_UUIDT); 00267 #else /* store the whole HPSS handle in the NFS handle */ 00268 memlen = sizeof(ns_ObjHandle_t); 00269 #endif 00270 00271 /* sanity check about output size */ 00272 if(memlen > FSAL_DIGEST_SIZE_HDLV3) 00273 ReturnCode(ERR_FSAL_TOOSMALL, 0); 00274 00275 /* sanity check about core server ID */ 00276 00277 #ifdef _STRIP_CORESERVER_UUID 00278 if(memcmp(&in_fsal_handle->data.ns_handle.CoreServerUUID, 00279 &p_expcontext->fileset_root_handle.CoreServerUUID, sizeof(TYPE_UUIDT))) 00280 { 00281 char buffer[128]; 00282 snprintmem(buffer, 128, (caddr_t) & (in_fsal_handle->data.ns_handle.CoreServerUUID), 00283 sizeof(TYPE_UUIDT)); 00284 LogMajor(COMPONENT_FSAL, 00285 "Invalid CoreServerUUID in HPSS handle: %s", buffer); 00286 } 00287 #endif 00288 00289 /* building digest : 00290 * - fill it with zeros 00291 * - setting the first bytes to the fsal_handle value 00292 */ 00293 memset(out_buff, 0, FSAL_DIGEST_SIZE_HDLV3); 00294 memcpy(out_buff, &(in_fsal_handle->data.ns_handle), memlen); 00295 00296 break; 00297 00298 /* NFSV4 handle digest */ 00299 case FSAL_DIGEST_NFSV4: 00300 00301 #ifdef _STRIP_CORESERVER_UUID 00302 memlen = sizeof(ns_ObjHandle_t) - sizeof(TYPE_UUIDT); 00303 #else /* store the whole HPSS handle in the NFS handle */ 00304 memlen = sizeof(ns_ObjHandle_t); 00305 #endif 00306 00307 /* sanity check about output size */ 00308 if(memlen > FSAL_DIGEST_SIZE_HDLV4) 00309 ReturnCode(ERR_FSAL_TOOSMALL, 0); 00310 00311 /* sanity check about core server ID */ 00312 #ifdef _STRIP_CORESERVER_UUID 00313 if(memcmp(&in_fsal_handle->data.ns_handle.CoreServerUUID, 00314 &p_expcontext->fileset_root_handle.CoreServerUUID, sizeof(TYPE_UUIDT))) 00315 { 00316 char buffer[128]; 00317 snprintmem(buffer, 128, (caddr_t) & (in_fsal_handle->data.ns_handle.CoreServerUUID), 00318 sizeof(TYPE_UUIDT)); 00319 LogMajor(COMPONENT_FSAL, 00320 "Invalid CoreServerUUID in HPSS handle: %s", buffer); 00321 } 00322 #endif 00323 00324 /* building digest : 00325 * - fill it with zeros 00326 * - setting the first bytes to the fsal_handle value 00327 */ 00328 memset(out_buff, 0, FSAL_DIGEST_SIZE_HDLV4); 00329 memcpy(out_buff, &(in_fsal_handle->data.ns_handle), memlen); 00330 00331 break; 00332 00333 /* FileId digest for NFSv2 */ 00334 case FSAL_DIGEST_FILEID2: 00335 00336 /* get object ID from handle */ 00337 objid = hpss_GetObjId(&in_fsal_handle->data.ns_handle); 00338 00339 #ifndef _NO_CHECKS 00340 00341 /* sanity check about output size */ 00342 00343 if(sizeof(unsigned32) > FSAL_DIGEST_SIZE_FILEID2) 00344 ReturnCode(ERR_FSAL_TOOSMALL, 0); 00345 00346 #endif 00347 00348 memset(out_buff, 0, FSAL_DIGEST_SIZE_FILEID2); 00349 memcpy(out_buff, &objid, sizeof(unsigned32)); 00350 00351 break; 00352 00353 /* FileId digest for NFSv3 */ 00354 case FSAL_DIGEST_FILEID3: 00355 00356 /* get object ID from handle */ 00357 objid64 = hpss_GetObjId(&in_fsal_handle->data.ns_handle); 00358 00359 #ifndef _NO_CHECKS 00360 00361 /* sanity check about output size */ 00362 00363 if(sizeof(fsal_u64_t) > FSAL_DIGEST_SIZE_FILEID3) 00364 ReturnCode(ERR_FSAL_TOOSMALL, 0); 00365 00366 #endif 00367 00368 memset(out_buff, 0, FSAL_DIGEST_SIZE_FILEID3); 00369 memcpy(out_buff, &objid64, sizeof(fsal_u64_t)); 00370 break; 00371 00372 /* FileId digest for NFSv4 */ 00373 00374 case FSAL_DIGEST_FILEID4: 00375 /* get object ID from handle */ 00376 objid64 = hpss_GetObjId(&in_fsal_handle->data.ns_handle); 00377 00378 #ifndef _NO_CHECKS 00379 00380 /* sanity check about output size */ 00381 00382 if(sizeof(fsal_u64_t) > FSAL_DIGEST_SIZE_FILEID4) 00383 ReturnCode(ERR_FSAL_TOOSMALL, 0); 00384 00385 #endif 00386 00387 memset(out_buff, 0, FSAL_DIGEST_SIZE_FILEID4); 00388 memcpy(out_buff, &objid64, sizeof(fsal_u64_t)); 00389 break; 00390 00391 /* Nodetype digest. */ 00392 case FSAL_DIGEST_NODETYPE: 00393 00394 nodetype = in_fsal_handle->data.obj_type; 00395 00396 #ifndef _NO_CHECKS 00397 00398 /* sanity check about output size */ 00399 00400 if(sizeof(fsal_nodetype_t) > FSAL_DIGEST_SIZE_NODETYPE) 00401 ReturnCode(ERR_FSAL_TOOSMALL, 0); 00402 00403 #endif 00404 00405 memset(out_buff, 0, FSAL_DIGEST_SIZE_NODETYPE); 00406 memcpy(out_buff, &nodetype, sizeof(fsal_nodetype_t)); 00407 00408 break; 00409 00410 default: 00411 ReturnCode(ERR_FSAL_SERVERFAULT, 0); 00412 } 00413 00414 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00415 00416 } 00417 00433 fsal_status_t HPSSFSAL_ExpandHandle(hpssfsal_export_context_t * p_expcontext, /* IN */ 00434 fsal_digesttype_t in_type, /* IN */ 00435 caddr_t in_buff, /* IN */ 00436 hpssfsal_handle_t * out_fsal_handle /* OUT */ 00437 ) 00438 { 00439 00440 /* significant size in nfs digests */ 00441 int memlen; 00442 00443 /* sanity checks */ 00444 if(!out_fsal_handle || !in_buff || !p_expcontext) 00445 ReturnCode(ERR_FSAL_FAULT, 0); 00446 00447 switch (in_type) 00448 { 00449 00450 case FSAL_DIGEST_NFSV2: 00451 /* core server UUID is always stripped for NFSv2 handles */ 00452 memlen = sizeof(ns_ObjHandle_t) - sizeof(TYPE_UUIDT); 00453 00454 memset(out_fsal_handle, 0, sizeof(out_fsal_handle->data)); 00455 memcpy(&out_fsal_handle->data.ns_handle, in_buff, memlen); 00456 00457 memcpy(&out_fsal_handle->data.ns_handle.CoreServerUUID, 00458 &p_expcontext->fileset_root_handle.CoreServerUUID, sizeof(TYPE_UUIDT)); 00459 00460 out_fsal_handle->data.obj_type = hpss2fsal_type(out_fsal_handle->data.ns_handle.Type); 00461 00462 break; 00463 00464 case FSAL_DIGEST_NFSV3: 00465 00466 #ifdef _STRIP_CORESERVER_UUID 00467 memlen = sizeof(ns_ObjHandle_t) - sizeof(TYPE_UUIDT); 00468 #else 00469 memlen = sizeof(ns_ObjHandle_t); 00470 #endif 00471 memset(out_fsal_handle, 0, sizeof(out_fsal_handle->data)); 00472 memcpy(&out_fsal_handle->data.ns_handle, in_buff, memlen); 00473 00474 #ifdef _STRIP_CORESERVER_UUID 00475 memcpy(&out_fsal_handle->data.ns_handle.CoreServerUUID, 00476 &p_expcontext->fileset_root_handle.CoreServerUUID, sizeof(TYPE_UUIDT)); 00477 #endif 00478 00479 out_fsal_handle->data.obj_type = hpss2fsal_type(out_fsal_handle->data.ns_handle.Type); 00480 00481 break; 00482 00483 case FSAL_DIGEST_NFSV4: 00484 00485 #ifdef _STRIP_CORESERVER_UUID 00486 memlen = sizeof(ns_ObjHandle_t) - sizeof(TYPE_UUIDT); 00487 #else 00488 memlen = sizeof(ns_ObjHandle_t); 00489 #endif 00490 00491 memset(out_fsal_handle, 0, sizeof(out_fsal_handle->data)); 00492 memcpy(&out_fsal_handle->data.ns_handle, in_buff, memlen); 00493 00494 #ifdef _STRIP_CORESERVER_UUID 00495 memcpy(&out_fsal_handle->data.ns_handle.CoreServerUUID, 00496 &p_expcontext->fileset_root_handle.CoreServerUUID, sizeof(TYPE_UUIDT)); 00497 #endif 00498 00499 out_fsal_handle->data.obj_type = hpss2fsal_type(out_fsal_handle->data.ns_handle.Type); 00500 00501 break; 00502 00503 default: 00504 /* Invalid input digest type. */ 00505 ReturnCode(ERR_FSAL_INVAL, 0); 00506 } 00507 00508 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00509 00510 } 00511 00519 fsal_status_t HPSSFSAL_SetDefault_FSAL_parameter(fsal_parameter_t * out_parameter) 00520 { 00521 00522 /* defensive programming... */ 00523 if(out_parameter == NULL) 00524 ReturnCode(ERR_FSAL_FAULT, 0); 00525 00526 00527 /* init max FS calls = unlimited */ 00528 out_parameter->fsal_info.max_fs_calls = 0; 00529 00530 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00531 00532 } 00533 00534 fsal_status_t HPSSFSAL_SetDefault_FS_common_parameter(fsal_parameter_t * out_parameter) 00535 { 00536 /* defensive programming... */ 00537 if(out_parameter == NULL) 00538 ReturnCode(ERR_FSAL_FAULT, 0); 00539 00540 /* set default values for all parameters of fs_common_info */ 00541 00542 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxfilesize); 00543 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxlink); 00544 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxnamelen); 00545 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxpathlen); 00546 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, no_trunc); 00547 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, chown_restricted); 00548 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, case_insensitive); 00549 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, case_preserving); 00550 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, fh_expire_type); 00551 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, link_support); 00552 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, symlink_support); 00553 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, named_attr); 00554 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, unique_handles); 00555 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, lease_time); 00556 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, acl_support); 00557 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, cansettime); 00558 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, homogenous); 00559 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, supported_attrs); 00560 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxread); 00561 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxwrite); 00562 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, umask); 00563 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, auth_exportpath_xdev); 00564 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, xattr_access_rights); 00565 00566 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00567 00568 } 00569 00570 fsal_status_t HPSSFSAL_SetDefault_FS_specific_parameter(fsal_parameter_t * out_parameter) 00571 { 00572 /* defensive programming... */ 00573 if(out_parameter == NULL) 00574 ReturnCode(ERR_FSAL_FAULT, 0); 00575 00576 /* set default values for all parameters of fs_specific_info */ 00577 00578 #if HPSS_MAJOR_VERSION == 5 00579 00580 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, PrincipalName); 00581 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, KeytabPath); 00582 00583 #elif HPSS_MAJOR_VERSION >= 6 00584 00585 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, AuthnMech); 00586 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, NumRetries); 00587 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, BusyDelay); 00588 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, BusyRetries); 00589 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, MaxConnections); 00590 00591 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, DebugPath); 00592 00593 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, Principal); 00594 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, KeytabPath); 00595 00596 #endif 00597 00598 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, CredentialLifetime); 00599 FSAL_SET_INIT_DEFAULT(out_parameter->fs_specific_info, ReturnInconsistentDirent); 00600 00601 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00602 00603 } 00604 00626 /* load FSAL init info */ 00627 00628 fsal_status_t HPSSFSAL_load_FSAL_parameter_from_conf(config_file_t in_config, 00629 fsal_parameter_t * out_parameter) 00630 { 00631 int err; 00632 int var_max, var_index; 00633 char *key_name; 00634 char *key_value; 00635 config_item_t block; 00636 00637 int DebugLevel = -1; 00638 char *LogFile = NULL; 00639 00640 block = config_FindItemByName(in_config, CONF_LABEL_FSAL); 00641 00642 /* cannot read item */ 00643 00644 if(block == NULL) 00645 { 00646 LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: Cannot read item \"%s\" from configuration file", 00647 CONF_LABEL_FSAL); 00648 ReturnCode(ERR_FSAL_NOENT, 0); 00649 } 00650 else if(config_ItemType(block) != CONFIG_ITEM_BLOCK) 00651 { 00652 LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: Item \"%s\" is expected to be a block", 00653 CONF_LABEL_FSAL); 00654 ReturnCode(ERR_FSAL_INVAL, 0); 00655 } 00656 00657 /* read variable for fsal init */ 00658 00659 var_max = config_GetNbItems(block); 00660 00661 for(var_index = 0; var_index < var_max; var_index++) 00662 { 00663 config_item_t item; 00664 00665 item = config_GetItemByIndex(block, var_index); 00666 00667 err = config_GetKeyValue(item, &key_name, &key_value); 00668 if(err) 00669 { 00670 LogCrit(COMPONENT_FSAL, 00671 "FSAL LOAD PARAMETER: ERROR reading key[%d] from section \"%s\" of configuration file.", 00672 var_index, CONF_LABEL_FSAL); 00673 ReturnCode(ERR_FSAL_SERVERFAULT, err); 00674 } 00675 00676 if(!STRCMP(key_name, "DebugLevel")) 00677 { 00678 DebugLevel = ReturnLevelAscii(key_value); 00679 00680 if(DebugLevel == -1) 00681 { 00682 LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: ERROR: Invalid debug level name: \"%s\".", 00683 key_value); 00684 ReturnCode(ERR_FSAL_INVAL, -1); 00685 } 00686 00687 } 00688 else if(!STRCMP(key_name, "LogFile")) 00689 { 00690 00691 LogFile = key_value; 00692 00693 } 00694 else if(!STRCMP(key_name, "Max_FS_calls")) 00695 { 00696 00697 int maxcalls = s_read_int(key_value); 00698 00699 if(maxcalls < 0) 00700 { 00701 LogCrit(COMPONENT_FSAL, 00702 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: null or positive integer expected.", 00703 key_name); 00704 ReturnCode(ERR_FSAL_INVAL, 0); 00705 } 00706 00707 out_parameter->fsal_info.max_fs_calls = (unsigned int)maxcalls; 00708 00709 } 00710 else 00711 { 00712 LogCrit(COMPONENT_FSAL, 00713 "FSAL LOAD PARAMETER: ERROR: Unknown or unsettable key: %s (item %s)", 00714 key_name, CONF_LABEL_FSAL); 00715 ReturnCode(ERR_FSAL_INVAL, 0); 00716 } 00717 00718 } 00719 00720 /* init logging */ 00721 if(LogFile) 00722 SetComponentLogFile(COMPONENT_FSAL, LogFile); 00723 00724 if(DebugLevel != -1) 00725 SetComponentLogLevel(COMPONENT_FSAL, DebugLevel); 00726 00727 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00728 00729 } /* FSAL_load_FSAL_parameter_from_conf */ 00730 00731 /* load general filesystem configuration options */ 00732 00733 fsal_status_t HPSSFSAL_load_FS_common_parameter_from_conf(config_file_t in_config, 00734 fsal_parameter_t * 00735 out_parameter) 00736 { 00737 int err; 00738 int var_max, var_index; 00739 char *key_name; 00740 char *key_value; 00741 config_item_t block; 00742 00743 block = config_FindItemByName(in_config, CONF_LABEL_FS_COMMON); 00744 00745 /* cannot read item */ 00746 if(block == NULL) 00747 { 00748 LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: Cannot read item \"%s\" from configuration file", 00749 CONF_LABEL_FS_COMMON); 00750 ReturnCode(ERR_FSAL_NOENT, 0); 00751 } 00752 else if(config_ItemType(block) != CONFIG_ITEM_BLOCK) 00753 { 00754 LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: Item \"%s\" is expected to be a block", 00755 CONF_LABEL_FS_COMMON); 00756 ReturnCode(ERR_FSAL_INVAL, 0); 00757 } 00758 00759 /* 00760 configurable common info for filesystem are: 00761 link_support # hardlink support 00762 symlink_support # symlinks support 00763 cansettime # Is it possible to change file times 00764 maxread # Max read size from FS 00765 maxwrite # Max write size to FS 00766 umask 00767 auth_exportpath_xdev 00768 xattr_access_rights 00769 */ 00770 00771 var_max = config_GetNbItems(block); 00772 00773 for(var_index = 0; var_index < var_max; var_index++) 00774 { 00775 config_item_t item; 00776 00777 item = config_GetItemByIndex(block, var_index); 00778 00779 err = config_GetKeyValue(item, &key_name, &key_value); 00780 if(err) 00781 { 00782 LogCrit(COMPONENT_FSAL, 00783 "FSAL LOAD PARAMETER: ERROR reading key[%d] from section \"%s\" of configuration file.", 00784 var_index, CONF_LABEL_FS_COMMON); 00785 ReturnCode(ERR_FSAL_SERVERFAULT, err); 00786 } 00787 00788 /* does the variable exists ? */ 00789 if(!STRCMP(key_name, "link_support")) 00790 { 00791 00792 int bool = StrToBoolean(key_value); 00793 00794 if(bool == -1) 00795 { 00796 LogCrit(COMPONENT_FSAL, 00797 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: boolean expected.", 00798 key_name); 00799 ReturnCode(ERR_FSAL_INVAL, 0); 00800 } 00801 00802 /* if set to false, force value to false. 00803 * else keep fs default. 00804 */ 00805 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, link_support, 00806 FSAL_INIT_MAX_LIMIT, bool); 00807 00808 } 00809 else if(!STRCMP(key_name, "symlink_support")) 00810 { 00811 int bool = StrToBoolean(key_value); 00812 00813 if(bool == -1) 00814 { 00815 LogCrit(COMPONENT_FSAL, 00816 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: boolean expected.", 00817 key_name); 00818 ReturnCode(ERR_FSAL_INVAL, 0); 00819 } 00820 00821 /* if set to false, force value to false. 00822 * else keep fs default. 00823 */ 00824 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, symlink_support, 00825 FSAL_INIT_MAX_LIMIT, bool); 00826 } 00827 else if(!STRCMP(key_name, "cansettime")) 00828 { 00829 int bool = StrToBoolean(key_value); 00830 00831 if(bool == -1) 00832 { 00833 LogCrit(COMPONENT_FSAL, 00834 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: boolean expected.", 00835 key_name); 00836 ReturnCode(ERR_FSAL_INVAL, 0); 00837 } 00838 00839 /* if set to false, force value to false. 00840 * else keep fs default. 00841 */ 00842 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, cansettime, 00843 FSAL_INIT_MAX_LIMIT, bool); 00844 00845 } 00846 else if(!STRCMP(key_name, "maxread")) 00847 { 00848 fsal_u64_t size; 00849 00850 if(s_read_int64(key_value, &size)) 00851 { 00852 LogCrit(COMPONENT_FSAL, 00853 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: positive integer expected.", 00854 key_name); 00855 ReturnCode(ERR_FSAL_INVAL, 0); 00856 } 00857 00858 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, maxread, 00859 FSAL_INIT_FORCE_VALUE, size); 00860 00861 } 00862 else if(!STRCMP(key_name, "maxwrite")) 00863 { 00864 fsal_u64_t size; 00865 00866 if(s_read_int64(key_value, &size)) 00867 { 00868 LogCrit(COMPONENT_FSAL, 00869 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: positive integer expected.", 00870 key_name); 00871 ReturnCode(ERR_FSAL_INVAL, 0); 00872 } 00873 00874 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, maxwrite, 00875 FSAL_INIT_FORCE_VALUE, size); 00876 00877 } 00878 else if(!STRCMP(key_name, "umask")) 00879 { 00880 int mode = s_read_octal(key_value); 00881 00882 if(mode < 0) 00883 { 00884 LogCrit(COMPONENT_FSAL, 00885 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: octal expected.", 00886 key_name); 00887 ReturnCode(ERR_FSAL_INVAL, 0); 00888 } 00889 00890 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, umask, 00891 FSAL_INIT_FORCE_VALUE, unix2fsal_mode(mode)); 00892 00893 } 00894 else if(!STRCMP(key_name, "auth_xdev_export")) 00895 { 00896 int bool = StrToBoolean(key_value); 00897 00898 if(bool == -1) 00899 { 00900 LogCrit(COMPONENT_FSAL, 00901 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: boolean expected.", 00902 key_name); 00903 ReturnCode(ERR_FSAL_INVAL, 0); 00904 } 00905 00906 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, auth_exportpath_xdev, 00907 FSAL_INIT_FORCE_VALUE, bool); 00908 } 00909 else if(!STRCMP(key_name, "xattr_access_rights")) 00910 { 00911 int mode = s_read_octal(key_value); 00912 00913 if(mode < 0) 00914 { 00915 LogCrit(COMPONENT_FSAL, 00916 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: octal expected.", 00917 key_name); 00918 ReturnCode(ERR_FSAL_INVAL, 0); 00919 } 00920 00921 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, xattr_access_rights, 00922 FSAL_INIT_FORCE_VALUE, unix2fsal_mode(mode)); 00923 00924 } 00925 else 00926 { 00927 LogCrit(COMPONENT_FSAL, 00928 "FSAL LOAD PARAMETER: ERROR: Unknown or unsettable key: %s (item %s)", 00929 key_name, CONF_LABEL_FS_COMMON); 00930 ReturnCode(ERR_FSAL_INVAL, 0); 00931 } 00932 00933 } 00934 00935 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00936 00937 } /* FSAL_load_FS_common_parameter_from_conf */ 00938 00939 /* load specific filesystem configuration options */ 00940 00941 fsal_status_t HPSSFSAL_load_FS_specific_parameter_from_conf(config_file_t in_config, 00942 fsal_parameter_t * 00943 out_parameter) 00944 { 00945 int err; 00946 int var_max, var_index; 00947 char *key_name; 00948 char *key_value; 00949 config_item_t block; 00950 00951 block = config_FindItemByName(in_config, CONF_LABEL_FS_SPECIFIC); 00952 00953 /* cannot read item */ 00954 if(block == NULL) 00955 { 00956 LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: Cannot read item \"%s\" from configuration file", 00957 CONF_LABEL_FS_SPECIFIC); 00958 ReturnCode(ERR_FSAL_NOENT, 0); 00959 } 00960 else if(config_ItemType(block) != CONFIG_ITEM_BLOCK) 00961 { 00962 LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: Item \"%s\" is expected to be a block", 00963 CONF_LABEL_FS_SPECIFIC); 00964 ReturnCode(ERR_FSAL_INVAL, 0); 00965 } 00966 00967 var_max = config_GetNbItems(block); 00968 00969 for(var_index = 0; var_index < var_max; var_index++) 00970 { 00971 config_item_t item; 00972 00973 item = config_GetItemByIndex(block, var_index); 00974 00975 err = config_GetKeyValue(item, &key_name, &key_value); 00976 if(err) 00977 { 00978 LogCrit(COMPONENT_FSAL, 00979 "FSAL LOAD PARAMETER: ERROR reading key[%d] from section \"%s\" of configuration file.", 00980 var_index, CONF_LABEL_FS_SPECIFIC); 00981 ReturnCode(ERR_FSAL_SERVERFAULT, err); 00982 } 00983 #if HPSS_MAJOR_VERSION == 5 00984 /* does the variable exists ? */ 00985 if(!STRCMP(key_name, "PrincipalName")) 00986 { 00987 00988 out_parameter->fs_specific_info.behaviors.PrincipalName = FSAL_INIT_FORCE_VALUE; 00989 strcpy(out_parameter->fs_specific_info.hpss_config.PrincipalName, key_value); 00990 00991 } 00992 else if(!STRCMP(key_name, "KeytabPath")) 00993 { 00994 00995 out_parameter->fs_specific_info.behaviors.KeytabPath = FSAL_INIT_FORCE_VALUE; 00996 strcpy(out_parameter->fs_specific_info.hpss_config.KeytabPath, key_value); 00997 00998 } 00999 #else 01000 /* does the variable exists ? */ 01001 if(!STRCMP(key_name, "PrincipalName")) 01002 { 01003 out_parameter->fs_specific_info.behaviors.Principal = FSAL_INIT_FORCE_VALUE; 01004 strcpy(out_parameter->fs_specific_info.Principal, key_value); 01005 01006 } 01007 else if(!STRCMP(key_name, "KeytabPath")) 01008 { 01009 out_parameter->fs_specific_info.behaviors.KeytabPath = FSAL_INIT_FORCE_VALUE; 01010 strcpy(out_parameter->fs_specific_info.KeytabPath, key_value); 01011 } 01012 else if(!STRCMP(key_name, "AuthMech")) 01013 { 01014 int error; 01015 01016 out_parameter->fs_specific_info.behaviors.AuthnMech = FSAL_INIT_FORCE_VALUE; 01017 01018 error = hpss_AuthnMechTypeFromString(key_value, 01019 &out_parameter->fs_specific_info. 01020 hpss_config.AuthnMech); 01021 01022 if(error != HPSS_E_NOERROR) 01023 { 01024 LogCrit(COMPONENT_FSAL,"FSAL LOAD PARAMETER: ERROR: Unexpected value for %s.", 01025 key_name); 01026 ReturnCode(ERR_FSAL_INVAL, error); 01027 } 01028 01029 } 01030 else if(!STRCMP(key_name, "BusyDelay")) 01031 { 01032 int busydelay = s_read_int(key_value); 01033 01034 if(busydelay < 0) 01035 { 01036 LogCrit(COMPONENT_FSAL, 01037 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: positive integer expected.", 01038 key_name); 01039 ReturnCode(ERR_FSAL_INVAL, 0); 01040 } 01041 01042 out_parameter->fs_specific_info.behaviors.BusyDelay = FSAL_INIT_FORCE_VALUE; 01043 out_parameter->fs_specific_info.hpss_config.BusyDelay = busydelay; 01044 } 01045 else if(!STRCMP(key_name, "BusyRetries")) 01046 { 01047 int busyretries; 01048 01049 if(key_value[0] == '-') 01050 { 01051 busyretries = s_read_int((char *)(key_value + 1)); 01052 if(busyretries < 0) 01053 { 01054 LogCrit(COMPONENT_FSAL, 01055 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: integer expected.", 01056 key_name); 01057 ReturnCode(ERR_FSAL_INVAL, 0); 01058 } 01059 busyretries = -busyretries; 01060 } 01061 else 01062 { 01063 busyretries = s_read_int(key_value); 01064 01065 if(busyretries < 0) 01066 { 01067 LogCrit(COMPONENT_FSAL, 01068 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: integer expected.", 01069 key_name); 01070 ReturnCode(ERR_FSAL_INVAL, 0); 01071 } 01072 } 01073 01074 out_parameter->fs_specific_info.behaviors.BusyRetries = FSAL_INIT_FORCE_VALUE; 01075 out_parameter->fs_specific_info.hpss_config.BusyRetries = busyretries; 01076 } 01077 else if(!STRCMP(key_name, "NumRetries")) 01078 { 01079 int numretries; 01080 01081 if(key_value[0] == '-') 01082 { 01083 numretries = s_read_int((char *)(key_value + 1)); 01084 if(numretries < 0) 01085 { 01086 LogCrit(COMPONENT_FSAL, 01087 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: integer expected.", 01088 key_name); 01089 ReturnCode(ERR_FSAL_INVAL, 0); 01090 } 01091 numretries = -numretries; 01092 } 01093 else 01094 { 01095 numretries = s_read_int(key_value); 01096 01097 if(numretries < 0) 01098 { 01099 LogCrit(COMPONENT_FSAL, 01100 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: integer expected.", 01101 key_name); 01102 ReturnCode(ERR_FSAL_INVAL, 0); 01103 } 01104 } 01105 01106 out_parameter->fs_specific_info.behaviors.NumRetries = FSAL_INIT_FORCE_VALUE; 01107 out_parameter->fs_specific_info.hpss_config.NumRetries = numretries; 01108 } 01109 else if(!STRCMP(key_name, "MaxConnections")) 01110 { 01111 int maxconn = s_read_int(key_value); 01112 01113 if(maxconn < 0) 01114 { 01115 LogCrit(COMPONENT_FSAL, 01116 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: positive integer expected.", 01117 key_name); 01118 ReturnCode(ERR_FSAL_INVAL, 0); 01119 } 01120 01121 out_parameter->fs_specific_info.behaviors.MaxConnections 01122 = FSAL_INIT_FORCE_VALUE; 01123 out_parameter->fs_specific_info.hpss_config.MaxConnections = maxconn; 01124 } 01125 else if(!STRCMP(key_name, "DebugPath")) 01126 { 01127 out_parameter->fs_specific_info.behaviors.DebugPath = FSAL_INIT_FORCE_VALUE; 01128 strcpy(out_parameter->fs_specific_info.hpss_config.DebugPath, key_value); 01129 } 01130 #endif 01131 else if(!STRCMP(key_name, "CredentialLifetime")) 01132 { 01133 int cred_life = s_read_int(key_value); 01134 01135 if(cred_life < 1) 01136 { 01137 LogCrit(COMPONENT_FSAL, 01138 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: positive integer expected.", 01139 key_name); 01140 ReturnCode(ERR_FSAL_INVAL, 0); 01141 } 01142 01143 out_parameter->fs_specific_info.behaviors.CredentialLifetime 01144 = FSAL_INIT_FORCE_VALUE; 01145 out_parameter->fs_specific_info.CredentialLifetime = (fsal_uint_t) cred_life; 01146 } 01147 else if(!STRCMP(key_name, "ReturnInconsistentDirent")) 01148 { 01149 int bool = StrToBoolean(key_value); 01150 01151 if(bool == -1) 01152 { 01153 LogCrit(COMPONENT_FSAL, 01154 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: boolean expected.", 01155 key_name); 01156 ReturnCode(ERR_FSAL_INVAL, 0); 01157 } 01158 01159 out_parameter->fs_specific_info.behaviors.ReturnInconsistentDirent 01160 = FSAL_INIT_FORCE_VALUE; 01161 out_parameter->fs_specific_info.ReturnInconsistentDirent = (fsal_uint_t) bool; 01162 } 01163 else 01164 { 01165 LogCrit(COMPONENT_FSAL, 01166 "FSAL LOAD PARAMETER: ERROR: Unknown or unsettable key: %s (item %s)", 01167 key_name, CONF_LABEL_FS_SPECIFIC); 01168 ReturnCode(ERR_FSAL_INVAL, 0); 01169 } 01170 01171 } 01172 01173 ReturnCode(ERR_FSAL_NO_ERROR, 0); 01174 01175 } /* FSAL_load_FS_specific_parameter_from_conf */