nfs-ganesha 1.4
|
00001 /* 00002 * Common FSAL methods 00003 */ 00004 00005 #ifdef HAVE_CONFIG_H 00006 #include "config.h" 00007 #endif 00008 00009 #define fsal_increment_nbcall( _f_,_struct_status_ ) 00010 00011 #include <sys/types.h> 00012 #include <stdint.h> 00013 #include <stddef.h> 00014 #include <stdlib.h> 00015 #include <errno.h> 00016 #include <string.h> 00017 #include <pthread.h> 00018 #include <sys/quota.h> 00019 #include "log.h" 00020 #include "fsal.h" 00021 #include "FSAL/common_methods.h" 00022 00023 00024 /* Methods shared by most/all fsals. 00025 * These are either used in place of or can be called from the fsal specific 00026 * method to handle common (base class) operations 00027 */ 00028 00029 /* Export context 00030 */ 00031 00040 fsal_status_t COMMON_CleanUpExportContext_noerror(fsal_export_context_t * p_export_context) 00041 { 00042 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_CleanUpExportContext); 00043 } 00044 00045 /* Client context */ 00046 00047 fsal_status_t COMMON_InitClientContext(fsal_op_context_t * p_thr_context) 00048 { 00049 /* sanity check */ 00050 if(!p_thr_context) 00051 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_InitClientContext); 00052 00053 /* initialy set the export entry to none */ 00054 p_thr_context->export_context = NULL; 00055 00056 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_InitClientContext); 00057 } 00058 00059 #ifndef _USE_HPSS 00060 fsal_status_t COMMON_GetClientContext(fsal_op_context_t * p_thr_context, /* IN/OUT */ 00061 fsal_export_context_t * p_export_context, /* IN */ 00062 fsal_uid_t uid, /* IN */ 00063 fsal_gid_t gid, /* IN */ 00064 fsal_gid_t * alt_groups, /* IN */ 00065 fsal_count_t nb_alt_groups /* IN */ ) 00066 { 00067 fsal_count_t ng = nb_alt_groups; 00068 unsigned int i; 00069 00070 /* sanity check */ 00071 if(!p_thr_context || !p_export_context || 00072 ((ng > 0) && (alt_groups == NULL))) 00073 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_GetClientContext); 00074 00075 /* set the export specific context */ 00076 p_thr_context->export_context = p_export_context; 00077 p_thr_context->credential.user = uid; 00078 p_thr_context->credential.group = gid; 00079 00080 if(ng > FSAL_NGROUPS_MAX) /* this artificially truncates the group list ! */ 00081 ng = FSAL_NGROUPS_MAX; 00082 p_thr_context->credential.nbgroups = ng; 00083 00084 for(i = 0; i < ng; i++) 00085 p_thr_context->credential.alt_groups[i] = alt_groups[i]; 00086 00087 if(isFullDebug(COMPONENT_FSAL)) { 00088 /* traces: prints p_credential structure */ 00089 00090 LogFullDebug(COMPONENT_FSAL, "credential modified:\tuid = %d, gid = %d", 00091 p_thr_context->credential.user, 00092 p_thr_context->credential.group); 00093 for(i = 0; i < p_thr_context->credential.nbgroups; i++) 00094 LogFullDebug(COMPONENT_FSAL, "\tAlt grp: %d", 00095 p_thr_context->credential.alt_groups[i]); 00096 } 00097 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_GetClientContext); 00098 } 00099 #endif 00100 00101 /* Access controls 00102 */ 00103 00128 fsal_status_t COMMON_setattr_access_notsupp(fsal_op_context_t * p_context, /* IN */ 00129 fsal_attrib_list_t * candidate_attributes, /* IN */ 00130 fsal_attrib_list_t * object_attributes /* IN */ 00131 ) 00132 { 00133 Return(ERR_FSAL_NOTSUPP, 0, INDEX_FSAL_setattr_access); 00134 } /* FSAL_test_setattr_access */ 00135 00153 fsal_status_t COMMON_rename_access(fsal_op_context_t * pcontext, /* IN */ 00154 fsal_attrib_list_t * pattrsrc, /* IN */ 00155 fsal_attrib_list_t * pattrdest) /* IN */ 00156 { 00157 fsal_status_t fsal_status; 00158 00159 fsal_status = FSAL_test_access(pcontext, FSAL_W_OK, pattrsrc); 00160 if(FSAL_IS_ERROR(fsal_status)) 00161 Return(fsal_status.major, fsal_status.minor, INDEX_FSAL_rename_access); 00162 00163 fsal_status = FSAL_test_access(pcontext, FSAL_W_OK, pattrdest); 00164 if(FSAL_IS_ERROR(fsal_status)) 00165 Return(fsal_status.major, fsal_status.minor, INDEX_FSAL_rename_access); 00166 00167 /* If this point is reached, then access is granted */ 00168 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_rename_access); 00169 } /* FSAL_rename_access */ 00170 00171 /* Not supported version 00172 */ 00173 00174 fsal_status_t COMMON_rename_access_notsupp(fsal_op_context_t * pcontext, /* IN */ 00175 fsal_attrib_list_t * pattrsrc, /* IN */ 00176 fsal_attrib_list_t * pattrdest) /* IN */ 00177 { 00178 Return(ERR_FSAL_NOTSUPP, 0, INDEX_FSAL_rename_access); 00179 } /* FSAL_rename_access */ 00180 00195 fsal_status_t COMMON_create_access(fsal_op_context_t * pcontext, /* IN */ 00196 fsal_attrib_list_t * pattr) /* IN */ 00197 { 00198 fsal_status_t fsal_status; 00199 00200 fsal_status = FSAL_test_access(pcontext, FSAL_W_OK, pattr); 00201 if(FSAL_IS_ERROR(fsal_status)) 00202 Return(fsal_status.major, fsal_status.minor, INDEX_FSAL_create_access); 00203 00204 /* If this point is reached, then access is granted */ 00205 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_create_access); 00206 } /* FSAL_create_access */ 00207 00222 fsal_status_t COMMON_unlink_access(fsal_op_context_t * pcontext, /* IN */ 00223 fsal_attrib_list_t * pattr) /* IN */ 00224 { 00225 fsal_status_t fsal_status; 00226 00227 fsal_status = FSAL_test_access(pcontext, FSAL_W_OK, pattr); 00228 if(FSAL_IS_ERROR(fsal_status)) 00229 Return(fsal_status.major, fsal_status.minor, INDEX_FSAL_unlink_access); 00230 00231 /* If this point is reached, then access is granted */ 00232 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_unlink_access); 00233 00234 } /* FSAL_unlink_access */ 00235 00251 fsal_status_t COMMON_link_access(fsal_op_context_t * pcontext, /* IN */ 00252 fsal_attrib_list_t * pattr) /* IN */ 00253 { 00254 fsal_status_t fsal_status; 00255 00256 fsal_status = FSAL_test_access(pcontext, FSAL_W_OK, pattr); 00257 if(FSAL_IS_ERROR(fsal_status)) 00258 Return(fsal_status.major, fsal_status.minor, INDEX_FSAL_unlink_access); 00259 00260 /* If this point is reached, then access is granted */ 00261 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_link_access); 00262 } /* FSAL_link_access */ 00263 00279 fsal_status_t COMMON_merge_attrs(fsal_attrib_list_t * pinit_attr, 00280 fsal_attrib_list_t * pnew_attr, 00281 fsal_attrib_list_t * presult_attr) 00282 { 00283 if(pinit_attr == NULL || pnew_attr == NULL || presult_attr == NULL) 00284 Return(ERR_FSAL_INVAL, 0, INDEX_FSAL_merge_attrs); 00285 00286 /* The basis for the result attr is the fist argument */ 00287 *presult_attr = *pinit_attr; 00288 00289 /* Now deal with the attributes to be merged in this set of attributes */ 00290 if(FSAL_TEST_MASK(pnew_attr->asked_attributes, FSAL_ATTR_MODE)) 00291 presult_attr->mode = pnew_attr->mode; 00292 00293 if(FSAL_TEST_MASK(pnew_attr->asked_attributes, FSAL_ATTR_OWNER)) 00294 presult_attr->owner = pnew_attr->owner; 00295 00296 if(FSAL_TEST_MASK(pnew_attr->asked_attributes, FSAL_ATTR_GROUP)) 00297 presult_attr->group = pnew_attr->group; 00298 00299 if(FSAL_TEST_MASK(pnew_attr->asked_attributes, FSAL_ATTR_SIZE)) 00300 presult_attr->filesize = pnew_attr->filesize; 00301 00302 if(FSAL_TEST_MASK(pnew_attr->asked_attributes, FSAL_ATTR_SPACEUSED)) 00303 presult_attr->spaceused = pnew_attr->spaceused; 00304 00305 if(FSAL_TEST_MASK(pnew_attr->asked_attributes, FSAL_ATTR_ATIME)) 00306 { 00307 presult_attr->atime.seconds = pnew_attr->atime.seconds; 00308 presult_attr->atime.nseconds = pnew_attr->atime.nseconds; 00309 } 00310 00311 if(FSAL_TEST_MASK(pnew_attr->asked_attributes, FSAL_ATTR_MTIME)) 00312 { 00313 presult_attr->mtime.seconds = pnew_attr->mtime.seconds; 00314 presult_attr->mtime.nseconds = pnew_attr->mtime.nseconds; 00315 } 00316 00317 /* Do not forget the ctime */ 00318 FSAL_SET_MASK(presult_attr->asked_attributes, FSAL_ATTR_CTIME); 00319 presult_attr->ctime.seconds = pnew_attr->ctime.seconds; 00320 presult_attr->ctime.nseconds = pnew_attr->ctime.nseconds; 00321 00322 /* Regular exit */ 00323 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_merge_attrs); 00324 } /* FSAL_merge_attrs */ 00325 00326 00327 /* Quota management 00328 */ 00329 00330 #if 0 00331 00349 fsal_status_t COMMON_get_quota(fsal_path_t * pfsal_path, /* IN */ 00350 int quota_type, /* IN */ 00351 fsal_uid_t fsal_uid, /* IN */ 00352 fsal_quota_t * pquota) /* OUT */ 00353 { 00354 struct dqblk fs_quota; 00355 char fs_spec[MAXPATHLEN]; 00356 00357 if(!pfsal_path || !pquota) 00358 ReturnCode(ERR_FSAL_FAULT, 0); 00359 00360 if(fsal_internal_path2fsname(pfsal_path->path, fs_spec) == -1) 00361 ReturnCode(ERR_FSAL_INVAL, 0); 00362 00363 memset((char *)&fs_quota, 0, sizeof(struct dqblk)); 00364 00365 if(quotactl(FSAL_QCMD(Q_GETQUOTA, quota_type), fs_spec, fsal_uid, (caddr_t) & fs_quota) 00366 < 0) 00367 ReturnCode(posix2fsal_error(errno), errno); 00368 00369 /* Convert XFS structure to FSAL one */ 00370 pquota->bhardlimit = fs_quota.dqb_bhardlimit; 00371 pquota->bsoftlimit = fs_quota.dqb_bsoftlimit; 00372 pquota->curblocks = fs_quota.dqb_curspace; 00373 pquota->fhardlimit = fs_quota.dqb_ihardlimit; 00374 pquota->curfiles = fs_quota.dqb_curinodes; 00375 pquota->btimeleft = fs_quota.dqb_btime; 00376 pquota->ftimeleft = fs_quota.dqb_itime; 00377 pquota->bsize = DEV_BSIZE; 00378 00379 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00380 } /* FSAL_get_quota */ 00381 00402 fsal_status_t COMMON_set_quota(fsal_path_t * pfsal_path, /* IN */ 00403 int quota_type, /* IN */ 00404 fsal_uid_t fsal_uid, /* IN */ 00405 fsal_quota_t * pquota, /* IN */ 00406 fsal_quota_t * presquota) /* OUT */ 00407 { 00408 struct dqblk fs_quota; 00409 fsal_status_t fsal_status; 00410 char fs_spec[MAXPATHLEN]; 00411 00412 if(!pfsal_path || !pquota) 00413 ReturnCode(ERR_FSAL_FAULT, 0); 00414 00415 if(fsal_internal_path2fsname(pfsal_path->path, fs_spec) == -1) 00416 ReturnCode(ERR_FSAL_INVAL, 0); 00417 00418 memset((char *)&fs_quota, 0, sizeof(struct dqblk)); 00419 00420 /* Convert FSAL structure to XFS one */ 00421 if(pquota->bhardlimit != 0) 00422 { 00423 fs_quota.dqb_bhardlimit = pquota->bhardlimit; 00424 fs_quota.dqb_valid |= QIF_BLIMITS; 00425 } 00426 00427 if(pquota->bsoftlimit != 0) 00428 { 00429 fs_quota.dqb_bsoftlimit = pquota->bsoftlimit; 00430 fs_quota.dqb_valid |= QIF_BLIMITS; 00431 } 00432 00433 if(pquota->fhardlimit != 0) 00434 { 00435 fs_quota.dqb_ihardlimit = pquota->fhardlimit; 00436 fs_quota.dqb_valid |= QIF_ILIMITS; 00437 } 00438 00439 if(pquota->btimeleft != 0) 00440 { 00441 fs_quota.dqb_btime = pquota->btimeleft; 00442 fs_quota.dqb_valid |= QIF_BTIME; 00443 } 00444 00445 if(pquota->ftimeleft != 0) 00446 { 00447 fs_quota.dqb_itime = pquota->ftimeleft; 00448 fs_quota.dqb_valid |= QIF_ITIME; 00449 } 00450 00451 if(quotactl(FSAL_QCMD(Q_SETQUOTA, quota_type), fs_spec, fsal_uid, (caddr_t) & fs_quota) 00452 < 0) 00453 ReturnCode(posix2fsal_error(errno), errno); 00454 00455 if(presquota != NULL) 00456 { 00457 fsal_status = FSAL_get_quota(pfsal_path, quota_type, fsal_uid, presquota); 00458 00459 if(FSAL_IS_ERROR(fsal_status)) 00460 return fsal_status; 00461 } 00462 00463 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00464 } /* FSAL_set_quota */ 00465 00466 #endif 00467 00468 /* No quota support case 00469 */ 00470 00486 fsal_status_t COMMON_get_quota_noquota(fsal_path_t * pfsal_path, /* IN */ 00487 int quota_type, fsal_uid_t fsal_uid, fsal_quota_t * pquota) /* OUT */ 00488 { 00489 ReturnCode(ERR_FSAL_NO_QUOTA, 0); 00490 } /* FSAL_get_quota */ 00491 00510 fsal_status_t COMMON_set_quota_noquota(fsal_path_t * pfsal_path, /* IN */ 00511 int quota_type, fsal_uid_t fsal_uid, /* IN */ 00512 fsal_quota_t * pquot, /* IN */ 00513 fsal_quota_t * presquot) /* OUT */ 00514 { 00515 ReturnCode(ERR_FSAL_NO_QUOTA, 0); 00516 } /* FSAL_set_quota */ 00517 00534 fsal_status_t COMMON_check_quota( char * pfsal_path, /* IN */ 00535 fsal_quota_type_t quota_type, 00536 fsal_uid_t fsal_uid) /* IN */ 00537 { 00538 ReturnCode(ERR_FSAL_NO_ERROR, 0) ; 00539 } /* COMMON_check_quota */ 00540 00541 /* Object Resources 00542 */ 00543 00553 fsal_status_t COMMON_CleanObjectResources(fsal_handle_t * in_fsal_handle) 00554 { 00555 00556 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_CleanObjectResources); 00557 00558 } 00559 00560 /* operation by file id. PROXY specific. 00561 */ 00562 00563 fsal_status_t COMMON_open_by_fileid(fsal_handle_t * filehandle, /* IN */ 00564 fsal_u64_t fileid, /* IN */ 00565 fsal_op_context_t * p_context, /* IN */ 00566 fsal_openflags_t openflags, /* IN */ 00567 fsal_file_t * file_descriptor, /* OUT */ 00568 fsal_attrib_list_t * file_attributes /* [ IN/OUT ] */ ) 00569 { 00570 Return(ERR_FSAL_NOTSUPP, 0, INDEX_FSAL_open_by_fileid); 00571 } 00572 00573 fsal_status_t COMMON_close_by_fileid(fsal_file_t * file_descriptor /* IN */ , 00574 fsal_u64_t fileid) 00575 { 00576 Return(ERR_FSAL_NOTSUPP, 0, INDEX_FSAL_open_by_fileid); 00577 } 00578 00598 fsal_status_t COMMON_getextattrs_notsupp(fsal_handle_t * p_filehandle, /* IN */ 00599 fsal_op_context_t * p_context, /* IN */ 00600 fsal_extattrib_list_t * p_object_attributes /* OUT */ 00601 ) 00602 { 00603 Return(ERR_FSAL_NOTSUPP, 0, INDEX_FSAL_getextattrs); 00604 } 00605 00606 /* 00607 * init/terminate 00608 */ 00609 00610 00611 /* To be called before exiting */ 00612 fsal_status_t COMMON_terminate_noerror() 00613 { 00614 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00615 } 00616 00617 /* Parameter management and initialization 00618 */ 00619 00628 #define STRCMP strcasecmp 00629 00630 fsal_status_t COMMON_SetDefault_FSAL_parameter(fsal_parameter_t * out_parameter) 00631 { 00632 /* defensive programming... */ 00633 if(out_parameter == NULL) 00634 ReturnCode(ERR_FSAL_FAULT, 0); 00635 00636 /* init max FS calls = unlimited */ 00637 out_parameter->fsal_info.max_fs_calls = 0; 00638 00639 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00640 } 00641 00642 fsal_status_t COMMON_SetDefault_FS_common_parameter(fsal_parameter_t * out_parameter) 00643 { 00644 /* defensive programming... */ 00645 if(out_parameter == NULL) 00646 ReturnCode(ERR_FSAL_FAULT, 0); 00647 00648 /* set default values for all parameters of fs_common_info */ 00649 00650 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxfilesize); 00651 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxlink); 00652 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxnamelen); 00653 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxpathlen); 00654 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, no_trunc); 00655 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, chown_restricted); 00656 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, case_insensitive); 00657 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, case_preserving); 00658 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, fh_expire_type); 00659 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, link_support); 00660 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, symlink_support); 00661 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, lock_support); 00662 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, lock_support_owner); 00663 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, lock_support_async_block); 00664 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, named_attr); 00665 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, unique_handles); 00666 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, lease_time); 00667 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, acl_support); 00668 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, cansettime); 00669 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, homogenous); 00670 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, supported_attrs); 00671 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxread); 00672 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, maxwrite); 00673 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, umask); 00674 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, auth_exportpath_xdev); 00675 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, xattr_access_rights); 00676 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, accesscheck_support); 00677 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, share_support); 00678 FSAL_SET_INIT_DEFAULT(out_parameter->fs_common_info, share_support_owner); 00679 00680 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00681 00682 } 00683 00705 fsal_status_t COMMON_load_FSAL_parameter_from_conf(config_file_t in_config, 00706 fsal_parameter_t * out_parameter) 00707 { 00708 int err; 00709 int var_max, var_index; 00710 char *key_name; 00711 char *key_value; 00712 config_item_t block; 00713 00714 int DebugLevel = -1; 00715 char *LogFile = NULL; 00716 00717 block = config_FindItemByName(in_config, CONF_LABEL_FSAL); 00718 00719 /* cannot read item */ 00720 00721 if(block == NULL) 00722 { 00723 LogCrit(COMPONENT_CONFIG, 00724 "FSAL LOAD PARAMETER: Cannot read item \"%s\" from configuration file", 00725 CONF_LABEL_FSAL); 00726 ReturnCode(ERR_FSAL_NOENT, 0); 00727 } 00728 else if(config_ItemType(block) != CONFIG_ITEM_BLOCK) 00729 { 00730 LogCrit(COMPONENT_CONFIG, 00731 "FSAL LOAD PARAMETER: Item \"%s\" is expected to be a block", 00732 CONF_LABEL_FSAL); 00733 ReturnCode(ERR_FSAL_INVAL, 0); 00734 } 00735 00736 /* read variable for fsal init */ 00737 00738 var_max = config_GetNbItems(block); 00739 00740 for(var_index = 0; var_index < var_max; var_index++) 00741 { 00742 config_item_t item; 00743 00744 item = config_GetItemByIndex(block, var_index); 00745 00746 err = config_GetKeyValue(item, &key_name, &key_value); 00747 if(err) 00748 { 00749 LogCrit(COMPONENT_CONFIG, 00750 "FSAL LOAD PARAMETER: ERROR reading key[%d] from section \"%s\" of configuration file.", 00751 var_index, CONF_LABEL_FSAL); 00752 ReturnCode(ERR_FSAL_SERVERFAULT, err); 00753 } 00754 00755 if(!STRCMP(key_name, "DebugLevel")) 00756 { 00757 DebugLevel = ReturnLevelAscii(key_value); 00758 00759 if(DebugLevel == -1) 00760 { 00761 LogCrit(COMPONENT_CONFIG, 00762 "FSAL LOAD PARAMETER: ERROR: Invalid debug level name: \"%s\".", 00763 key_value); 00764 ReturnCode(ERR_FSAL_INVAL, -1); 00765 } 00766 00767 } 00768 else if(!STRCMP(key_name, "LogFile")) 00769 { 00770 00771 LogFile = key_value; 00772 00773 } 00774 else if(!STRCMP(key_name, "Max_FS_calls")) 00775 { 00776 00777 int maxcalls = s_read_int(key_value); 00778 00779 if(maxcalls < 0) 00780 { 00781 LogCrit(COMPONENT_CONFIG, 00782 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: null or positive integer expected.", 00783 key_name); 00784 ReturnCode(ERR_FSAL_INVAL, 0); 00785 } 00786 00787 out_parameter->fsal_info.max_fs_calls = (unsigned int)maxcalls; 00788 00789 } 00790 else 00791 { 00792 LogCrit(COMPONENT_CONFIG, 00793 "FSAL LOAD PARAMETER: ERROR: Unknown or unsettable key: %s (item %s)", 00794 key_name, CONF_LABEL_FSAL); 00795 ReturnCode(ERR_FSAL_INVAL, 0); 00796 } 00797 00798 } 00799 00800 /* init logging */ 00801 00802 if(LogFile) 00803 SetComponentLogFile(COMPONENT_FSAL, LogFile); 00804 00805 if(DebugLevel != -1) 00806 SetComponentLogLevel(COMPONENT_FSAL, DebugLevel); 00807 00808 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00809 00810 } /* FSAL_load_FSAL_parameter_from_conf */ 00811 00812 /* load general filesystem configuration options */ 00813 00814 fsal_status_t COMMON_load_FS_common_parameter_from_conf(config_file_t in_config, 00815 fsal_parameter_t * out_parameter) 00816 { 00817 int err; 00818 int var_max, var_index; 00819 char *key_name; 00820 char *key_value; 00821 config_item_t block; 00822 00823 block = config_FindItemByName(in_config, CONF_LABEL_FS_COMMON); 00824 00825 /* cannot read item */ 00826 if(block == NULL) 00827 { 00828 LogCrit(COMPONENT_CONFIG, 00829 "FSAL LOAD PARAMETER: Cannot read item \"%s\" from configuration file", 00830 CONF_LABEL_FS_COMMON); 00831 ReturnCode(ERR_FSAL_NOENT, 0); 00832 } 00833 else if(config_ItemType(block) != CONFIG_ITEM_BLOCK) 00834 { 00835 LogCrit(COMPONENT_CONFIG, 00836 "FSAL LOAD PARAMETER: Item \"%s\" is expected to be a block", 00837 CONF_LABEL_FS_COMMON); 00838 ReturnCode(ERR_FSAL_INVAL, 0); 00839 } 00840 00841 /* 00842 configurable common info for filesystem are: 00843 link_support # hardlink support 00844 symlink_support # symlinks support 00845 cansettime # Is it possible to change file times 00846 maxread # Max read size from FS 00847 maxwrite # Max write size to FS 00848 umask 00849 auth_exportpath_xdev 00850 xattr_access_rights 00851 00852 */ 00853 00854 var_max = config_GetNbItems(block); 00855 00856 for(var_index = 0; var_index < var_max; var_index++) 00857 { 00858 config_item_t item; 00859 00860 item = config_GetItemByIndex(block, var_index); 00861 00862 err = config_GetKeyValue(item, &key_name, &key_value); 00863 if(err) 00864 { 00865 LogCrit(COMPONENT_CONFIG, 00866 "FSAL LOAD PARAMETER: ERROR reading key[%d] from section \"%s\" of configuration file.", 00867 var_index, CONF_LABEL_FS_COMMON); 00868 ReturnCode(ERR_FSAL_SERVERFAULT, err); 00869 } 00870 00871 /* does the variable exists ? */ 00872 if(!STRCMP(key_name, "link_support")) 00873 { 00874 00875 int bool = StrToBoolean(key_value); 00876 00877 if(bool == -1) 00878 { 00879 LogCrit(COMPONENT_CONFIG, 00880 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: 0 or 1 expected.", 00881 key_name); 00882 ReturnCode(ERR_FSAL_INVAL, 0); 00883 } 00884 00885 /* if set to false, force value to false. 00886 * else keep fs default. 00887 */ 00888 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, link_support, 00889 FSAL_INIT_MAX_LIMIT, bool); 00890 00891 } 00892 else if(!STRCMP(key_name, "symlink_support")) 00893 { 00894 int bool = StrToBoolean(key_value); 00895 00896 if(bool == -1) 00897 { 00898 LogCrit(COMPONENT_CONFIG, 00899 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: 0 or 1 expected.", 00900 key_name); 00901 ReturnCode(ERR_FSAL_INVAL, 0); 00902 } 00903 00904 /* if set to false, force value to false. 00905 * else keep fs default. 00906 */ 00907 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, symlink_support, 00908 FSAL_INIT_MAX_LIMIT, bool); 00909 } 00910 else if(!STRCMP(key_name, "cansettime")) 00911 { 00912 int bool = StrToBoolean(key_value); 00913 00914 if(bool == -1) 00915 { 00916 LogCrit(COMPONENT_CONFIG, 00917 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: 0 or 1 expected.", 00918 key_name); 00919 ReturnCode(ERR_FSAL_INVAL, 0); 00920 } 00921 00922 /* if set to false, force value to false. 00923 * else keep fs default. 00924 */ 00925 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, cansettime, 00926 FSAL_INIT_MAX_LIMIT, bool); 00927 00928 } 00929 else if(!STRCMP(key_name, "maxread")) 00930 { 00931 fsal_u64_t size; 00932 00933 if(s_read_int64(key_value, &size)) 00934 { 00935 LogCrit(COMPONENT_CONFIG, 00936 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: positive integer expected.", 00937 key_name); 00938 ReturnCode(ERR_FSAL_INVAL, 0); 00939 } 00940 00941 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, maxread, 00942 FSAL_INIT_FORCE_VALUE, size); 00943 00944 } 00945 else if(!STRCMP(key_name, "maxwrite")) 00946 { 00947 fsal_u64_t size; 00948 00949 if(s_read_int64(key_value, &size)) 00950 { 00951 LogCrit(COMPONENT_CONFIG, 00952 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: positive integer expected.", 00953 key_name); 00954 ReturnCode(ERR_FSAL_INVAL, 0); 00955 } 00956 00957 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, maxwrite, 00958 FSAL_INIT_FORCE_VALUE, size); 00959 00960 } 00961 else if(!STRCMP(key_name, "umask")) 00962 { 00963 int mode = s_read_octal(key_value); 00964 00965 if(mode < 0) 00966 { 00967 LogCrit(COMPONENT_CONFIG, 00968 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: octal expected.", 00969 key_name); 00970 ReturnCode(ERR_FSAL_INVAL, 0); 00971 } 00972 00973 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, umask, 00974 FSAL_INIT_FORCE_VALUE, unix2fsal_mode(mode)); 00975 00976 } 00977 else if(!STRCMP(key_name, "auth_xdev_export")) 00978 { 00979 int bool = StrToBoolean(key_value); 00980 00981 if(bool == -1) 00982 { 00983 LogCrit(COMPONENT_CONFIG, 00984 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: boolean expected.", 00985 key_name); 00986 ReturnCode(ERR_FSAL_INVAL, 0); 00987 } 00988 00989 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, auth_exportpath_xdev, 00990 FSAL_INIT_FORCE_VALUE, bool); 00991 } 00992 else if(!STRCMP(key_name, "xattr_access_rights")) 00993 { 00994 int mode = s_read_octal(key_value); 00995 00996 if(mode < 0) 00997 { 00998 LogCrit(COMPONENT_CONFIG, 00999 "FSAL LOAD PARAMETER: ERROR: Unexpected value for %s: octal expected.", 01000 key_name); 01001 ReturnCode(ERR_FSAL_INVAL, 0); 01002 } 01003 01004 FSAL_SET_INIT_INFO(out_parameter->fs_common_info, xattr_access_rights, 01005 FSAL_INIT_FORCE_VALUE, unix2fsal_mode(mode)); 01006 01007 } 01008 else 01009 { 01010 LogCrit(COMPONENT_CONFIG, 01011 "FSAL LOAD PARAMETER: ERROR: Unknown or unsettable key: %s (item %s)", 01012 key_name, CONF_LABEL_FS_COMMON); 01013 ReturnCode(ERR_FSAL_INVAL, 0); 01014 } 01015 01016 } 01017 01018 ReturnCode(ERR_FSAL_NO_ERROR, 0); 01019 01020 } /* FSAL_load_FS_common_parameter_from_conf */ 01021 01022 fsal_status_t COMMON_share_op_notsupp( fsal_file_t * p_file_descriptor, /* IN */ 01023 fsal_handle_t * p_filehandle, /* IN */ 01024 fsal_op_context_t * p_context, /* IN */ 01025 void * p_owner, /* IN (opaque to FSAL) */ 01026 fsal_share_param_t request_share ) /* IN */ 01027 { 01028 Return(ERR_FSAL_NOTSUPP, 0, INDEX_FSAL_share_op); 01029 }